Home | History | Annotate | Line # | Download | only in test
      1 /*-
      2  * SPDX-License-Identifier: BSD-2-Clause
      3  *
      4  * Copyright (c) 2012 Michihiro NAKAJIMA
      5  * All rights reserved.
      6  */
      7 #include "test.h"
      8 
      9 DEFINE_TEST(test_format_newc)
     10 {
     11 
     12 	assertMakeFile("file1", 0644, "file1");
     13 	assertMakeFile("file2", 0644, "file2");
     14 	assertMakeHardlink("file3", "file1");
     15 
     16 	/* Test 1: Create an archive file with a newc format. */
     17 	assertEqualInt(0,
     18 	    systemf("%s -cf test1.cpio --format newc file1 file2 file3",
     19 	    testprog));
     20 	assertMakeDir("test1", 0755);
     21 	assertChdir("test1");
     22 	assertEqualInt(0,
     23 	    systemf("%s -xf ../test1.cpio >test.out 2>test.err", testprog));
     24 	assertFileContents("file1", 5, "file1");
     25 	assertFileContents("file2", 5, "file2");
     26 	assertFileContents("file1", 5, "file3");
     27 	assertEmptyFile("test.out");
     28 	assertEmptyFile("test.err");
     29 	assertChdir("..");
     30 
     31 	/* Test 2: Exclude one of hardlinked files. */
     32 	assertEqualInt(0,
     33 	    systemf("%s -cf test2.cpio --format newc file1 file2",
     34 	    testprog));
     35 	assertMakeDir("test2", 0755);
     36 	assertChdir("test2");
     37 	assertEqualInt(0,
     38 	    systemf("%s -xf ../test2.cpio >test.out 2>test.err", testprog));
     39 	assertFileContents("file1", 5, "file1");
     40 	assertFileContents("file2", 5, "file2");
     41 	assertFileNotExists("file3");
     42 	assertEmptyFile("test.out");
     43 	assertEmptyFile("test.err");
     44 	assertChdir("..");
     45 }
     46