From: Michihiro NAKAJIMA Date: Sun, 20 Mar 2011 16:36:38 +0000 (-0400) Subject: Skip the tests which perform a character-set conversion if the platform X-Git-Tag: v3.0.0a~637 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3154080cd51b4c877405cc2f6c91ea712a94c98f;p=thirdparty%2Flibarchive.git Skip the tests which perform a character-set conversion if the platform does not support. SVN-Revision: 3035 --- diff --git a/libarchive/test/main.c b/libarchive/test/main.c index ee41e56f8..cdc14fcfb 100644 --- a/libarchive/test/main.c +++ b/libarchive/test/main.c @@ -28,6 +28,9 @@ #include #endif #include +#ifdef HAVE_ICONV_H +#include +#endif #include #include #include @@ -1658,6 +1661,23 @@ canGunzip(void) return (value); } +/* + * Can this platform convert character-set. + */ +int +canConvertCharset(const char *to_charset, const char *from_charset) +{ +#if HAVE_ICONV + iconv_t cd = iconv_open(to_charset, from_charset); + if (cd == NULL) + return (0); + iconv_close(cd); + return (1); +#else + return (0); +#endif +} + /* * Sleep as needed; useful for verifying disk timestamp changes by * ensuring that the wall-clock time has actually changed before we diff --git a/libarchive/test/test.h b/libarchive/test/test.h index aa0e0fc4b..780fe58db 100644 --- a/libarchive/test/test.h +++ b/libarchive/test/test.h @@ -275,6 +275,9 @@ int canGzip(void); /* Return true if this platform can run the "gunzip" program. */ int canGunzip(void); +/* Return true if this patform can convert character-set. */ +int canConvertCharset(const char *, const char *); + /* Suck file into string allocated via malloc(). Call free() when done. */ /* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */ char *slurpfile(size_t *, const char *fmt, ...); diff --git a/libarchive/test/test_pax_filename_encoding.c b/libarchive/test/test_pax_filename_encoding.c index 969e3de83..02a8cd323 100644 --- a/libarchive/test/test_pax_filename_encoding.c +++ b/libarchive/test/test_pax_filename_encoding.c @@ -336,6 +336,11 @@ test_pax_filename_encoding_ru_RU() char buff[4096]; size_t used; + if (!canConvertCharset("UTF-8", "KOI8-R")) { + skipping("This system cannot convert character-set" + " from KOI8-R to UTF-8."); + return; + } if (NULL == setlocale(LC_ALL, "ru_RU.KOI8-R")) { skipping("KOI8-R locale not available on this system."); return; @@ -370,6 +375,11 @@ test_pax_filename_encoding_ja_JP() wchar_t ws[] = {0x8868, L'.', L't', L'x', L't', 0}; size_t used; + if (!canConvertCharset("UTF-8", "eucJP")) { + skipping("This system cannot convert character-set" + " from eucJP to UTF-8."); + return; + } if (NULL == setlocale(LC_ALL, "ja_JP.eucJP")) { skipping("eucJP locale not available on this system."); return; diff --git a/libarchive/test/test_read_format_cab_filename.c b/libarchive/test/test_read_format_cab_filename.c index 207b5f64e..54b6798c7 100644 --- a/libarchive/test/test_read_format_cab_filename.c +++ b/libarchive/test/test_read_format_cab_filename.c @@ -36,6 +36,11 @@ DEFINE_TEST(test_read_format_cab_filename) /* * Read CAB filename in ja_JP.eucJP with "charset=CP932" option. */ + if (!canConvertCharset("eucJP", "CP932")) { + skipping("This system cannot convert character-set" + " from CP932 to eucJP."); + return; + } if (NULL == setlocale(LC_ALL, "ja_JP.eucJP")) { skipping("ja_JP.eucJP locale not available on this system."); return; @@ -80,6 +85,11 @@ DEFINE_TEST(test_read_format_cab_filename) /* * Read CAB filename in ja_JP.UTF-8 with "charset=CP932" option. */ + if (!canConvertCharset("UTF-8", "CP932")) { + skipping("This system cannot convert character-set" + " from CP932 to UTF-8."); + return; + } if (NULL == setlocale(LC_ALL, "ja_JP.UTF-8")) { skipping("ja_JP.UTF-8 locale not available on this system."); return; diff --git a/libarchive/test/test_read_format_lha_filename.c b/libarchive/test/test_read_format_lha_filename.c index 6927e2689..1b67b4153 100644 --- a/libarchive/test/test_read_format_lha_filename.c +++ b/libarchive/test/test_read_format_lha_filename.c @@ -38,6 +38,11 @@ DEFINE_TEST(test_read_format_lha_filename) /* * Read LHA filename in ja_JP.eucJP. */ + if (!canConvertCharset("eucJP", "CP932")) { + skipping("This system cannot convert character-set" + " from CP932 to eucJP."); + return; + } if (NULL == setlocale(LC_ALL, "ja_JP.eucJP")) { skipping("ja_JP.eucJP locale not available on this system."); return; @@ -77,6 +82,11 @@ DEFINE_TEST(test_read_format_lha_filename) /* * Read LHA filename in ja_JP.UTF-8. */ + if (!canConvertCharset("UTF-8", "CP932")) { + skipping("This system cannot convert character-set" + " from CP932 to UTF-8."); + return; + } if (NULL == setlocale(LC_ALL, "ja_JP.UTF-8")) { skipping("ja_JP.UTF-8 locale not available on this system."); return; diff --git a/libarchive/test/test_read_format_zip_filename.c b/libarchive/test/test_read_format_zip_filename.c index 709d4f8e2..bccb57fcc 100644 --- a/libarchive/test/test_read_format_zip_filename.c +++ b/libarchive/test/test_read_format_zip_filename.c @@ -36,6 +36,11 @@ DEFINE_TEST(test_read_format_zip_filename) /* * Read ZIP filename in ja_JP.eucJP with "charset=CP932" option. */ + if (!canConvertCharset("eucJP", "CP932")) { + skipping("This system cannot convert character-set" + " from CP932 to eucJP."); + return; + } if (NULL == setlocale(LC_ALL, "ja_JP.eucJP")) { skipping("ja_JP.eucJP locale not available on this system."); return; @@ -80,6 +85,11 @@ DEFINE_TEST(test_read_format_zip_filename) /* * Read ZIP filename in ja_JP.UTF-8 with "charset=CP932" option. */ + if (!canConvertCharset("UTF-8", "CP932")) { + skipping("This system cannot convert character-set" + " from CP932 to UTF-8."); + return; + } if (NULL == setlocale(LC_ALL, "ja_JP.UTF-8")) { skipping("ja_JP.UTF-8 locale not available on this system."); return;