~ubuntu-branches/ubuntu/quantal/libarchive/quantal

« back to all changes in this revision

Viewing changes to cpio/test/test_basic.c

  • Committer: Package Import Robot
  • Author(s): Andres Mejia
  • Date: 2012-02-23 19:29:24 UTC
  • mfrom: (8.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20120223192924-73n4iedok5fwgsyr
Tags: 3.0.3-5
* Detect if locales or locales-all is installed for use with test suite.
* Bump Standards-Version to 3.9.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
         */
34
34
 
35
35
        /* Regular file with 2 links. */
 
36
        failure(msg);
36
37
        assertIsReg("file", 0644);
37
38
        failure(msg);
38
39
        assertFileSize("file", 10);
 
40
        failure(msg);
39
41
        assertFileNLinks("file", 2);
40
42
 
41
43
        /* Another name for the same file. */
 
44
        failure(msg);
42
45
        assertIsHardlink("linkfile", "file");
43
46
 
44
47
        /* Symlink */
46
49
                assertIsSymlink("symlink", "file");
47
50
 
48
51
        /* Another file with 1 link and different permissions. */
 
52
        failure(msg);
49
53
        assertIsReg("file2", 0777);
 
54
        failure(msg);
50
55
        assertFileSize("file2", 10);
 
56
        failure(msg);
51
57
        assertFileNLinks("file2", 1);
52
58
 
53
59
        /* dir */
58
64
basic_cpio(const char *target,
59
65
    const char *pack_options,
60
66
    const char *unpack_options,
61
 
    const char *se)
 
67
    const char *se, const char *se2)
62
68
{
63
69
        int r;
64
70
 
87
93
 
88
94
        /* Verify stderr. */
89
95
        failure("Error invoking %s -i %s in dir %s", testprog, unpack_options, target);
90
 
        assertTextFileContents(se, "unpack.err");
 
96
        assertTextFileContents(se2, "unpack.err");
91
97
 
92
98
        verify_files(pack_options);
93
99
 
125
131
{
126
132
        FILE *filelist;
127
133
        const char *msg;
 
134
        char result[1024];
128
135
 
129
136
        assertUmask(0);
130
137
 
132
139
         * Create an assortment of files on disk.
133
140
         */
134
141
        filelist = fopen("filelist", "w");
 
142
        memset(result, 0, sizeof(result));
135
143
 
136
144
        /* File with 10 bytes content. */
137
145
        assertMakeFile("file", 0644, "1234567890");
138
146
        fprintf(filelist, "file\n");
 
147
        if (is_LargeInode("file"))
 
148
                strncat(result,
 
149
                    "bsdcpio: file: large inode number truncated: "
 
150
                    "Numerical result out of range\n",
 
151
                    sizeof(result) - strlen(result));
139
152
 
140
153
        /* hardlink to above file. */
141
154
        assertMakeHardlink("linkfile", "file");
142
155
        fprintf(filelist, "linkfile\n");
 
156
        if (is_LargeInode("linkfile"))
 
157
                strncat(result,
 
158
                    "bsdcpio: linkfile: large inode number truncated: "
 
159
                    "Numerical result out of range\n",
 
160
                    sizeof(result) - strlen(result));
143
161
 
144
162
        /* Symlink to above file. */
145
163
        if (canSymlink()) {
146
164
                assertMakeSymlink("symlink", "file");
147
165
                fprintf(filelist, "symlink\n");
 
166
                if (is_LargeInode("symlink"))
 
167
                        strncat(result,
 
168
                            "bsdcpio: symlink: large inode number truncated: "
 
169
                                "Numerical result out of range\n",
 
170
                            sizeof(result) - strlen(result));
148
171
        }
149
172
 
150
173
        /* Another file with different permissions. */
151
174
        assertMakeFile("file2", 0777, "1234567890");
152
175
        fprintf(filelist, "file2\n");
 
176
        if (is_LargeInode("file2"))
 
177
                strncat(result,
 
178
                    "bsdcpio: file2: large inode number truncated: "
 
179
                    "Numerical result out of range\n",
 
180
                    sizeof(result) - strlen(result));
153
181
 
154
182
        /* Directory. */
155
183
        assertMakeDir("dir", 0775);
156
184
        fprintf(filelist, "dir\n");
 
185
        if (is_LargeInode("dir"))
 
186
                strncat(result,
 
187
                    "bsdcpio: dir: large inode number truncated: "
 
188
                    "Numerical result out of range\n",
 
189
                    sizeof(result) - strlen(result));
 
190
        strncat(result, "2 blocks\n", sizeof(result) - strlen(result));
 
191
 
157
192
        /* All done. */
158
193
        fclose(filelist);
159
194
 
161
196
 
162
197
        /* Archive/dearchive with a variety of options. */
163
198
        msg = canSymlink() ? "2 blocks\n" : "1 block\n";
164
 
        basic_cpio("copy", "", "", msg);
165
 
        basic_cpio("copy_odc", "--format=odc", "", msg);
166
 
        basic_cpio("copy_newc", "-H newc", "", "2 blocks\n");
167
 
        basic_cpio("copy_cpio", "-H odc", "", msg);
 
199
        basic_cpio("copy", "", "", msg, msg);
 
200
        basic_cpio("copy_odc", "--format=odc", "", msg, msg);
 
201
        basic_cpio("copy_newc", "-H newc", "", result, "2 blocks\n");
 
202
        basic_cpio("copy_cpio", "-H odc", "", msg, msg);
168
203
        msg = canSymlink() ? "9 blocks\n" : "8 blocks\n";
169
 
        basic_cpio("copy_ustar", "-H ustar", "", msg);
 
204
        basic_cpio("copy_ustar", "-H ustar", "", msg, msg);
170
205
 
171
206
        /* Copy in one step using -p */
172
207
        passthrough("passthrough");