]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
On Windows, pass test_option_L in bsdcpio_test.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Fri, 6 Mar 2009 17:03:26 +0000 (12:03 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Fri, 6 Mar 2009 17:03:26 +0000 (12:03 -0500)
SVN-Revision: 741

cpio/test/test_option_L.c

index 0caa0f0e616af5c7d09d836302ced4cd537b0d30..1f5e4e0528692fc184747b8554ec9a17ba141a95 100644 (file)
 #include "test.h"
 __FBSDID("$FreeBSD: src/usr.bin/cpio/test/test_option_L.c,v 1.2 2008/08/24 06:21:00 kientzle Exp $");
 
+#ifdef _WIN32
+#define CAT "type"
+#else
+#define CAT "cat"
+#endif
+
 DEFINE_TEST(test_option_L)
 {
        struct stat st;
+       const char *p;
        int fd, filelist;
        int r;
 
@@ -46,37 +53,54 @@ DEFINE_TEST(test_option_L)
 
        close(filelist);
 
-       r = systemf("cat filelist | %s -pd copy >copy.out 2>copy.err", testprog);
+       r = systemf(CAT " filelist | %s -pd copy >copy.out 2>copy.err", testprog);
        assertEqualInt(r, 0);
        assertEqualInt(0, lstat("copy/symlink", &st));
+#ifndef _WIN32
        failure("Regular -p without -L should preserve symlinks.");
        assert(S_ISLNK(st.st_mode));
+#endif
 
-       r = systemf("cat filelist | %s -pd -L copy-L >copy-L.out 2>copy-L.err", testprog);
+       r = systemf(CAT " filelist | %s -pd -L copy-L >copy-L.out 2>copy-L.err", testprog);
        assertEqualInt(r, 0);
        assertEmptyFile("copy-L.out");
-       assertFileContents("1 block\n", 8, "copy-L.err");
+       p = "1 block" NL;
+       assertFileContents(p, strlen(p), "copy-L.err");
        assertEqualInt(0, lstat("copy-L/symlink", &st));
        failure("-pdL should dereference symlinks and turn them into files.");
        assert(!S_ISLNK(st.st_mode));
 
-       r = systemf("cat filelist | %s -o >archive.out 2>archive.err", testprog);
+       r = systemf(CAT " filelist | %s -o >archive.out 2>archive.err", testprog);
        failure("Error invoking %s -o ", testprog);
        assertEqualInt(r, 0);
 
        assertEqualInt(0, mkdir("unpack", 0755));
+#ifdef _WIN32
+       assertEqualInt(0, chdir("unpack"));
+       r = systemf("type ..\\archive.out | %s -i >unpack.out 2>unpack.err", testprog);
+       assertEqualInt(0, chdir(".."));
+#else
        r = systemf("cat archive.out | (cd unpack ; %s -i >unpack.out 2>unpack.err)", testprog);
+#endif
        failure("Error invoking %s -i", testprog);
        assertEqualInt(r, 0);
        assertEqualInt(0, lstat("unpack/symlink", &st));
+#ifndef _WIN32
        assert(S_ISLNK(st.st_mode));
+#endif
 
-       r = systemf("cat filelist | %s -oL >archive-L.out 2>archive-L.err", testprog);
+       r = systemf(CAT " filelist | %s -oL >archive-L.out 2>archive-L.err", testprog);
        failure("Error invoking %s -oL", testprog);
        assertEqualInt(r, 0);
 
        assertEqualInt(0, mkdir("unpack-L", 0755));
+#ifdef _WIN32
+       assertEqualInt(0, chdir("unpack-L"));
+       r = systemf("type ..\\archive-L.out | %s -i >unpack-L.out 2>unpack-L.err", testprog);
+       assertEqualInt(0, chdir(".."));
+#else
        r = systemf("cat archive-L.out | (cd unpack-L ; %s -i >unpack-L.out 2>unpack-L.err)", testprog);
+#endif
        failure("Error invoking %s -i < archive-L.out", testprog);
        assertEqualInt(r, 0);
        assertEqualInt(0, lstat("unpack-L/symlink", &st));