Path: blob/main/contrib/libarchive/tar/test/test_option_O_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"78static const char *test4out[] = {"file1", "file2", NULL};9static const char *test5err[] = {"file1", "file2", NULL};1011DEFINE_TEST(test_option_O_upper)12{13assertMakeFile("file1", 0644, "file1");14assertMakeFile("file2", 0644, "file2");15assertEqualInt(0, systemf("%s -cf archive.tar file1 file2", testprog));1617/* Test 1: -x without -O */18assertMakeDir("test1", 0755);19assertChdir("test1");20assertEqualInt(0,21systemf("%s -xf ../archive.tar >test.out 2>test.err", testprog));22assertFileContents("file1", 5, "file1");23assertFileContents("file2", 5, "file2");24assertEmptyFile("test.out");25assertEmptyFile("test.err");26assertChdir("..");2728/* Test 2: -x with -O */29assertMakeDir("test2", 0755);30assertChdir("test2");31assertEqualInt(0,32systemf("%s -xOf ../archive.tar file1 >test.out 2>test.err", testprog));33assertFileNotExists("file1");34assertFileNotExists("file2");35assertFileContents("file1", 5, "test.out");36assertEmptyFile("test.err");37assertChdir("..");3839/* Test 3: -x with -O and multiple files */40assertMakeDir("test3", 0755);41assertChdir("test3");42assertEqualInt(0,43systemf("%s -xOf ../archive.tar >test.out 2>test.err", testprog));44assertFileNotExists("file1");45assertFileNotExists("file2");46assertFileContents("file1file2", 10, "test.out");47assertEmptyFile("test.err");48assertChdir("..");4950/* Test 4: -t without -O */51assertMakeDir("test4", 0755);52assertChdir("test4");53assertEqualInt(0,54systemf("%s -tf ../archive.tar >test.out 2>test.err", testprog));55assertFileContainsLinesAnyOrder("test.out", test4out);56assertEmptyFile("test.err");57assertChdir("..");5859/* Test 5: -t with -O */60assertMakeDir("test5", 0755);61assertChdir("test5");62assertEqualInt(0,63systemf("%s -tOf ../archive.tar >test.out 2>test.err", testprog));64assertEmptyFile("test.out");65assertFileContainsLinesAnyOrder("test.err", test5err);66assertChdir("..");67}686970