xref: /freebsd/contrib/libarchive/tar/test/test_missing_file.c (revision bd66c1b43e33540205dbc1187c2f2a15c58b57ba)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2016 Tim Kientzle
5  * All rights reserved.
6  */
7 #include "test.h"
8 
DEFINE_TEST(test_missing_file)9 DEFINE_TEST(test_missing_file)
10 {
11 	const char * invalid_stderr[] = { "INTERNAL ERROR", NULL };
12 	assertMakeFile("file1", 0644, "file1");
13 	assertMakeFile("file2", 0644, "file2");
14 	assert(0 == systemf("%s -cf archive.tar file1 file2 2>stderr1", testprog));
15 	assertEmptyFile("stderr1");
16 	assert(0 != systemf("%s -cf archive.tar file1 file2 file3 2>stderr2", testprog));
17 	assertFileContainsNoInvalidStrings("stderr2", invalid_stderr);
18 	assert(0 != systemf("%s -cf archive.tar 2>stderr3", testprog));
19 	assertFileContainsNoInvalidStrings("stderr3", invalid_stderr);
20 	assert(0 != systemf("%s -cf archive.tar file3 file4 2>stderr4", testprog));
21 	assertFileContainsNoInvalidStrings("stderr4", invalid_stderr);
22 }
23