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_L_upper) 29231200Smm{ 30231200Smm 31231200Smm if (!canSymlink()) { 32231200Smm skipping("Can't test symlinks on this filesystem"); 33231200Smm return; 34231200Smm } 35231200Smm 36231200Smm /* 37231200Smm * Create a sample archive. 38231200Smm */ 39231200Smm assertMakeDir("in", 0755); 40231200Smm assertChdir("in"); 41231200Smm assertMakeDir("d1", 0755); 42231200Smm assertMakeSymlink("ld1", "d1"); 43231200Smm assertMakeFile("d1/file1", 0644, "d1/file1"); 44231200Smm assertMakeFile("d1/file2", 0644, "d1/file2"); 45231200Smm assertMakeSymlink("d1/link1", "file1"); 46231200Smm assertMakeSymlink("d1/linkX", "fileX"); 47231200Smm assertMakeSymlink("link2", "d1/file2"); 48231200Smm assertMakeSymlink("linkY", "d1/fileY"); 49231200Smm assertChdir(".."); 50231200Smm 51231200Smm /* Test 1: Without -L */ 52231200Smm assertMakeDir("test1", 0755); 53231200Smm assertEqualInt(0, 54231200Smm systemf("%s -cf test1/archive.tar -C in . >test1/c.out 2>test1/c.err", testprog)); 55231200Smm assertChdir("test1"); 56231200Smm assertEqualInt(0, 57231200Smm systemf("%s -xf archive.tar >c.out 2>c.err", testprog)); 58231200Smm assertIsSymlink("ld1", "d1"); 59231200Smm assertIsSymlink("d1/link1", "file1"); 60231200Smm assertIsSymlink("d1/linkX", "fileX"); 61231200Smm assertIsSymlink("link2", "d1/file2"); 62231200Smm assertIsSymlink("linkY", "d1/fileY"); 63231200Smm assertChdir(".."); 64231200Smm 65231200Smm /* Test 2: With -L, no symlink on command line. */ 66231200Smm assertMakeDir("test2", 0755); 67231200Smm assertEqualInt(0, 68231200Smm systemf("%s -cf test2/archive.tar -L -C in . >test2/c.out 2>test2/c.err", testprog)); 69231200Smm assertChdir("test2"); 70231200Smm assertEqualInt(0, 71231200Smm systemf("%s -xf archive.tar >c.out 2>c.err", testprog)); 72231200Smm assertIsDir("ld1", 0755); 73231200Smm assertIsReg("d1/link1", 0644); 74231200Smm assertIsSymlink("d1/linkX", "fileX"); 75231200Smm assertIsReg("link2", 0644); 76231200Smm assertIsSymlink("linkY", "d1/fileY"); 77231200Smm assertChdir(".."); 78231200Smm 79231200Smm /* Test 3: With -L, some symlinks on command line. */ 80231200Smm assertMakeDir("test3", 0755); 81231200Smm assertEqualInt(0, 82231200Smm systemf("%s -cf test3/archive.tar -L -C in ld1 d1 link2 linkY >test2/c.out 2>test2/c.err", testprog)); 83231200Smm assertChdir("test3"); 84231200Smm assertEqualInt(0, 85231200Smm systemf("%s -xf archive.tar >c.out 2>c.err", testprog)); 86231200Smm assertIsDir("ld1", 0755); 87231200Smm assertIsReg("d1/link1", 0644); 88231200Smm assertIsSymlink("d1/linkX", "fileX"); 89231200Smm assertIsReg("link2", 0644); 90231200Smm assertIsSymlink("linkY", "d1/fileY"); 91231200Smm assertChdir(".."); 92231200Smm} 93