xref: /freebsd/contrib/libarchive/cpio/test/test_option_l.c (revision caf54c4f6ce7f1612a528170c1aa3c3fe4f8b153)
1*caf54c4fSMartin Matuska /*-
2*caf54c4fSMartin Matuska  * Copyright (c) 2003-2007 Tim Kientzle
3*caf54c4fSMartin Matuska  * All rights reserved.
4*caf54c4fSMartin Matuska  *
5*caf54c4fSMartin Matuska  * Redistribution and use in source and binary forms, with or without
6*caf54c4fSMartin Matuska  * modification, are permitted provided that the following conditions
7*caf54c4fSMartin Matuska  * are met:
8*caf54c4fSMartin Matuska  * 1. Redistributions of source code must retain the above copyright
9*caf54c4fSMartin Matuska  *    notice, this list of conditions and the following disclaimer.
10*caf54c4fSMartin Matuska  * 2. Redistributions in binary form must reproduce the above copyright
11*caf54c4fSMartin Matuska  *    notice, this list of conditions and the following disclaimer in the
12*caf54c4fSMartin Matuska  *    documentation and/or other materials provided with the distribution.
13*caf54c4fSMartin Matuska  *
14*caf54c4fSMartin Matuska  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15*caf54c4fSMartin Matuska  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16*caf54c4fSMartin Matuska  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17*caf54c4fSMartin Matuska  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18*caf54c4fSMartin Matuska  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19*caf54c4fSMartin Matuska  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20*caf54c4fSMartin Matuska  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21*caf54c4fSMartin Matuska  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22*caf54c4fSMartin Matuska  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23*caf54c4fSMartin Matuska  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24*caf54c4fSMartin Matuska  */
25*caf54c4fSMartin Matuska #include "test.h"
26*caf54c4fSMartin Matuska __FBSDID("$FreeBSD$");
27*caf54c4fSMartin Matuska 
28*caf54c4fSMartin Matuska DEFINE_TEST(test_option_l)
29*caf54c4fSMartin Matuska {
30*caf54c4fSMartin Matuska 	int r;
31*caf54c4fSMartin Matuska 
32*caf54c4fSMartin Matuska 	/* Create a file. */
33*caf54c4fSMartin Matuska 	assertMakeFile("f", 0644, "a");
34*caf54c4fSMartin Matuska 
35*caf54c4fSMartin Matuska 	/* Copy the file to the "copy" dir. */
36*caf54c4fSMartin Matuska 	r = systemf("echo f | %s -pd copy >copy.out 2>copy.err",
37*caf54c4fSMartin Matuska 	    testprog);
38*caf54c4fSMartin Matuska 	assertEqualInt(r, 0);
39*caf54c4fSMartin Matuska 
40*caf54c4fSMartin Matuska 	/* Check that the copy is a true copy and not a link. */
41*caf54c4fSMartin Matuska 	assertIsNotHardlink("f", "copy/f");
42*caf54c4fSMartin Matuska 
43*caf54c4fSMartin Matuska 	/* Copy the file to the "link" dir with the -l option. */
44*caf54c4fSMartin Matuska 	r = systemf("echo f | %s -pld link >link.out 2>link.err",
45*caf54c4fSMartin Matuska 	    testprog);
46*caf54c4fSMartin Matuska 	assertEqualInt(r, 0);
47*caf54c4fSMartin Matuska 
48*caf54c4fSMartin Matuska 	/* Check that this is a link and not a copy. */
49*caf54c4fSMartin Matuska 	assertIsHardlink("f", "link/f");
50*caf54c4fSMartin Matuska }
51