#include "test.h"
__FBSDID("$FreeBSD: src/usr.bin/tar/test/test_option_q.c,v 1.3 2008/08/22 01:35:08 kientzle Exp $");
DEFINE_TEST(test_option_q)
{
FILE *f;
int r;
f = fopen("foo", "w");
assert(f != NULL);
fprintf(f, "foo1");
fclose(f);
assertEqualInt(0, systemf("%s -cf archive.tar foo", testprog));
f = fopen("foo", "w");
assert(f != NULL);
fprintf(f, "foo2");
fclose(f);
assertEqualInt(0, systemf("%s -rf archive.tar foo", testprog));
f = fopen("bar", "w");
assert(f != NULL);
fprintf(f, "bar1");
fclose(f);
assertEqualInt(0, systemf("%s -rf archive.tar bar", testprog));
f = fopen("foo", "w");
assert(f != NULL);
fprintf(f, "foo3");
fclose(f);
assertEqualInt(0, systemf("%s -rf archive.tar foo", testprog));
f = fopen("bar", "w");
assert(f != NULL);
fprintf(f, "bar2");
fclose(f);
assertEqualInt(0, systemf("%s -rf archive.tar bar", testprog));
assertMakeDir("test1", 0755);
assertChdir("test1");
r = systemf("%s -xf ../archive.tar -q foo >test.out 2>test.err",
testprog);
failure("Fatal error trying to use -q option");
if (!assertEqualInt(0, r))
return;
assertFileContents("foo1", 4, "foo");
assertEmptyFile("test.out");
assertEmptyFile("test.err");
assertChdir("..");
assertMakeDir("test2", 0755);
assertChdir("test2");
assertEqualInt(0,
systemf("%s -xf ../archive.tar -q foo bar >test.out 2>test.err", testprog));
assertFileContents("foo2", 4, "foo");
assertFileContents("bar1", 4, "bar");
assertEmptyFile("test.out");
assertEmptyFile("test.err");
assertChdir("..");
assertMakeDir("test3", 0755);
assertChdir("test3");
assertEqualInt(0,
systemf("%s -xf ../archive.tar --fast-read foo bar >test.out 2>test.err", testprog));
assertFileContents("foo2", 4, "foo");
assertFileContents("bar1", 4, "bar");
assertEmptyFile("test.out");
assertEmptyFile("test.err");
assertChdir("..");
assertMakeDir("test4", 0755);
assertChdir("test4");
assertEqualInt(0,
systemf("%s -xf ../archive.tar foo bar >test.out 2>test.err", testprog));
assertFileContents("foo3", 4, "foo");
assertFileContents("bar2", 4, "bar");
assertEmptyFile("test.out");
assertEmptyFile("test.err");
assertChdir("..");
}