From: Tim Kientzle Date: Fri, 25 Sep 2009 06:01:37 +0000 (-0400) Subject: Use mtime tests from test harness, don't rely on stat(). X-Git-Tag: v2.8.0~335 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a3d9c2aaec08864ddeadf804adb1640d086c6361;p=thirdparty%2Flibarchive.git Use mtime tests from test harness, don't rely on stat(). SVN-Revision: 1473 --- diff --git a/cpio/test/test_option_m.c b/cpio/test/test_option_m.c index e008a5940..de880b288 100644 --- a/cpio/test/test_option_m.c +++ b/cpio/test/test_option_m.c @@ -28,9 +28,7 @@ __FBSDID("$FreeBSD$"); DEFINE_TEST(test_option_m) { - struct stat st; int r; - time_t now; /* * The reference archive has one file with an mtime in 1970, 1 @@ -42,14 +40,11 @@ DEFINE_TEST(test_option_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); assertEqualInt(r, 0); assertEmptyFile("out"); assertTextFileContents("1 block\n", "err"); - assertEqualInt(0, stat("file", &st)); /* Should have been created within the last few seconds. */ - assert(st.st_mtime <= now); - assert(st.st_mtime > now - 5); + assertFileMtimeRecent("file"); /* With -m, it should have an mtime in 1970. */ assertChdir(".."); @@ -57,14 +52,12 @@ DEFINE_TEST(test_option_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); assertEqualInt(r, 0); assertEmptyFile("out"); assertTextFileContents("1 block\n", "err"); - assertEqualInt(0, stat("file", &st)); /* * mtime in reference archive is '1' == 1 second after * midnight Jan 1, 1970 UTC. */ - assertEqualInt(1, st.st_mtime); + assertFileMtime("file", 1, 0); }