lib/util/charset Run charset sets with and without the system iconv
authorAndrew Bartlett <abartlet@samba.org>
Fri, 9 Sep 2011 23:53:29 +0000 (09:53 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 10 Sep 2011 12:18:06 +0000 (14:18 +0200)
We need to know that we can load the samba-provided modules, and that
they are correct.  However, we must mark a number of tests as
knownfail due to errors in our internal iconv modules.

Andrew Bartlett

lib/util/charset/charset.h
lib/util/charset/codepoints.c
lib/util/charset/tests/convert_string.c
source4/selftest/knownfail
source4/selftest/tests.py

index ce297d0ddd78b50d2d5555fc5e0e638cfe41a7d7..20887e0e9d4ba12f407539d9176642c6607d271d 100644 (file)
@@ -182,7 +182,8 @@ extern struct smb_iconv_handle *global_iconv_handle;
 struct smb_iconv_handle *get_iconv_handle(void);
 struct smb_iconv_handle *get_iconv_testing_handle(TALLOC_CTX *mem_ctx, 
                                                  const char *dos_charset, 
-                                                 const char *unix_charset);
+                                                 const char *unix_charset,
+                                                 bool native_iconv);
 smb_iconv_t get_conv_handle(struct smb_iconv_handle *ic,
                            charset_t from, charset_t to);
 const char *charset_name(struct smb_iconv_handle *ic, charset_t ch);
index 8cc33a9782ab77db2dc6b5a2aade886cb7957443..0d1020f7a0bb60edb17d7747ce369c7303641f9d 100644 (file)
@@ -174,10 +174,11 @@ struct smb_iconv_handle *get_iconv_handle(void)
 
 struct smb_iconv_handle *get_iconv_testing_handle(TALLOC_CTX *mem_ctx, 
                                                  const char *dos_charset, 
-                                                 const char *unix_charset)
+                                                 const char *unix_charset,
+                                                 bool native_iconv)
 {
        return smb_iconv_handle_reinit(mem_ctx,
-                                      dos_charset, unix_charset, true, NULL);
+                                      dos_charset, unix_charset, native_iconv, NULL);
 }
 
 /**
index 9a5d974fe35da3e967e334427b79f075fa396150..ff19a579bd3b9aa21ce58c8ded0186b6af2e348a 100644 (file)
@@ -21,6 +21,7 @@
 #include "includes.h"
 #include "torture/torture.h"
 #include "lib/util/charset/charset.h"
+#include "param/param.h"
 
 /* The text below is in ancient and a latin charset transliteration of
  * greek, and an english translation.  It from Apology by Plato and sourced from
@@ -105,7 +106,8 @@ static bool test_gd_iso8859_cp850_handle(struct torture_context *tctx)
        talloc_steal(tctx, gd_iso8859_1.data);
        talloc_steal(tctx, gd_utf16le.data);
 
-       iconv_handle = get_iconv_testing_handle(tctx, "ISO8859-1", "CP850");
+       iconv_handle = get_iconv_testing_handle(tctx, "ISO8859-1", "CP850",
+                                               lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
        torture_assert(tctx, iconv_handle, "getting iconv handle");
                
        torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, 
@@ -297,7 +299,8 @@ static bool test_gd_minus_1_handle(struct torture_context *tctx)
        talloc_steal(tctx, gd_cp850.data);
        talloc_steal(tctx, gd_utf16le.data);
 
-       iconv_handle = get_iconv_testing_handle(tctx, "CP850", "CP850");
+       iconv_handle = get_iconv_testing_handle(tctx, "CP850", "CP850", 
+                                               lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
        torture_assert(tctx, iconv_handle, "getting iconv handle");
 
        gd_utf8_terminated = data_blob_talloc(tctx, NULL, gd_utf8.length + 1);
@@ -481,7 +484,8 @@ static bool test_gd_ascii_handle(struct torture_context *tctx)
        talloc_steal(tctx, gd_iso8859_1.data);
        talloc_steal(tctx, gd_utf16le.data);
 
-       iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8");
+       iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8", 
+                                               lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
        torture_assert(tctx, iconv_handle, "getting iconv handle");
 
        torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle,
@@ -550,7 +554,8 @@ static bool test_plato_english_iso8859_cp850_handle(struct torture_context *tctx
        
        talloc_steal(tctx, plato_english_utf16le.data);
 
-       iconv_handle = get_iconv_testing_handle(tctx, "ISO8859-1", "CP850");
+       iconv_handle = get_iconv_testing_handle(tctx, "ISO8859-1", "CP850", 
+                                               lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
        torture_assert(tctx, iconv_handle, "getting iconv handle");
                
        torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, 
@@ -668,7 +673,8 @@ static bool test_plato_english_minus_1_handle(struct torture_context *tctx)
        
        talloc_steal(tctx, plato_english_utf16le.data);
 
-       iconv_handle = get_iconv_testing_handle(tctx, "ISO8859-1", "CP850");
+       iconv_handle = get_iconv_testing_handle(tctx, "ISO8859-1", "CP850", 
+                                               lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
        torture_assert(tctx, iconv_handle, "getting iconv handle");
 
        plato_english_utf8_terminated = data_blob_talloc(tctx, NULL, plato_english_utf8.length + 1);
@@ -809,7 +815,8 @@ static bool test_plato_minus_1_handle(struct torture_context *tctx)
        talloc_steal(tctx, plato_utf8.data);
        talloc_steal(tctx, plato_utf16le.data);
 
-       iconv_handle = get_iconv_testing_handle(tctx, "ISO8859-1", "CP850");
+       iconv_handle = get_iconv_testing_handle(tctx, "ISO8859-1", "CP850",
+                                               lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
        torture_assert(tctx, iconv_handle, "getting iconv handle");
 
        plato_utf8_terminated = data_blob_talloc(tctx, NULL, plato_utf8.length + 1);
@@ -923,7 +930,8 @@ static bool test_plato_cp850_utf8_handle(struct torture_context *tctx)
        talloc_steal(tctx, plato_utf8.data);
        talloc_steal(tctx, plato_utf16le.data);
 
-       iconv_handle = get_iconv_testing_handle(tctx, "CP850", "UTF8");
+       iconv_handle = get_iconv_testing_handle(tctx, "CP850", "UTF8", 
+                                               lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
        torture_assert(tctx, iconv_handle, "creating iconv handle");
                
        torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, 
@@ -1114,7 +1122,8 @@ static bool test_plato_latin_cp850_utf8_handle(struct torture_context *tctx)
        talloc_steal(tctx, plato_latin_utf8.data);
        talloc_steal(tctx, plato_latin_utf16le.data);
 
-       iconv_handle = get_iconv_testing_handle(tctx, "CP850", "UTF8");
+       iconv_handle = get_iconv_testing_handle(tctx, "CP850", "UTF8",
+                                               lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
        torture_assert(tctx, iconv_handle, "creating iconv handle");
                
        torture_assert(tctx, convert_string_talloc_handle(tctx, iconv_handle, 
@@ -1182,7 +1191,8 @@ static bool test_gd_case_utf8_handle(struct torture_context *tctx)
        char *gd_lower, *gd_upper;
        talloc_steal(tctx, gd_utf8.data);
 
-       iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8");
+       iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8",
+                                               lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
        torture_assert(tctx, iconv_handle, "getting utf8 iconv handle");
 
        torture_assert(tctx,
@@ -1245,7 +1255,8 @@ static bool test_gd_case_cp850_handle(struct torture_context *tctx)
        char *gd_lower, *gd_upper;
        talloc_steal(tctx, gd_cp850.data);
 
-       iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "CP850");
+       iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "CP850",
+                                               lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
        torture_assert(tctx, iconv_handle, "getting cp850 iconv handle");
 
        torture_assert(tctx,
@@ -1306,7 +1317,8 @@ static bool test_plato_case_utf8_handle(struct torture_context *tctx)
        char *plato_lower, *plato_upper;
        talloc_steal(tctx, plato_utf8.data);
 
-       iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8");
+       iconv_handle = get_iconv_testing_handle(tctx, "ASCII", "UTF8",
+                                               lpcfg_parm_bool(tctx->lp_ctx, NULL, "iconv", "native", true));
        torture_assert(tctx, iconv_handle, "getting utf8 iconv handle");
 
        torture_assert(tctx,
index 915591b9e38ee2f0e2e1c5b361b2b06d275f5e97..0152676b77d24c88efa13726015e7164a1744452 100644 (file)
@@ -5,6 +5,9 @@
 # a successful run for any of these tests an error.
 ^samba4.local.resolve.*.async
 ^samba4.local.iconv.*.next_codepoint()
+^samba4.local.iconv.5M random UTF-16LE sequences # Fails because our CP850 module returns the wrong error codes
+^samba4.local.convert_string_handle.iconv.modules.plato_cp850_utf8
+^samba4.local.convert_string.iconv.modules.plato
 ^samba4..*base.delete.*.deltest17
 ^samba4..*base.delete.*.deltest20a
 ^samba4..*base.delete.*.deltest20b
index 21e19554baa5aa6d33ad689c1fe2f314b21f6347..f64a803a7850b9a0b41bbf3fe5485b57574f40c8 100755 (executable)
@@ -267,6 +267,12 @@ plansmbtorturetestsuite('echo.udp', 'dc:local', '//$SERVER/whatever')
 for t in smb4torture_testsuites("local."):
     plansmbtorturetestsuite(t, "none", "ncalrpc:")
 
+# Confirm these tests with the system iconv too
+for t in ["local.convert_string_handle", "local.convert_string", "local.ndr"]:
+    modname = "samba4.%s.iconv.modules" % t
+    cmdline = "%s %s %s" % (valgrindify(smb4torture), "ncalrpc: --option='iconv:native=false'", t)
+    plantestsuite_loadlist(modname, env, cmdline)
+
 tdbtorture4 = binpath("tdbtorture")
 if os.path.exists(tdbtorture4):
     plantestsuite("tdb.stress", "none", valgrindify(tdbtorture4))