failure("Error invoking %s -o %s", testprog, pack_options);
assertEqualInt(r, 0);
- chdir(target);
+ assertChdir(target);
/* Verify stderr. */
failure("Expected: %s, options=%s", se, pack_options);
verify_files(target);
- chdir("..");
+ assertChdir("..");
}
static void
failure("Error invoking %s -p", testprog);
assertEqualInt(r, 0);
- chdir(target);
+ assertChdir(target);
/* Verify stderr. */
failure("Error invoking %s -p in dir %s",
assertTextFileContents("1 block\n", "stderr");
verify_files(target);
- chdir("..");
+ assertChdir("..");
}
DEFINE_TEST(test_basic)
/* Create a work dir named after the file we're unpacking. */
assertEqualInt(0, mkdir(from, 0775));
- chdir(from);
+ assertChdir(from);
/*
* Use cpio to unpack the sample archive
#endif
}
- chdir("..");
+ assertChdir("..");
}
DEFINE_TEST(test_gcpio_compat)
assertEqualInt(0, mkdir("unpack", 0755));
#if defined(_WIN32) && !defined(__CYGWIN__)
- assertEqualInt(0, chdir("unpack"));
+ assertChdir("unpack");
r = systemf("type ..\\archive.out | %s -i >unpack.out 2>unpack.err", testprog);
- assertEqualInt(0, chdir(".."));
+ assertChdir("..");
#else
r = systemf("cat archive.out | (cd unpack ; %s -i >unpack.out 2>unpack.err)", testprog);
#endif
assertEqualInt(0, mkdir("unpack-L", 0755));
#if defined(_WIN32) && !defined(__CYGWIN__)
- assertEqualInt(0, chdir("unpack-L"));
+ assertChdir("unpack-L");
r = systemf("type ..\\archive-L.out | %s -i >unpack-L.out 2>unpack-L.err", testprog);
- assertEqualInt(0, chdir(".."));
+ assertChdir("..");
#else
r = systemf("cat archive-L.out | (cd unpack-L ; %s -i >unpack-L.out 2>unpack-L.err)", testprog);
#endif
/* Dearchive without -d, this should fail. */
assertEqualInt(0, mkdir("without-d", 0755));
- assertEqualInt(0, chdir("without-d"));
+ assertChdir("without-d");
r = systemf("%s -i < ../archive.cpio >out 2>err", testprog);
assertEqualInt(r, 0);
assertEmptyFile("out");
assert(0 != stat("dir/file", &st));
/* Dearchive with -d, this should succeed. */
- assertEqualInt(0, chdir(".."));
+ assertChdir("..");
assertEqualInt(0, mkdir("with-d", 0755));
- assertEqualInt(0, chdir("with-d"));
+ assertChdir("with-d");
r = systemf("%s -id < ../archive.cpio >out 2>err", testprog);
assertEqualInt(r, 0);
assertEmptyFile("out");
int r;
assertEqualInt(0, mkdir(dirname, 0755));
- assertEqualInt(0, chdir(dirname));
+ assertChdir(dirname);
extract_reference_file("test_option_f.cpio");
r = systemf("%s -i %s < test_option_f.cpio > copy-no-a.out 2>copy-no-a.err", testprog, option);
assertEqualInt(0, r);
- assertEqualInt(0, chdir(".."));
+ assertChdir("..");
}
DEFINE_TEST(test_option_f)
/* Restored without -m, the result should have a current mtime. */
assertEqualInt(0, mkdir("without-m", 0755));
- assertEqualInt(0, chdir("without-m"));
+ assertChdir("without-m");
extract_reference_file("test_option_m.cpio");
r = systemf("%s --no-preserve-owner -i < test_option_m.cpio >out 2>err", testprog);
now = time(NULL);
assert(st.st_mtime > now - 5);
/* With -m, it should have an mtime in 1970. */
- assertEqualInt(0, chdir(".."));
+ assertChdir("..");
assertEqualInt(0, mkdir("with-m", 0755));
- assertEqualInt(0, chdir("with-m"));
+ assertChdir("with-m");
extract_reference_file("test_option_m.cpio");
r = systemf("%s --no-preserve-owner -im < test_option_m.cpio >out 2>err", testprog);
now = time(NULL);
/* Directory. */
assertEqualInt(0, mkdir("dir", 0755));
- assertEqualInt(0, chdir("dir"));
+ assertChdir("dir");
write(filelist, ".\n", 2);
failure("Error invoking %s -pd ..", testprog);
assertEqualInt(r, 0);
- assertEqualInt(0, chdir(".."));
+ assertChdir("..");
/* Verify stderr and stdout. */
assertTextFileContents("../.\n../file\n1 block\n", "stderr");
failure("Error invoking %s -pd out", testprog);
assertEqualInt(r, 0);
- assertEqualInt(0, chdir("out"));
+ assertChdir("out");
/* Verify stderr and stdout. */
assertTextFileContents("out/dir/file\nout/dir\n1 block\n",