diff options
author | kientzle <kientzle@FreeBSD.org> | 2009-03-08 05:47:21 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2009-03-08 05:47:21 +0000 |
commit | 9ab299b136d96059e3903cf712eadfd82dddc3ac (patch) | |
tree | bcdf4e5f9ce124f6ac9ca61f2bf0b1a77d73818c /usr.bin/tar/test | |
parent | f11509af10454a047769d60c430b85c2aba51000 (diff) | |
download | FreeBSD-src-9ab299b136d96059e3903cf712eadfd82dddc3ac.zip FreeBSD-src-9ab299b136d96059e3903cf712eadfd82dddc3ac.tar.gz |
Merger r629-631,633-646,648,654,678,681,682 from libarchive.googlecode.com:
Many changes for Windows compatibility. bsdtar_test now runs successfully
on both POSIX platforms and Windows.
Diffstat (limited to 'usr.bin/tar/test')
-rw-r--r-- | usr.bin/tar/test/main.c | 31 | ||||
-rw-r--r-- | usr.bin/tar/test/test.h | 6 | ||||
-rw-r--r-- | usr.bin/tar/test/test_0.c | 9 | ||||
-rw-r--r-- | usr.bin/tar/test/test_basic.c | 35 | ||||
-rw-r--r-- | usr.bin/tar/test/test_copy.c | 10 | ||||
-rw-r--r-- | usr.bin/tar/test/test_option_T.c | 34 | ||||
-rw-r--r-- | usr.bin/tar/test/test_option_s.c | 11 | ||||
-rw-r--r-- | usr.bin/tar/test/test_patterns.c | 12 | ||||
-rw-r--r-- | usr.bin/tar/test/test_patterns_2.tar.uu | 232 | ||||
-rw-r--r-- | usr.bin/tar/test/test_patterns_2.tgz.uu | 9 | ||||
-rw-r--r-- | usr.bin/tar/test/test_patterns_3.tar.uu | 232 | ||||
-rw-r--r-- | usr.bin/tar/test/test_patterns_3.tgz.uu | 8 | ||||
-rw-r--r-- | usr.bin/tar/test/test_strip_components.c | 4 | ||||
-rw-r--r-- | usr.bin/tar/test/test_symlink_dir.c | 27 | ||||
-rw-r--r-- | usr.bin/tar/test/test_version.c | 17 |
15 files changed, 623 insertions, 54 deletions
diff --git a/usr.bin/tar/test/main.c b/usr.bin/tar/test/main.c index 7f114ecf..ad434aa 100644 --- a/usr.bin/tar/test/main.c +++ b/usr.bin/tar/test/main.c @@ -504,6 +504,7 @@ test_assert_empty_file(const char *f1fmt, ...) (ssize_t)sizeof(buff) : (ssize_t)st.st_size; s = read(fd, buff, s); hexdump(buff, NULL, s, 0); + close(fd); } report_failure(NULL); return (0); @@ -564,11 +565,16 @@ test_assert_equal_file(const char *f1, const char *f2pattern, ...) n2 = read(fd2, buff2, sizeof(buff2)); if (n1 != n2) break; - if (n1 == 0 && n2 == 0) + if (n1 == 0 && n2 == 0) { + close(fd1); + close(fd2); return (1); + } if (memcmp(buff1, buff2, n1) != 0) break; } + close(fd1); + close(fd2); failures ++; if (!verbose && previous_failures(test_filename, test_line)) return (0); @@ -648,6 +654,7 @@ test_assert_file_contents(const void *buff, int s, const char *fpattern, ...) } contents = malloc(s * 2); n = read(fd, contents, s * 2); + close(fd); if (n == s && memcmp(buff, contents, s) == 0) { free(contents); return (1); @@ -802,7 +809,11 @@ static int test_run(int i, const char *tmpdir) /* If there were no failures, we can remove the work dir. */ if (failures == failures_before) { if (!keep_temp_files && chdir(tmpdir) == 0) { +#ifdef _WIN32 + systemf("rmdir /S /Q %s", tests[i].name); +#else systemf("rm -rf %s", tests[i].name); +#endif } } /* Return appropriate status. */ @@ -901,6 +912,9 @@ int main(int argc, char **argv) int i, tests_run = 0, tests_failed = 0, opt; time_t now; char *refdir_alloc = NULL; +#ifdef _WIN32 + char *testprg; +#endif const char *opt_arg, *progname, *p; char tmpdir[256]; char tmpdir_timestamp[256]; @@ -913,7 +927,8 @@ int main(int argc, char **argv) */ progname = p = argv[0]; while (*p != '\0') { - if (*p == '/') + /* Support \ or / dir separators for Windows compat. */ + if (*p == '/' || *p == '\\') progname = p + 1; ++p; } @@ -995,6 +1010,18 @@ int main(int argc, char **argv) if (testprog == NULL) usage(progname); #endif +#ifdef _WIN32 + /* + * command.com cannot accept the command used '/' with drive + * name such as c:/xxx/command.exe when use '|' pipe handling. + */ + testprg = strdup(testprog); + for (i = 0; testprg[i] != '\0'; i++) { + if (testprg[i] == '/') + testprg[i] = '\\'; + } + testprog = testprg; +#endif /* * Create a temp directory for the following tests. diff --git a/usr.bin/tar/test/test.h b/usr.bin/tar/test/test.h index ab568c2..27a6935 100644 --- a/usr.bin/tar/test/test.h +++ b/usr.bin/tar/test/test.h @@ -45,7 +45,13 @@ #error Oops: No config.h and no pre-built configuration in test.h. #endif +#ifndef _WIN32 #include <dirent.h> +#else +#define dirent direct +#include "../bsdtar_windows.h" +#include <direct.h> +#endif #include <errno.h> #include <fcntl.h> #include <stdio.h> diff --git a/usr.bin/tar/test/test_0.c b/usr.bin/tar/test/test_0.c index 7a72af1..1bafc05 100644 --- a/usr.bin/tar/test/test_0.c +++ b/usr.bin/tar/test/test_0.c @@ -29,6 +29,11 @@ __FBSDID("$FreeBSD$"); * This first test does basic sanity checks on the environment. For * most of these, we just exit on failure. */ +#ifndef _WIN32 +#define DEV_NULL "/dev/null" +#else +#define DEV_NULL "NUL" +#endif DEFINE_TEST(test_0) { @@ -46,9 +51,9 @@ DEFINE_TEST(test_0) * Try to succesfully run the program; this requires that * we know some option that will succeed. */ - if (0 == systemf("%s --version >/dev/null", testprog)) { + if (0 == systemf("%s --version >" DEV_NULL, testprog)) { /* This worked. */ - } else if (0 == systemf("%s -W version >/dev/null", testprog)) { + } else if (0 == systemf("%s -W version >" DEV_NULL, testprog)) { /* This worked. */ } else { failure("Unable to successfully run any of the following:\n" diff --git a/usr.bin/tar/test/test_basic.c b/usr.bin/tar/test/test_basic.c index 50be289..b454723 100644 --- a/usr.bin/tar/test/test_basic.c +++ b/usr.bin/tar/test/test_basic.c @@ -27,16 +27,23 @@ __FBSDID("$FreeBSD$"); static void -basic_tar(const char *target, const char *pack_options, const char *unpack_options) +basic_tar(const char *target, const char *pack_options, + const char *unpack_options, const char *flist) { struct stat st, st2; +#ifndef _WIN32 char buff[128]; +#endif int r; assertEqualInt(0, mkdir(target, 0775)); /* Use the tar program to create an archive. */ - r = systemf("%s cf - %s `cat filelist` >%s/archive 2>%s/pack.err", testprog, pack_options, target, target); +#ifndef _WIN32 + r = systemf("%s cf - %s `cat %s` >%s/archive 2>%s/pack.err", testprog, pack_options, flist, target, target); +#else + r = systemf("%s cf - %s %s >%s/archive 2>%s/pack.err", testprog, pack_options, flist, target, target); +#endif failure("Error invoking %s cf -", testprog, pack_options); assertEqualInt(r, 0); @@ -65,7 +72,11 @@ basic_tar(const char *target, const char *pack_options, const char *unpack_optio assertEqualInt(r, 0); if (r == 0) { assert(S_ISREG(st.st_mode)); +#ifndef _WIN32 assertEqualInt(0644, st.st_mode & 0777); +#else + assertEqualInt(0600, st.st_mode & 0700); +#endif assertEqualInt(10, st.st_size); failure("file %s/file", target); assertEqualInt(2, st.st_nlink); @@ -77,7 +88,11 @@ basic_tar(const char *target, const char *pack_options, const char *unpack_optio assertEqualInt(r, 0); if (r == 0) { assert(S_ISREG(st2.st_mode)); +#ifndef _WIN32 assertEqualInt(0644, st2.st_mode & 0777); +#else + assertEqualInt(0600, st2.st_mode & 0700); +#endif assertEqualInt(10, st2.st_size); failure("file %s/linkfile", target); assertEqualInt(2, st2.st_nlink); @@ -87,6 +102,7 @@ basic_tar(const char *target, const char *pack_options, const char *unpack_optio assertEqualInt(st.st_ino, st2.st_ino); } +#ifndef _WIN32 /* Symlink */ r = lstat("symlink", &st); failure("Failed to stat file %s/symlink, errno=%d", target, errno); @@ -102,13 +118,18 @@ basic_tar(const char *target, const char *pack_options, const char *unpack_optio assertEqualString(buff, "file"); } } +#endif /* dir */ r = lstat("dir", &st); if (r == 0) { assertEqualInt(r, 0); assert(S_ISDIR(st.st_mode)); +#ifndef _WIN32 assertEqualInt(0775, st.st_mode & 0777); +#else + assertEqualInt(0700, st.st_mode & 0700); +#endif } chdir(".."); @@ -119,6 +140,7 @@ DEFINE_TEST(test_basic) int fd; int filelist; int oldumask; + const char *flist; oldumask = umask(0); @@ -148,11 +170,16 @@ DEFINE_TEST(test_basic) /* All done. */ close(filelist); +#ifndef _WIN32 + flist = "filelist"; +#else + flist = "file linkfile symlink dir"; +#endif /* Archive/dearchive with a variety of options. */ - basic_tar("copy", "", ""); + basic_tar("copy", "", "", flist); /* tar doesn't handle cpio symlinks correctly */ /* basic_tar("copy_odc", "--format=odc", ""); */ - basic_tar("copy_ustar", "--format=ustar", ""); + basic_tar("copy_ustar", "--format=ustar", "", flist); umask(oldumask); } diff --git a/usr.bin/tar/test/test_copy.c b/usr.bin/tar/test/test_copy.c index 7f12f9c..9aff916 100644 --- a/usr.bin/tar/test/test_copy.c +++ b/usr.bin/tar/test/test_copy.c @@ -64,6 +64,7 @@ create_tree(void) buff2[0] = 'm'; assertEqualInt(0, link(buff, buff2)); +#ifndef _WIN32 /* Create a symlink named "s/abcdef..." to the above. */ strcpy(buff2 + 3, buff); buff[0] = 's'; @@ -71,7 +72,9 @@ create_tree(void) buff2[1] = '.'; buff2[2] = '/'; assertEqualInt(0, symlink(buff2, buff)); - +#else + skipping("create a symlink to the above"); +#endif /* Create a dir named "d/abcdef...". */ buff[0] = 'd'; assertEqualInt(0, mkdir(buff, 0775)); @@ -153,6 +156,7 @@ verify_tree(int limit) } } +#ifndef _WIN32 /* * Symlink text doesn't include the 'original/' prefix, * so the limit here is 100 characters. @@ -174,7 +178,9 @@ verify_tree(int limit) } } } - +#else + skipping("verify symlink"); +#endif /* Verify dir "d/abcdef...". */ strcpy(name1, "d/"); strcat(name1, filename); diff --git a/usr.bin/tar/test/test_option_T.c b/usr.bin/tar/test/test_option_T.c index 493dcc1..9f4a2b3 100644 --- a/usr.bin/tar/test/test_option_T.c +++ b/usr.bin/tar/test/test_option_T.c @@ -41,6 +41,7 @@ DEFINE_TEST(test_option_T) { FILE *f; int r; + struct stat st; /* Create a simple dir heirarchy; bail if anything fails. */ if (!assertEqualInt(0, mkdir("d1", 0755))) return; @@ -127,19 +128,26 @@ DEFINE_TEST(test_option_T) assertEqualInt(0, mkdir("test4/d1", 0755)); assertEqualInt(1, touch("test4/d1/foo")); - systemf("%s -cf - -s /foo/bar/ test4/d1/foo | %s -xf - -C test4_out", - testprog, testprog); - assertEmptyFile("test4_out/test4/d1/bar"); - systemf("%s -cf - -s /d1/d2/ test4/d1/foo | %s -xf - -C test4_out", - testprog, testprog); - assertEmptyFile("test4_out/test4/d2/foo"); - systemf("%s -cf - -s ,test4/d1/foo,, test4/d1/foo | %s -tvf - > test4.lst", - testprog, testprog); - assertEmptyFile("test4.lst"); - systemf("%s -cf - test4/d1/foo | %s -xf - -s /foo/bar/ -C test4_out2", - testprog, testprog); - assertEmptyFile("test4_out2/test4/d1/bar"); - + /* Does bsdtar support -s option ? */ + systemf("%s -cf - -s /foo/bar/ test4/d1/foo > NUL 2> check.err", + testprog); + assertEqualInt(0, stat("check.err", &st)); + if (st.st_size == 0) { + systemf("%s -cf - -s /foo/bar/ test4/d1/foo | %s -xf - -C test4_out", + testprog, testprog); + assertEmptyFile("test4_out/test4/d1/bar"); + systemf("%s -cf - -s /d1/d2/ test4/d1/foo | %s -xf - -C test4_out", + testprog, testprog); + assertEmptyFile("test4_out/test4/d2/foo"); + systemf("%s -cf - -s ,test4/d1/foo,, test4/d1/foo | %s -tvf - > test4.lst", + testprog, testprog); + assertEmptyFile("test4.lst"); + systemf("%s -cf - test4/d1/foo | %s -xf - -s /foo/bar/ -C test4_out2", + testprog, testprog); + assertEmptyFile("test4_out2/test4/d1/bar"); + } else { + skipping("bsdtar does not support -s option on this platform"); + } /* TODO: Include some use of -C directory-changing within the filelist. */ /* I'm pretty sure -C within the filelist is broken on extract. */ } diff --git a/usr.bin/tar/test/test_option_s.c b/usr.bin/tar/test/test_option_s.c index b256e2a..1059066 100644 --- a/usr.bin/tar/test/test_option_s.c +++ b/usr.bin/tar/test/test_option_s.c @@ -42,12 +42,23 @@ mkfile(const char *fn, const char *contents) DEFINE_TEST(test_option_s) { + struct stat st; + /* Create a sample file heirarchy. */ assertEqualInt(0, mkdir("in", 0755)); assertEqualInt(0, mkdir("in/d1", 0755)); assertEqualInt(0, mkfile("in/d1/foo", "foo")); assertEqualInt(0, mkfile("in/d1/bar", "bar")); + /* Does bsdtar support -s option ? */ + systemf("%s -cf - -s /foo/bar/ in/d1/foo > NUL 2> check.err", + testprog); + assertEqualInt(0, stat("check.err", &st)); + if (st.st_size != 0) { + skipping("bsdtar does not support -s option on this platform"); + return; + } + /* * Test 1: Filename substitution when creating archives. */ diff --git a/usr.bin/tar/test/test_patterns.c b/usr.bin/tar/test/test_patterns.c index 281133a..36d4542 100644 --- a/usr.bin/tar/test/test_patterns.c +++ b/usr.bin/tar/test/test_patterns.c @@ -28,8 +28,8 @@ __FBSDID("$FreeBSD$"); DEFINE_TEST(test_patterns) { int fd, r; - const char *reffile2 = "test_patterns_2.tgz"; - const char *reffile3 = "test_patterns_3.tgz"; + const char *reffile2 = "test_patterns_2.tar"; + const char *reffile3 = "test_patterns_3.tar"; const char *p; /* @@ -45,9 +45,9 @@ DEFINE_TEST(test_patterns) fd = open("foo", O_CREAT | O_WRONLY, 0644); assert(fd >= 0); close(fd); - r = systemf("%s zcfv tar1.tgz foo > tar1a.out 2> tar1a.err", testprog); + r = systemf("%s cfv tar1.tgz foo > tar1a.out 2> tar1a.err", testprog); assertEqualInt(r, 0); - r = systemf("%s zxfv tar1.tgz foo bar > tar1b.out 2> tar1b.err", testprog); + r = systemf("%s xfv tar1.tgz foo bar > tar1b.out 2> tar1b.err", testprog); failure("tar should return non-zero because a file was given on the command line that's not in the archive"); assert(r != 0); @@ -59,7 +59,11 @@ DEFINE_TEST(test_patterns) r = systemf("%s tf %s /tmp/foo/bar > tar2a.out 2> tar2a.err", testprog, reffile2); assertEqualInt(r, 0); +#ifndef _WIN32 p = "/tmp/foo/bar/\n/tmp/foo/bar/baz\n"; +#else + p = "/tmp/foo/bar/\r\n/tmp/foo/bar/baz\r\n"; +#endif assertFileContents(p, strlen(p), "tar2a.out"); assertEmptyFile("tar2a.err"); diff --git a/usr.bin/tar/test/test_patterns_2.tar.uu b/usr.bin/tar/test/test_patterns_2.tar.uu new file mode 100644 index 0000000..1ed9a7d --- /dev/null +++ b/usr.bin/tar/test/test_patterns_2.tar.uu @@ -0,0 +1,232 @@ +$FreeBSD$ +begin 644 test_patterns_2.tar +M+W1M<"]F;V\O```````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````#`P,#<U-2``,#`Q-S4P(``P,#`P,#`@`#`P,#`P,#`P,#`P +M(#$Q,#4Q,C$R-C4V(#`Q,C0T,0`@-0`````````````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````!U<W1A<@`P,'1I;0`` +M````````````````````````````````````=VAE96P````````````````` +M```````````````````P,#`P,#`@`#`P,#`P,"`````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````O=&UP+V9O;R]B87(O```````````````````` +M```````````````````````````````````````````````````````````` +M````````````````````````````````````,#`P-S4U(``P,#$W-3`@`#`P +M,#`P,"``,#`P,#`P,#`P,#`@,3$P-3$R,3(V-3,@,#$S,C`R`"`U```````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M`````'5S=&%R`#`P=&EM``````````````````````````````````````!W +M:&5E;````````````````````````````````````#`P,#`P,"``,#`P,#`P +M(``````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````````````````````````````````````"]T;7`O9F]O+V)A +M>@`````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````P +M,#`V-#0@`#`P,3<U,"``,#`P,#`P(``P,#`P,#`P,#`P,"`Q,3`U,3(Q,C8U +M-B`P,3,Q,C8`(#`````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M````````````````````````````=7-T87(`,#!T:6T````````````````` +M`````````````````````'=H965L```````````````````````````````` +M````,#`P,#`P(``P,#`P,#`@```````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M````````+W1M<"]F;V\O8F%R+V)A>@`````````````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````````````#`P,#8T-"``,#`Q-S4P(``P,#`P,#`@`#`P,#`P +M,#`P,#`P(#$Q,#4Q,C$R-C4S(#`Q,S8V-P`@,``````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````````````!U<W1A<@`P +M,'1I;0``````````````````````````````````````=VAE96P````````` +M```````````````````````````P,#`P,#`@`#`P,#`P,"`````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +9```````````````````````````````````` +` +end diff --git a/usr.bin/tar/test/test_patterns_2.tgz.uu b/usr.bin/tar/test/test_patterns_2.tgz.uu deleted file mode 100644 index 0f9c715..0000000 --- a/usr.bin/tar/test/test_patterns_2.tgz.uu +++ /dev/null @@ -1,9 +0,0 @@ -$FreeBSD$ -begin 644 test_patterns_2.tgz -M'XL(`,P5I4@``^W3T0J",!3&<1]E;[!SYC:?Q\`H2`PS@IZ^F5AV(PFMJ__O -MYB@;>.:W8X?V;/==9XM\1*0*P:2J59"QCN8ZO:A*4*<NAFA$G?=:F)"QIY?K -M9:C[U,IP;%?WW0Y-<UI9_SR4^6F/&=DY_UW=Y[H#V_(O4_ZE$T?^_[#(_Y[K -M&^E_1.^WS'^9'@HCN1I:(O_W_&>Z`]OR?\Y_C!7Y`P``````````````?.,! -(*>E$>P`H```` -` -end diff --git a/usr.bin/tar/test/test_patterns_3.tar.uu b/usr.bin/tar/test/test_patterns_3.tar.uu new file mode 100644 index 0000000..e8d487e --- /dev/null +++ b/usr.bin/tar/test/test_patterns_3.tar.uu @@ -0,0 +1,232 @@ +$FreeBSD$ +begin 644 test_patterns_3.tar +M+W1M<"]F;V\O8F%R+P`````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````#`P,#<U-2``,#`Q-S4P(``P,#`P,#`@`#`P,#`P,#`P,#`P +M(#$Q,#4S,C`W-34R(#`Q,S(P-@`@-0`````````````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````!U<W1A<@`P,'1I;0`` +M````````````````````````````````````=VAE96P````````````````` +M```````````````````P,#`P,#`@`#`P,#`P,"`````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````O=&UP+V9O;R]B87(O8F%Z+P`````````````` +M```````````````````````````````````````````````````````````` +M````````````````````````````````````,#`P-S4U(``P,#$W-3`@`#`P +M,#`P,"``,#`P,#`P,#`P,#`@,3$P-3,R,#<U-3(@,#$S-S8R`"`U```````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M`````'5S=&%R`#`P=&EM``````````````````````````````````````!W +M:&5E;````````````````````````````````````#`P,#`P,"``,#`P,#`P +M(``````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````````````````````````````````````'1M<"]F;V\O8F%Z +M+P`````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````P +M,#`W-34@`#`P,3<U,"``,#`P,#`P(``P,#`P,#`P,#`P,"`Q,3`U,S(P-S4V +M,"`P,3,Q,S8`(#4````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M````````````````````````````=7-T87(`,#!T:6T````````````````` +M`````````````````````'=H965L```````````````````````````````` +M````,#`P,#`P(``P,#`P,#`@```````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M````````=&UP+V9O;R]B87HO8F%R+P`````````````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````````````#`P,#<U-2``,#`Q-S4P(``P,#`P,#`@`#`P,#`P +M,#`P,#`P(#$Q,#4S,C`W-38P(#`Q,S<P,@`@-0`````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````````````!U<W1A<@`P +M,'1I;0``````````````````````````````````````=VAE96P````````` +M```````````````````````````P,#`P,#`@`#`P,#`P,"`````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +M```````````````````````````````````````````````````````````` +9```````````````````````````````````` +` +end diff --git a/usr.bin/tar/test/test_patterns_3.tgz.uu b/usr.bin/tar/test/test_patterns_3.tgz.uu deleted file mode 100644 index f85afc0..0000000 --- a/usr.bin/tar/test/test_patterns_3.tgz.uu +++ /dev/null @@ -1,8 +0,0 @@ -$FreeBSD$ -begin 644 test_patterns_3.tgz -M'XL(`)P/K4@``^W5T0K"(!3&\3V*;^#1H3Z/@T5!8[&,H*=O%J/M9M3(7?U_ -M-T?1BR.?HD[=11_Z7C=QT%49(A*<4V,UP4FNV53?$V/$U3;OLTK,./*5<H7Z -M6;A=4QS&5M*I6]UW/[;M>65]>2CUUQX+TO/\F_@H<0<VY!^\)?\]?.(O$OW+ -K3_E[R?F;FO>_BWG^I;Z`#?D'X?T#``````````````!\Y0FE&!YR`"@````` -` -end diff --git a/usr.bin/tar/test/test_strip_components.c b/usr.bin/tar/test/test_strip_components.c index 0f98dfc..6fc4b30 100644 --- a/usr.bin/tar/test/test_strip_components.c +++ b/usr.bin/tar/test/test_strip_components.c @@ -64,7 +64,11 @@ DEFINE_TEST(test_strip_components) failure("d0/d1/ is too short and should not get restored"); assertEqualInt(-1, lstat("target/d1", &st)); failure("d0/d1/s2 is a symlink to something that won't be extracted"); +#ifndef _WIN32 assertEqualInt(-1, stat("target/s2", &st)); +#else + skipping("symlink with stat()"); +#endif assertEqualInt(0, lstat("target/s2", &st)); failure("d0/d1/d2 should be extracted"); assertEqualInt(0, lstat("target/d2", &st)); diff --git a/usr.bin/tar/test/test_symlink_dir.c b/usr.bin/tar/test/test_symlink_dir.c index e256c94..d5c493d 100644 --- a/usr.bin/tar/test/test_symlink_dir.c +++ b/usr.bin/tar/test/test_symlink_dir.c @@ -47,7 +47,10 @@ mkfile(const char *name, int mode, const char *contents, ssize_t size) DEFINE_TEST(test_symlink_dir) { - struct stat st, st2; + struct stat st; +#ifndef _WIN32 + struct stat st2; +#endif int oldumask; oldumask = umask(0); @@ -75,18 +78,25 @@ DEFINE_TEST(test_symlink_dir) assertEqualInt(0, mkdir("dest1", 0755)); /* "dir" is a symlink to an existing "real_dir" */ assertEqualInt(0, mkdir("dest1/real_dir", 0755)); +#ifndef _WIN32 assertEqualInt(0, symlink("real_dir", "dest1/dir")); /* "dir2" is a symlink to a non-existing "real_dir2" */ assertEqualInt(0, symlink("real_dir2", "dest1/dir2")); +#else + skipping("symlink does not work on this platform"); +#endif /* "dir3" is a symlink to an existing "non_dir3" */ assertEqualInt(0, mkfile("dest1/non_dir3", 0755, "abcdef", 6)); assertEqualInt(0, symlink("non_dir3", "dest1/dir3")); /* "file" is a symlink to existing "real_file" */ assertEqualInt(0, mkfile("dest1/real_file", 0755, "abcdefg", 7)); assertEqualInt(0, symlink("real_file", "dest1/file")); +#ifndef _WIN32 /* "file2" is a symlink to non-existing "real_file2" */ assertEqualInt(0, symlink("real_file2", "dest1/file2")); - +#else + skipping("symlink does not work on this platform"); +#endif assertEqualInt(0, systemf("%s -xf test.tar -C dest1", testprog)); /* dest1/dir symlink should be removed */ @@ -116,23 +126,31 @@ DEFINE_TEST(test_symlink_dir) assertEqualInt(0, mkdir("dest2", 0755)); /* "dir" is a symlink to existing "real_dir" */ assertEqualInt(0, mkdir("dest2/real_dir", 0755)); +#ifndef _WIN32 assertEqualInt(0, symlink("real_dir", "dest2/dir")); /* "dir2" is a symlink to a non-existing "real_dir2" */ assertEqualInt(0, symlink("real_dir2", "dest2/dir2")); +#else + skipping("symlink does not work on this platform"); +#endif /* "dir3" is a symlink to an existing "non_dir3" */ assertEqualInt(0, mkfile("dest2/non_dir3", 0755, "abcdefgh", 8)); assertEqualInt(0, symlink("non_dir3", "dest2/dir3")); /* "file" is a symlink to existing "real_file" */ assertEqualInt(0, mkfile("dest2/real_file", 0755, "abcdefghi", 9)); assertEqualInt(0, symlink("real_file", "dest2/file")); +#ifndef _WIN32 /* "file2" is a symlink to non-existing "real_file2" */ assertEqualInt(0, symlink("real_file2", "dest2/file2")); - +#else + skipping("symlink does not work on this platform"); +#endif assertEqualInt(0, systemf("%s -xPf test.tar -C dest2", testprog)); /* dest2/dir symlink should be followed */ assertEqualInt(0, lstat("dest2/dir", &st)); failure("tar -xP removed symlink instead of following it"); +#ifndef _WIN32 if (assert(S_ISLNK(st.st_mode))) { /* Only verify what the symlink points to if it * really is a symlink. */ @@ -146,6 +164,9 @@ DEFINE_TEST(test_symlink_dir) failure("symlink should still point to the existing directory"); assertEqualInt(st.st_ino, st2.st_ino); } +#else + skipping("symlink does not work on this platform"); +#endif /* Contents of 'dir' should be restored */ assertEqualInt(0, lstat("dest2/dir/d", &st)); assert(S_ISDIR(st.st_mode)); diff --git a/usr.bin/tar/test/test_version.c b/usr.bin/tar/test/test_version.c index 6f2f6a0..4f249a5 100644 --- a/usr.bin/tar/test/test_version.c +++ b/usr.bin/tar/test/test_version.c @@ -51,7 +51,7 @@ DEFINE_TEST(test_version) q = p = slurpfile(&s, "version.stdout"); /* Version message should start with name of program, then space. */ assert(s > 6); - failure("Version: %s", p); + failure("Version must start with 'bsdtar': ``%s''", p); assertEqualMem(q, "bsdtar ", 7); q += 7; s -= 7; /* Version number is a series of digits and periods. */ @@ -60,22 +60,22 @@ DEFINE_TEST(test_version) --s; } /* Version number terminated by space. */ - failure("Version: %s", p); + failure("No space after bsdtar version: ``%s''", p); assert(s > 1); /* Skip a single trailing a,b,c, or d. */ if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd') ++q; - failure("Version: %s", p); + failure("No space after bsdtar version: ``%s''", p); assert(*q == ' '); ++q; --s; /* Separator. */ - failure("Version: %s", p); + failure("No `-' between bsdtar and libarchive versions: ``%s''", p); assertEqualMem(q, "- ", 2); q += 2; s -= 2; /* libarchive name and version number */ - failure("Version: %s", p); + failure("Not long enough for libarchive version: ``%s''", p); assert(s > 11); - failure("Version: %s", p); + failure("Libarchive version must start with `libarchive': ``%s''", p); assertEqualMem(q, "libarchive ", 11); q += 11; s -= 11; /* Version number is a series of digits and periods. */ @@ -86,8 +86,11 @@ DEFINE_TEST(test_version) /* Skip a single trailing a,b,c, or d. */ if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd') ++q; - /* All terminated by a newline. */ + /* All terminated by end-of-line. */ assert(s >= 1); + /* Skip an optional CR character (e.g., Windows) */ + failure("Version output must end with \\n or \\r\\n"); + if (*q == '\r') { ++q; --s; } assertEqualMem(q, "\n", 1); free(p); } |