xref: /freebsd/contrib/libarchive/cpio/test/test_option_l.c (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2003-2007 Tim Kientzle
5  * All rights reserved.
6  */
7 #include "test.h"
8 
9 DEFINE_TEST(test_option_l)
10 {
11 	int r;
12 
13 	/* Create a file. */
14 	assertMakeFile("f", 0644, "a");
15 
16 	/* Copy the file to the "copy" dir. */
17 	r = systemf("echo f | %s -pd copy >copy.out 2>copy.err",
18 	    testprog);
19 	assertEqualInt(r, 0);
20 
21 	/* Check that the copy is a true copy and not a link. */
22 	assertIsNotHardlink("f", "copy/f");
23 
24 	/* Copy the file to the "link" dir with the -l option. */
25 	r = systemf("echo f | %s -pld link >link.out 2>link.err",
26 	    testprog);
27 	assertEqualInt(r, 0);
28 
29 	/* Check that this is a link and not a copy. */
30 	assertIsHardlink("f", "link/f");
31 }
32