1231200Smm/*- 2231200Smm * Copyright (c) 2010 Tim Kientzle 3231200Smm * All rights reserved. 4231200Smm * 5231200Smm * Redistribution and use in source and binary forms, with or without 6231200Smm * modification, are permitted provided that the following conditions 7231200Smm * are met: 8231200Smm * 1. Redistributions of source code must retain the above copyright 9231200Smm * notice, this list of conditions and the following disclaimer. 10231200Smm * 2. Redistributions in binary form must reproduce the above copyright 11231200Smm * notice, this list of conditions and the following disclaimer in the 12231200Smm * documentation and/or other materials provided with the distribution. 13231200Smm * 14231200Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15231200Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16231200Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17231200Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18231200Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19231200Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20231200Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21231200Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22231200Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23231200Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24231200Smm */ 25231200Smm#include "test.h" 26231200Smm__FBSDID("$FreeBSD$"); 27231200Smm 28231200SmmDEFINE_TEST(test_option_n) 29231200Smm{ 30231200Smm assertMakeDir("d1", 0755); 31231200Smm assertMakeFile("d1/file1", 0644, "d1/file1"); 32231200Smm 33231200Smm /* Test 1: -c without -n */ 34231200Smm assertMakeDir("test1", 0755); 35231200Smm assertChdir("test1"); 36231200Smm assertEqualInt(0, 37231200Smm systemf("%s -cf archive.tar -C .. d1 >c.out 2>c.err", testprog)); 38231200Smm assertEmptyFile("c.out"); 39231200Smm assertEmptyFile("c.err"); 40231200Smm assertEqualInt(0, 41231200Smm systemf("%s -xf archive.tar >x.out 2>x.err", testprog)); 42231200Smm assertEmptyFile("x.out"); 43231200Smm assertEmptyFile("x.err"); 44231200Smm assertFileContents("d1/file1", 8, "d1/file1"); 45231200Smm assertChdir(".."); 46231200Smm 47231200Smm /* Test 2: -c with -n */ 48231200Smm assertMakeDir("test2", 0755); 49231200Smm assertChdir("test2"); 50231200Smm assertEqualInt(0, 51231200Smm systemf("%s -cnf archive.tar -C .. d1 >c.out 2>c.err", testprog)); 52231200Smm assertEmptyFile("c.out"); 53231200Smm assertEmptyFile("c.err"); 54231200Smm assertEqualInt(0, 55231200Smm systemf("%s -xf archive.tar >x.out 2>x.err", testprog)); 56231200Smm assertEmptyFile("x.out"); 57231200Smm assertEmptyFile("x.err"); 58231200Smm assertIsDir("d1", 0755); 59231200Smm assertFileNotExists("d1/file1"); 60231200Smm assertChdir(".."); 61231200Smm} 62