Path: blob/main/contrib/libarchive/tar/test/test_option_H_upper.c
39507 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2010 Tim Kientzle4* All rights reserved.5*/6#include "test.h"78DEFINE_TEST(test_option_H_upper)9{1011if (!canSymlink()) {12skipping("Can't test symlinks on this filesystem");13return;14}1516/*17* Create a sample archive.18*/19assertMakeDir("in", 0755);20assertChdir("in");21assertMakeDir("d1", 0755);22assertMakeSymlink("ld1", "d1", 1);23assertMakeFile("d1/file1", 0644, "d1/file1");24assertMakeFile("d1/file2", 0644, "d1/file2");25assertMakeSymlink("d1/link1", "file1", 0);26assertMakeSymlink("d1/linkX", "fileX", 0);27assertMakeSymlink("link2", "d1/file2", 0);28assertMakeSymlink("linkY", "d1/fileY", 0);29assertChdir("..");3031/* Test 1: Without -H */32assertMakeDir("test1", 0755);33assertEqualInt(0,34systemf("%s -cf test1/archive.tar -C in . >test1/c.out 2>test1/c.err", testprog));35assertChdir("test1");36assertEqualInt(0,37systemf("%s -xf archive.tar >c.out 2>c.err", testprog));38assertIsSymlink("ld1", "d1", 1);39assertIsSymlink("d1/link1", "file1", 0);40assertIsSymlink("d1/linkX", "fileX", 0);41assertIsSymlink("link2", "d1/file2", 0);42assertIsSymlink("linkY", "d1/fileY", 0);43assertChdir("..");4445/* Test 2: With -H, no symlink on command line. */46assertMakeDir("test2", 0755);47assertEqualInt(0,48systemf("%s -cf test2/archive.tar -H -C in . >test2/c.out 2>test2/c.err", testprog));49assertChdir("test2");50assertEqualInt(0,51systemf("%s -xf archive.tar >c.out 2>c.err", testprog));52assertIsSymlink("ld1", "d1", 1);53assertIsSymlink("d1/link1", "file1", 0);54assertIsSymlink("d1/linkX", "fileX", 0);55assertIsSymlink("link2", "d1/file2", 0);56assertIsSymlink("linkY", "d1/fileY", 0);57assertChdir("..");5859/* Test 3: With -H, some symlinks on command line. */60assertMakeDir("test3", 0755);61assertEqualInt(0,62systemf("%s -cf test3/archive.tar -H -C in ld1 d1 link2 linkY >test3/c.out 2>test3/c.err", testprog));63assertChdir("test3");64assertEqualInt(0,65systemf("%s -xf archive.tar >c.out 2>c.err", testprog));66assertIsDir("ld1", umasked(0755));67assertIsSymlink("d1/linkX", "fileX", 0);68assertIsSymlink("d1/link1", "file1", 0);69assertIsReg("link2", umasked(0644));70assertIsSymlink("linkY", "d1/fileY", 0);71assertChdir("..");7273#if defined(_WIN32) && !defined(__CYGWIN__)74/* Test 4: With -H, using wildcards with some symlinks on command line. (wildcards are supported only in Windows) */75assertMakeDir("test4", 0755);76assertEqualInt(0,77systemf("%s -cf test4/archive.tar -H -C in * >test4/c.out 2>test4/c.err", testprog));78assertChdir("test4");79assertEqualInt(0,80systemf("%s -xf archive.tar >c.out 2>c.err", testprog));81assertIsDir("ld1", umasked(0755));82assertIsSymlink("d1/linkX", "fileX", 0);83assertIsSymlink("d1/link1", "file1", 0);84assertIsReg("link2", umasked(0644));85assertIsSymlink("linkY", "d1/fileY", 0);86assertChdir("..");87#endif88}899091