1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2003-2007 Tim Kientzle
5 * All rights reserved.
6 */
7 #include "test.h"
8
DEFINE_TEST(test_option_m)9 DEFINE_TEST(test_option_m)
10 {
11 int r;
12
13 /*
14 * The reference archive has one file with an mtime in 1970, 1
15 * second after the start of the epoch.
16 */
17
18 /* Restored without -m, the result should have a current mtime. */
19 assertMakeDir("without-m", 0755);
20 assertChdir("without-m");
21 extract_reference_file("test_option_m.cpio");
22 r = systemf("%s --no-preserve-owner -i < test_option_m.cpio >out 2>err", testprog);
23 assertEqualInt(r, 0);
24 assertEmptyFile("out");
25 assertTextFileContents("1 block\n", "err");
26 /* Should have been created within the last few seconds. */
27 assertFileMtimeRecent("file");
28
29 /* With -m, it should have an mtime in 1970. */
30 assertChdir("..");
31 assertMakeDir("with-m", 0755);
32 assertChdir("with-m");
33 extract_reference_file("test_option_m.cpio");
34 r = systemf("%s --no-preserve-owner -im < test_option_m.cpio >out 2>err", testprog);
35 assertEqualInt(r, 0);
36 assertEmptyFile("out");
37 assertTextFileContents("1 block\n", "err");
38 /*
39 * mtime in reference archive is '1' == 1 second after
40 * midnight Jan 1, 1970 UTC.
41 */
42 assertFileMtime("file", 1, 0);
43 }
44