static void run_tar(const char *target, const char *pack_options, const char *unpack_options, const char *flist) { int r; assertMakeDir(target, 0775); /* Use the tar program to create an archive. */ r = systemf("%s cf - %s %s >%s/archive 2>%s/pack.err", testprog, pack_options, flist, target, target); failure("Error invoking %s cf -", testprog, pack_options); assertEqualInt(r, 0); assertChdir(target); /* Verify that nothing went to stderr. */ assertEmptyFile("pack.err"); /* * Use tar to unpack the archive into another directory. */ r = systemf("%s xf archive %s >unpack.out 2>unpack.err", testprog, unpack_options); failure("Error invoking %s xf archive %s", testprog, unpack_options); assertEqualInt(r, 0); /* Verify that nothing went to stderr. */ assertEmptyFile("unpack.err"); assertChdir(".."); }
static void basic_tar(const char *target, const char *pack_options, const char *unpack_options, const char *flist) { int r; assertMakeDir(target, 0775); /* Use the tar program to create an archive. */ r = systemf("%s cf - %s %s >%s/archive 2>%s/pack.err", testprog, pack_options, flist, target, target); failure("Error invoking %s cf -", testprog, pack_options); assertEqualInt(r, 0); assertChdir(target); /* Verify that nothing went to stderr. */ assertEmptyFile("pack.err"); /* * Use tar to unpack the archive into another directory. */ r = systemf("%s xf archive %s >unpack.out 2>unpack.err", testprog, unpack_options); failure("Error invoking %s xf archive %s", testprog, unpack_options); assertEqualInt(r, 0); /* Verify that nothing went to stderr. */ assertEmptyFile("unpack.err"); /* * Verify unpacked files. */ /* Regular file with 2 links. */ assertIsReg("file", -1); assertFileSize("file", 10); failure("%s", target); assertFileNLinks("file", 2); /* Another name for the same file. */ assertIsReg("linkfile", -1); assertFileSize("linkfile", 10); assertFileNLinks("linkfile", 2); assertIsHardlink("file", "linkfile"); /* Symlink */ if (canSymlink()) assertIsSymlink("symlink", "file"); /* dir */ assertIsDir("dir", 0775); assertChdir(".."); }
static void copy_ustar(void) { const char *target = "ustar"; int r; /* NOTE: for proper operation on cygwin-1.5 and windows, the * length of the name of the directory below, "ustar", must be * less than or equal to the lengthe of the name of the original * directory, "original" This restriction derives from the * extremely limited pathname lengths on those platforms. */ assertMakeDir(target, 0775); assertEqualInt(0, chdir(target)); /* * Use the tar program to create an archive. */ r = systemf("%s cf archive --format=ustar -C ../original f d l m s >pack.out 2>pack.err", testprog); failure("Error invoking \"%s cf archive --format=ustar\"", testprog); assertEqualInt(r, 0); /* Verify that nothing went to stdout. */ assertEmptyFile("pack.out"); /* Stderr is non-empty, since there are a bunch of files * with filenames too long to archive. */ /* * Use tar to unpack the archive into another directory. */ r = systemf("%s xf archive >unpack.out 2>unpack.err", testprog); failure("Error invoking %s xf archive", testprog); assertEqualInt(r, 0); /* Verify that nothing went to stdout or stderr. */ assertEmptyFile("unpack.err"); assertEmptyFile("unpack.out"); verify_tree(LIMIT_USTAR); assertEqualInt(0, chdir("../..")); }
static void copy_basic(void) { int r; /* NOTE: for proper operation on cygwin-1.5 and windows, the * length of the name of the directory below, "plain", must be * less than or equal to the lengthe of the name of the original * directory, "original" This restriction derives from the * extremely limited pathname lengths on those platforms. */ assertMakeDir("plain", 0775); assertEqualInt(0, chdir("plain")); /* * Use the tar program to create an archive. */ r = systemf("%s cf archive -C ../original f d l m s >pack.out 2>pack.err", testprog); failure("Error invoking \"%s cf\"", testprog); assertEqualInt(r, 0); /* Verify that nothing went to stdout or stderr. */ assertEmptyFile("pack.err"); assertEmptyFile("pack.out"); /* * Use tar to unpack the archive into another directory. */ r = systemf("%s xf archive >unpack.out 2>unpack.err", testprog); failure("Error invoking %s xf archive", testprog); assertEqualInt(r, 0); /* Verify that nothing went to stdout or stderr. */ assertEmptyFile("unpack.err"); assertEmptyFile("unpack.out"); verify_tree(LIMIT_NONE); assertEqualInt(0, chdir("..")); }