1238825Smm/*-
2238825Smm * Copyright (c) 2012 Michihiro NAKAJIMA
3238825Smm * All rights reserved.
4238825Smm *
5238825Smm * Redistribution and use in source and binary forms, with or without
6238825Smm * modification, are permitted provided that the following conditions
7238825Smm * are met:
8238825Smm * 1. Redistributions of source code must retain the above copyright
9238825Smm *    notice, this list of conditions and the following disclaimer.
10238825Smm * 2. Redistributions in binary form must reproduce the above copyright
11238825Smm *    notice, this list of conditions and the following disclaimer in the
12238825Smm *    documentation and/or other materials provided with the distribution.
13238825Smm *
14238825Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15238825Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16238825Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17238825Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18238825Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19238825Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20238825Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21238825Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22238825Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23238825Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24238825Smm */
25238825Smm#include "test.h"
26238825Smm__FBSDID("$FreeBSD$");
27238825Smm
28238825SmmDEFINE_TEST(test_option_nodump)
29238825Smm{
30238825Smm
31238825Smm	if (!canNodump()) {
32238825Smm		skipping("Can't test nodump on this filesystem");
33238825Smm		return;
34238825Smm	}
35238825Smm
36238825Smm	assertMakeFile("file1", 0644, "file1");
37238825Smm	assertMakeFile("file2", 0644, "file2");
38238825Smm	assertMakeFile("file3", 0644, "file3");
39238825Smm	assertNodump("file2");
40238825Smm
41238825Smm	/* Test 1: Without --nodump */
42238825Smm	assertEqualInt(0, systemf("%s -cf test1.tar file1 file2 file3",
43238825Smm	    testprog));
44238825Smm	assertMakeDir("test1", 0755);
45238825Smm	assertChdir("test1");
46238825Smm	assertEqualInt(0,
47238825Smm	    systemf("%s -xf ../test1.tar >test.out 2>test.err", testprog));
48238825Smm	assertFileContents("file1", 5, "file1");
49238825Smm	assertFileContents("file2", 5, "file2");
50238825Smm	assertFileContents("file3", 5, "file3");
51238825Smm	assertEmptyFile("test.out");
52238825Smm	assertEmptyFile("test.err");
53238825Smm	assertChdir("..");
54238825Smm
55238825Smm	/* Test 2: With --nodump */
56238825Smm	assertEqualInt(0, systemf("%s -cf test2.tar --nodump file1 file2 file3",
57238825Smm	    testprog));
58238825Smm	assertMakeDir("test2", 0755);
59238825Smm	assertChdir("test2");
60238825Smm	assertEqualInt(0,
61238825Smm	    systemf("%s -xf ../test2.tar >test.out 2>test.err", testprog));
62238825Smm	assertFileContents("file1", 5, "file1");
63238825Smm	assertFileNotExists("file2");
64238825Smm	assertFileContents("file3", 5, "file3");
65238825Smm	assertEmptyFile("test.out");
66238825Smm	assertEmptyFile("test.err");
67238825Smm	assertChdir("..");
68238825Smm}
69