]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix remaining MinGW tests
authorMartin Matuska <martin@matuska.org>
Sat, 6 Apr 2019 23:54:42 +0000 (01:54 +0200)
committerMartin Matuska <martin@matuska.org>
Sun, 7 Apr 2019 00:38:54 +0000 (02:38 +0200)
Enable tests on MinGW CI builds

.cirrus.yml
build/ci/travis_ci.sh
cpio/test/test_format_newc.c
cpio/test/test_option_L_upper.c
cpio/test/test_option_a.c
libarchive/test/test_read_disk_directory_traversals.c
tar/test/test_option_C_mtree.c
tar/test/test_strip_components.c
test_utils/test_main.c

index d3627afc9d3d1f48bef17339e2441979307b9483..acf4c8a28f1dbae30d68357469bd3f5d62b0f1a6 100644 (file)
@@ -51,14 +51,13 @@ Windows_MinGW_task:
   prepare_script:
   - choco install -y --no-progress mingw
   - choco install -y --no-progress --installargs 'ADD_CMAKE_TO_PATH=User' cmake
-  - choco install -y --no-progress wget
   - refreshenv
   - mkdir build_ci\mingw
   zlib_script:
   - refreshenv
   - mkdir build_ci\libs
   - cd build_ci\libs
-  - wget "https://www.zlib.net/zlib-1.2.11.tar.gz"
+  - curl -o zlib-1.2.11.tar.gz "https://www.zlib.net/zlib-1.2.11.tar.gz"
   - tar -x -z -f zlib-1.2.11.tar.gz
   - cd zlib-1.2.11
   - cmake -G "MinGW Makefiles" -D CMAKE_BUILD_TYPE="Release" .
@@ -72,3 +71,8 @@ Windows_MinGW_task:
   - refreshenv
   - cd build_ci\mingw
   - mingw32-make
+  test_script:
+  - refreshenv
+  - copy build_ci\libs\zlib-1.2.11\libzlib.dll build_ci\mingw\bin\
+  - cd build_ci\mingw
+  - mingw32-make test
index e51a67931b9f3107fee8dd44ed9f5898f10549d3..abbdd8d3849fd39bd3acc37b41a28336366b51aa 100755 (executable)
@@ -21,8 +21,7 @@ case "$UNAME" in
                set -x
                cmake -G "MSYS Makefiles" -D CMAKE_C_COMPILER="${CC}" -D CMAKE_MAKE_PROGRAM="mingw32-make" -D CMAKE_BUILD_TYPE="Release" "${SRCDIR}"
                mingw32-make
-               # The MinGW tests time out on Travis CI, disable for now
-               #mingw32-make test
+               mingw32-make test
                set +x
        else
                echo "Unknown or unspecified build type: ${BS}"
index 2c6694267646da229c60c69ea70e29b7850d9c86..6c981f6ac139361b603f29abfaaa075a6a7a4e7b 100644 (file)
@@ -233,7 +233,12 @@ DEFINE_TEST(test_format_newc)
                assert(is_hex(e, 110));
                assertEqualMem(e + 0, "070701", 6); /* Magic */
                assert(is_hex(e + 6, 8)); /* ino */
+#if defined(_WIN32) && !defined(CYGWIN)
+               /* Mode: Group members bits and others bits do not work. */
+               assertEqualInt(0xa180, from_hex(e + 14, 8) & 0xffc0);
+#else
                assertEqualInt(0xa1ff, from_hex(e + 14, 8)); /* Mode */
+#endif
                assertEqualInt(from_hex(e + 22, 8), uid); /* uid */
                assertEqualInt(gid, from_hex(e + 30, 8)); /* gid */
                assertEqualMem(e + 38, "00000001", 8); /* nlink */
index 7fd10cefc1483c3fd511fb85746227a91210c780..bf3a9c430c916bf0e8aae1b67827316caccd0756 100644 (file)
@@ -30,8 +30,10 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_option_L.c,v 1.2 2008/08/24 06:21
  * tests won't run on Windows. */
 #if defined(_WIN32) && !defined(__CYGWIN__)
 #define CAT "type"
+#define SEP "\\"
 #else
 #define CAT "cat"
+#define SEP "/"
 #endif
 
 DEFINE_TEST(test_option_L_upper)
@@ -77,7 +79,8 @@ DEFINE_TEST(test_option_L_upper)
 
        assertMakeDir("unpack", 0755);
        assertChdir("unpack");
-       r = systemf(CAT " ../archive.out | %s -i >unpack.out 2>unpack.err", testprog);
+       r = systemf(CAT " .." SEP "archive.out | %s -i >unpack.out 2>unpack.err", testprog);
+
        failure("Error invoking %s -i", testprog);
        assertEqualInt(r, 0);
        assertTextFileContents("1 block\n", "unpack.err");
@@ -92,7 +95,8 @@ DEFINE_TEST(test_option_L_upper)
 
        assertMakeDir("unpack-L", 0755);
        assertChdir("unpack-L");
-       r = systemf(CAT " ../archive-L.out | %s -i >unpack-L.out 2>unpack-L.err", testprog);
+       r = systemf(CAT " .." SEP "archive-L.out | %s -i >unpack-L.out 2>unpack-L.err", testprog);
+
        failure("Error invoking %s -i < archive-L.out", testprog);
        assertEqualInt(r, 0);
        assertTextFileContents("1 block\n", "unpack-L.err");
index 296387777ccf2c0d6c350b049d9982c1949cadb3..e96bdf3cab5b74a40a107667bf7c070351d818ef 100644 (file)
@@ -71,8 +71,13 @@ test_create(void)
                 * #ifdef this section out.  Most of the test below is
                 * still valid. */
                memset(&times, 0, sizeof(times));
+#if defined(_WIN32) && !defined(CYGWIN)
+               times.actime = 86400;
+               times.modtime = 86400;
+#else
                times.actime = 1;
                times.modtime = 3;
+#endif
                assertEqualInt(0, utime(files[i].name, &times));
 
                /* Record whatever atime the file ended up with. */
index 1e41c3caa333da83f04903808c87d82069529636..7dd19157d4d21077df2da429e3f46e13809facf8 100644 (file)
@@ -40,7 +40,30 @@ atimeIsUpdated(void)
 {
        const char *fn = "fs_noatime";
        struct stat st;
+#if defined(_WIN32) && !defined(CYGWIN)
+       char *buff = NULL;
+       char *ptr;
+       int r;
 
+       r = systemf("fsutil behavior query disableLastAccess > query_atime");
+       if (r == 0) {
+               buff = slurpfile(NULL, "query_atime");
+               if (buff != NULL) {
+                       ptr = buff;
+                       while(*ptr != '\0' && !isdigit(*ptr)) {
+                               ptr++;
+                       }
+                       if (*ptr == '0') {
+                               free(buff);
+                               return(1);
+                       } else if (*ptr == '1' || *ptr == '2') {
+                               free(buff);
+                               return(0);
+                       }
+                       free(buff);
+               }
+       }
+#endif
        if (!assertMakeFile(fn, 0666, "a"))
                return (0);
        if (!assertUtimes(fn, 1, 0, 1, 0))
index caf8044bf932f7165952136db299fe4a0eb83b9b..f0903066892c82dcafa3ba3dfa3d2880eb26c1ca 100644 (file)
@@ -36,6 +36,9 @@ DEFINE_TEST(test_option_C_mtree)
        p0 = NULL;
        char *content = "./foo type=file uname=root gname=root mode=0755\n";
        char *filename = "output.tar";
+#if defined(_WIN32) && !defined(CYGWIN)
+       char *p;
+#endif
 
        /* an absolute path to mtree file */ 
        char *mtree_file = "/METALOG.mtree";    
@@ -48,9 +51,21 @@ DEFINE_TEST(test_option_C_mtree)
        assertMakeDir("bar", 0775);
        assertMakeFile("bar/foo", 0777, "abc");
 
-       r = systemf("%s -cf %s -C bar \"@%s\" >step1.out 2>step1.err", testprog, filename, absolute_path);
+#if defined(_WIN32) && !defined(CYGWIN)
+       p = absolute_path;
+       while(*p != '\0') {
+               if (*p == '/')
+                       *p = '\\';
+               p++;
+       }
 
+       r = systemf("%s -cf %s -C bar @%s >step1.out 2>step1.err", testprog, filename, absolute_path);
        failure("Error invoking %s -cf %s -C bar @%s", testprog, filename, absolute_path);
+#else
+       r = systemf("%s -cf %s -C bar \"@%s\" >step1.out 2>step1.err", testprog, filename, absolute_path);
+       failure("Error invoking %s -cf %s -C bar \"@%s\"", testprog, filename, absolute_path);
+#endif
+
        assertEqualInt(r, 0);
        assertEmptyFile("step1.out");
        assertEmptyFile("step1.err");
index e1d71ddc525fe9b0651798f6300869b452dc4a3a..caf45a3e144ddc8b9031a8becd01d62b03d17f5c 100644 (file)
@@ -64,9 +64,10 @@ DEFINE_TEST(test_strip_components)
        failure("d0/d1/s2 is a symlink to something that won't be extracted");
        /* If platform supports symlinks, target/s2 is a broken symlink. */
        /* If platform does not support symlink, target/s2 doesn't exist. */
-       assertFileNotExists("target/s2");
        if (canSymlink())
                assertIsSymlink("target/s2", "d2/f1");
+       else
+               assertFileNotExists("target/s2");
        failure("d0/d1/d2 should be extracted");
        assertIsDir("target/d2", -1);
 
index 91effdf583e0ae50ba906921b844b1984228e4b9..cd4c772b8ed3413b6a0a31a39a5391296a49bc88 100644 (file)
@@ -1717,16 +1717,30 @@ is_symlink(const char *file, int line,
        REPARSE_DATA_BUFFER *buf;
        size_t len, len2;
        wchar_t *linknamew, *contentsw;
+       const char *p;
+       char *s, *pn;
        int ret = 0;
        BYTE *indata;
        DWORD flag = FILE_FLAG_BACKUP_SEMANTICS |
            FILE_FLAG_OPEN_REPARSE_POINT;
 
-       if (contents == NULL)
-               return (0);
+       /* Replace slashes with backslashes in pathname */
+       pn = malloc((strlen(pathname) + 1) * sizeof(char));
+       p = pathname;
+       s = pn;
+       while(*p != '\0') {
+               if(*p == '/')
+                       *s = '\\';
+               else
+                       *s = *p;
+               p++;
+               s++;
+       }
+       *s = '\0';
 
-       h = CreateFileA(pathname, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING,
+       h = CreateFileA(pn, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING,
            flag, NULL);
+       free(pn);
        if (h == INVALID_HANDLE_VALUE)
                return (0);
 
@@ -1747,6 +1761,11 @@ is_symlink(const char *file, int line,
                return (0);
        }
 
+       if (contents == NULL) {
+               free(indata);
+               return (1);
+       }
+
        len = buf->SymbolicLinkReparseBuffer.SubstituteNameLength;
 
        linknamew = malloc(len + sizeof(wchar_t));