1238825Smm/*- 2238825Smm * Copyright (c) 2012 Michihiro NAKAJIMA 3238825Smm * All rights reserved. 4238825Smm * 5238825Smm * Redistribution and use in source and binary forms, with or without 6238825Smm * modification, are permitted provided that the following conditions 7238825Smm * are met: 8238825Smm * 1. Redistributions of source code must retain the above copyright 9238825Smm * notice, this list of conditions and the following disclaimer. 10238825Smm * 2. Redistributions in binary form must reproduce the above copyright 11238825Smm * notice, this list of conditions and the following disclaimer in the 12238825Smm * documentation and/or other materials provided with the distribution. 13238825Smm * 14238825Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15238825Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16238825Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17238825Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18238825Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19238825Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20238825Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21238825Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22238825Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23238825Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24238825Smm */ 25238825Smm#include "test.h" 26238825Smm__FBSDID("$FreeBSD$"); 27238825Smm 28238825SmmDEFINE_TEST(test_format_newc) 29238825Smm{ 30238825Smm 31238825Smm assertMakeFile("file1", 0644, "file1"); 32238825Smm assertMakeFile("file2", 0644, "file2"); 33238825Smm assertMakeHardlink("file3", "file1"); 34238825Smm 35238825Smm /* Test 1: Create an archive file with a newc format. */ 36238825Smm assertEqualInt(0, 37238825Smm systemf("%s -cf test1.cpio --format newc file1 file2 file3", 38238825Smm testprog)); 39238825Smm assertMakeDir("test1", 0755); 40238825Smm assertChdir("test1"); 41238825Smm assertEqualInt(0, 42238825Smm systemf("%s -xf ../test1.cpio >test.out 2>test.err", testprog)); 43238825Smm assertFileContents("file1", 5, "file1"); 44238825Smm assertFileContents("file2", 5, "file2"); 45238825Smm assertFileContents("file1", 5, "file3"); 46238825Smm assertEmptyFile("test.out"); 47238825Smm assertEmptyFile("test.err"); 48238825Smm assertChdir(".."); 49238825Smm 50238825Smm /* Test 2: Exclude one of hardlinked files. */ 51238825Smm assertEqualInt(0, 52238825Smm systemf("%s -cf test2.cpio --format newc file1 file2", 53238825Smm testprog)); 54238825Smm assertMakeDir("test2", 0755); 55238825Smm assertChdir("test2"); 56238825Smm assertEqualInt(0, 57238825Smm systemf("%s -xf ../test2.cpio >test.out 2>test.err", testprog)); 58238825Smm assertFileContents("file1", 5, "file1"); 59238825Smm assertFileContents("file2", 5, "file2"); 60238825Smm assertFileNotExists("file3"); 61238825Smm assertEmptyFile("test.out"); 62238825Smm assertEmptyFile("test.err"); 63238825Smm assertChdir(".."); 64238825Smm} 65