diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-08-26 22:15:44 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 15:02:42 -0500 |
commit | 11744d9f1d74ac3992546dd006d4c128dbfc5cbd (patch) | |
tree | c21f8fc001cdc7b8fea3e719c1c234d83ecaef7c /source4 | |
parent | 6ca139026956916a4a956dd36d10d7f5a72272b8 (diff) | |
download | samba-11744d9f1d74ac3992546dd006d4c128dbfc5cbd.tar.gz samba-11744d9f1d74ac3992546dd006d4c128dbfc5cbd.tar.bz2 samba-11744d9f1d74ac3992546dd006d4c128dbfc5cbd.zip |
r24685: Don't warn about iconv tests not being usable until they're actually being run.
(This used to be commit df34e606981c3a9fe5b9ac846dbf40d36500bd6b)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/torture/local/iconv.c | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/source4/torture/local/iconv.c b/source4/torture/local/iconv.c index 6d318f2d91..c543aa7c8f 100644 --- a/source4/torture/local/iconv.c +++ b/source4/torture/local/iconv.c @@ -28,6 +28,27 @@ #include "torture/util.h" #if HAVE_NATIVE_ICONV + +static bool iconv_untestable(struct torture_context *tctx) +{ + iconv_t cd; + + if (!lp_parm_bool(-1, "iconv", "native", true)) + torture_skip(tctx, "system iconv disabled - skipping test"); + + cd = iconv_open("UTF-16LE", "UCS-4LE"); + if (cd == (iconv_t)-1) + torture_skip(tctx, "unable to test - system iconv library does not support UTF-16LE -> UCS-4LE"); + iconv_close(cd); + + cd = iconv_open("UTF-16LE", "CP850"); + if (cd == (iconv_t)-1) + torture_skip(tctx, "unable to test - system iconv library does not support UTF-16LE -> CP850\n"); + iconv_close(cd); + + return false; +} + /* generate a UTF-16LE buffer for a given unicode codepoint */ @@ -292,6 +313,9 @@ static bool test_codepoint(struct torture_context *tctx, unsigned int codepoint) static bool test_next_codepoint(struct torture_context *tctx) { + if (iconv_untestable(tctx)) + return true; + unsigned int codepoint; for (codepoint=0;codepoint<(1<<20);codepoint++) { if (!test_codepoint(tctx, codepoint)) @@ -306,6 +330,9 @@ static bool test_first_1m(struct torture_context *tctx) size_t size; unsigned char inbuf[1000]; + if (iconv_untestable(tctx)) + return true; + for (codepoint=0;codepoint<(1<<20);codepoint++) { if (gen_codepoint_utf16(codepoint, (char *)inbuf, &size) != 0) { continue; @@ -328,6 +355,10 @@ static bool test_random_5m(struct torture_context *tctx) { unsigned char inbuf[1000]; unsigned int i; + + if (iconv_untestable(tctx)) + return true; + for (i=0;i<500000;i++) { size_t size; unsigned int c; @@ -368,30 +399,8 @@ static bool test_random_5m(struct torture_context *tctx) struct torture_suite *torture_local_iconv(TALLOC_CTX *mem_ctx) { - static iconv_t cd; struct torture_suite *suite = torture_suite_create(mem_ctx, "ICONV"); - if (!lp_parm_bool(-1, "iconv", "native", True)) { - printf("system iconv disabled - skipping test\n"); - return NULL; - } - - cd = iconv_open("UTF-16LE", "UCS-4LE"); - if (cd == (iconv_t)-1) { - printf("unable to test - system iconv library does not support UTF-16LE -> UCS-4LE\n"); - return NULL; - } - iconv_close(cd); - - cd = iconv_open("UTF-16LE", "CP850"); - if (cd == (iconv_t)-1) { - printf("unable to test - system iconv library does not support UTF-16LE -> CP850\n"); - return NULL; - } - iconv_close(cd); - - srandom(time(NULL)); - torture_suite_add_simple_test(suite, "next_codepoint()", test_next_codepoint); |