~sergei.glushchenko/percona-xtrabackup/xb-pprint

« back to all changes in this revision

Viewing changes to src/libarchive/libarchive/test/test_compat_cpio.c

merge parallel compression branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-
 
2
 * Copyright (c) 2003-2009 Tim Kientzle
 
3
 * All rights reserved.
 
4
 *
 
5
 * Redistribution and use in source and binary forms, with or without
 
6
 * modification, are permitted provided that the following conditions
 
7
 * are met:
 
8
 * 1. Redistributions of source code must retain the above copyright
 
9
 *    notice, this list of conditions and the following disclaimer.
 
10
 * 2. Redistributions in binary form must reproduce the above copyright
 
11
 *    notice, this list of conditions and the following disclaimer in the
 
12
 *    documentation and/or other materials provided with the distribution.
 
13
 *
 
14
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
 
15
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 
16
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 
17
 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
 
18
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 
19
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
20
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
21
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 
23
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
24
 */
 
25
#include "test.h"
 
26
__FBSDID("$FreeBSD: head/lib/libarchive/test/test_compat_cpio.c 201247 2009-12-30 05:59:21Z kientzle $");
 
27
 
 
28
/*
 
29
 * Verify our ability to read various sample files.
 
30
 * It should be easy to add any new sample files sent in by users
 
31
 * to this collection of tests.
 
32
 */
 
33
 
 
34
/* Copy this function for each test file and adjust it accordingly. */
 
35
 
 
36
/*
 
37
 * test_compat_cpio_1.cpio checks heuristics for avoiding false
 
38
 * hardlinks.  foo1 and foo2 are files that have nlinks=1 and so
 
39
 * should not be marked as hardlinks even though they have identical
 
40
 * ino values.  bar1 and bar2 have nlinks=2 so should be marked
 
41
 * as hardlinks.
 
42
 */
 
43
static void
 
44
test_compat_cpio_1(void)
 
45
{
 
46
        char name[] = "test_compat_cpio_1.cpio";
 
47
        struct archive_entry *ae;
 
48
        struct archive *a;
 
49
 
 
50
        assert((a = archive_read_new()) != NULL);
 
51
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
 
52
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
 
53
        extract_reference_file(name);
 
54
        assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 17));
 
55
 
 
56
        /* Read first entry. */
 
57
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
 
58
        assertEqualString("foo1", archive_entry_pathname(ae));
 
59
        assertEqualString(NULL, archive_entry_hardlink(ae));
 
60
        assertEqualInt(1260250228, archive_entry_mtime(ae));
 
61
        assertEqualInt(1000, archive_entry_uid(ae));
 
62
        assertEqualInt(1000, archive_entry_gid(ae));
 
63
        assertEqualInt(0100644, archive_entry_mode(ae));
 
64
 
 
65
        /* Read second entry. */
 
66
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
 
67
        assertEqualString("foo2", archive_entry_pathname(ae));
 
68
        assertEqualString(NULL, archive_entry_hardlink(ae));
 
69
        assertEqualInt(1260250228, archive_entry_mtime(ae));
 
70
        assertEqualInt(1000, archive_entry_uid(ae));
 
71
        assertEqualInt(1000, archive_entry_gid(ae));
 
72
        assertEqualInt(0100644, archive_entry_mode(ae));
 
73
 
 
74
        /* Read third entry. */
 
75
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
 
76
        assertEqualString("bar1", archive_entry_pathname(ae));
 
77
        assertEqualString(NULL, archive_entry_hardlink(ae));
 
78
        assertEqualInt(1260250228, archive_entry_mtime(ae));
 
79
        assertEqualInt(1000, archive_entry_uid(ae));
 
80
        assertEqualInt(1000, archive_entry_gid(ae));
 
81
        assertEqualInt(0100644, archive_entry_mode(ae));
 
82
 
 
83
        /* Read fourth entry. */
 
84
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
 
85
        assertEqualString("bar2", archive_entry_pathname(ae));
 
86
        assertEqualString("bar1", archive_entry_hardlink(ae));
 
87
        assertEqualInt(1260250228, archive_entry_mtime(ae));
 
88
        assertEqualInt(1000, archive_entry_uid(ae));
 
89
        assertEqualInt(1000, archive_entry_gid(ae));
 
90
        assertEqualInt(0100644, archive_entry_mode(ae));
 
91
 
 
92
        /* Verify that the format detection worked. */
 
93
        assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE);
 
94
        assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
 
95
 
 
96
        assertEqualInt(ARCHIVE_OK, archive_read_close(a));
 
97
        assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
 
98
}
 
99
 
 
100
 
 
101
DEFINE_TEST(test_compat_cpio)
 
102
{
 
103
        test_compat_cpio_1();
 
104
}
 
105
 
 
106