]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
"Fix" this test on Win32 by suppressing tests of error handling that relies on proper...
authorTim Kientzle <kientzle@gmail.com>
Sun, 29 Nov 2009 20:33:21 +0000 (15:33 -0500)
committerTim Kientzle <kientzle@gmail.com>
Sun, 29 Nov 2009 20:33:21 +0000 (15:33 -0500)
The core problem here is that Windows has several different APIs for character-set conversion.  These tests rely on the POSIX-standard setlocale() to set the default character set for this process in order to then force character-conversion failures and verify the error-handling.  But the Win32 APIs don't obey setlocale() so this fails.  Indeed, I've found no way to programmatically override the CP_ACP code page for just the current process:  I considered using CP_THREAD_ACP instead but it seems to be broken (or at least there are a lot of bloggers claiming it should never be used).  It doesn't help that Windows documentation confuses "code page" with "language" (SetCurrentLocale() accepts a language code but the documentation claims it sets the code page while offering no insight into how language codes get mapped to code pages---remember that Japanese and Chinese are supported by several code pages).  I've gleaned from various blogs that the default code page cannot be set to UTF-8 in any case due to some bad assumptions deep in Win32's character-conversion routines (this implies, of course, that there is a way to set the default code page, which I've not been able to find).  From this, it appears that it's simply not possible to do the kind of testing I want to do here; if someone knows otherwise, please let me know.

SVN-Revision: 1681

libarchive/test/test_pax_filename_encoding.c

index dfa6ae91b9271dbea0c02d391d712f4bcb478906..25e33b897b654d0819bb0c7cea7510769665f095 100644 (file)
@@ -152,11 +152,7 @@ test_pax_filename_encoding_2(void)
        archive_entry_free(entry);
 
        assertEqualInt(0, archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-       archive_write_finish(a);
-#else
        assertEqualInt(0, archive_write_finish(a));
-#endif
 
        /*
         * Now read the entries back.
@@ -182,11 +178,7 @@ test_pax_filename_encoding_2(void)
        assertEqualString(longname, archive_entry_pathname(entry));
 
        assertEqualInt(0, archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-       archive_read_finish(a);
-#else
        assertEqualInt(0, archive_read_finish(a));
-#endif
 }
 
 /*
@@ -228,6 +220,15 @@ test_pax_filename_encoding_3(void)
                return;
        }
 
+       /* Skip test if archive_entry_update_pathname_utf8() is broken. */
+       /* In particular, this is currently broken on Win32 because
+        * setlocale() does not set the default encoding for CP_ACP. */
+       entry = archive_entry_new();
+       if (archive_entry_update_pathname_utf8(entry, badname_utf8)) {
+               skipping("Cannot test conversion failures.");
+               return;
+       }
+
        assert((a = archive_write_new()) != NULL);
        assertEqualIntA(a, 0, archive_write_set_format_pax(a));
        assertEqualIntA(a, 0, archive_write_set_compression_none(a));
@@ -275,11 +276,7 @@ test_pax_filename_encoding_3(void)
        archive_entry_free(entry);
 
        assertEqualInt(0, archive_write_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-       archive_write_finish(a);
-#else
        assertEqualInt(0, archive_write_finish(a));
-#endif
 
        /*
         * Now read the entries back.
@@ -323,11 +320,7 @@ test_pax_filename_encoding_3(void)
        assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &entry));
 
        assertEqualInt(0, archive_read_close(a));
-#if ARCHIVE_VERSION_NUMBER < 2000000
-       archive_read_finish(a);
-#else
        assertEqualInt(0, archive_read_finish(a));
-#endif
 }
 
 DEFINE_TEST(test_pax_filename_encoding)