]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Skip the tests which perform a character-set conversion if the platform
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 20 Mar 2011 16:36:38 +0000 (12:36 -0400)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 20 Mar 2011 16:36:38 +0000 (12:36 -0400)
does not support.

SVN-Revision: 3035

libarchive/test/main.c
libarchive/test/test.h
libarchive/test/test_pax_filename_encoding.c
libarchive/test/test_read_format_cab_filename.c
libarchive/test/test_read_format_lha_filename.c
libarchive/test/test_read_format_zip_filename.c

index ee41e56f814ffd12604b7eb5c5a970b535dda04a..cdc14fcfb0452700ca4df268492dce2fe4a5a44e 100644 (file)
@@ -28,6 +28,9 @@
 #include <sys/time.h>
 #endif
 #include <errno.h>
+#ifdef HAVE_ICONV_H
+#include <iconv.h>
+#endif
 #include <limits.h>
 #include <locale.h>
 #include <stdarg.h>
@@ -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
index aa0e0fc4b27ae27eac5746d73770ec5d8d3d3e8a..780fe58db1c887e1d4c8929f56e77a7f5bfa4c8c 100644 (file)
@@ -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, ...);
index 969e3de83863e73893f6bb53958aff68ccf3f7e0..02a8cd3231a143c43e7d2244ae590de0838dc78a 100644 (file)
@@ -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;
index 207b5f64eb03b7ed163193c62547e896b04deed3..54b6798c76984efc37dcb184ca5183e1e058e7c0 100644 (file)
@@ -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;
index 6927e268922d15ece5824c7585a8ea600d8479a0..1b67b415396034761d3a0dfd743dff6992ba6ba2 100644 (file)
@@ -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;
index 709d4f8e2aa9693d6a7d84ae0913c77245f52137..bccb57fccaa114bb1a9427c25d68496bc08d923c 100644 (file)
@@ -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;