Merge lp:~colin-king/ecryptfs/gcov-coverage into lp:ecryptfs
- gcov-coverage
- Merge into trunk
Proposed by
Colin Ian King
Status: | Merged |
---|---|
Merged at revision: | 765 |
Proposed branch: | lp:~colin-king/ecryptfs/gcov-coverage |
Merge into: | lp:ecryptfs |
Diff against target: |
594 lines (+516/-2) 8 files modified
tests/kernel/Makefile.am (+11/-1) tests/kernel/link.sh (+83/-0) tests/kernel/mknod.sh (+64/-0) tests/kernel/mmap-bmap.sh (+58/-0) tests/kernel/mmap-bmap/test.c (+132/-0) tests/kernel/tests.rc (+1/-1) tests/kernel/xattr.sh (+56/-0) tests/kernel/xattr/test.c (+111/-0) |
To merge this branch: | bzr merge lp:~colin-king/ecryptfs/gcov-coverage |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
eCryptfs | Pending | ||
Review via email:
|
Commit message
Description of the change
I ran the current eCryptfs tests on 3.8-rc4 with kernel gcov enabled and spotted a few trivial areas where it would be useful to up the test coverage on the code. So here are a few very simple additional tests to exercise eCryptfs a little further.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'tests/kernel/Makefile.am' | |||
2 | --- tests/kernel/Makefile.am 2012-11-02 23:20:18 +0000 | |||
3 | +++ tests/kernel/Makefile.am 2013-01-25 17:05:31 +0000 | |||
4 | @@ -8,6 +8,7 @@ | |||
5 | 8 | file-concurrent.sh \ | 8 | file-concurrent.sh \ |
6 | 9 | inode-race-stat.sh \ | 9 | inode-race-stat.sh \ |
7 | 10 | inotify.sh \ | 10 | inotify.sh \ |
8 | 11 | link.sh \ | ||
9 | 11 | llseek.sh \ | 12 | llseek.sh \ |
10 | 12 | lp-1009207.sh \ | 13 | lp-1009207.sh \ |
11 | 13 | lp-469664.sh \ | 14 | lp-469664.sh \ |
12 | @@ -23,6 +24,8 @@ | |||
13 | 23 | lp-926292.sh \ | 24 | lp-926292.sh \ |
14 | 24 | lp-994247.sh \ | 25 | lp-994247.sh \ |
15 | 25 | miscdev-bad-count.sh \ | 26 | miscdev-bad-count.sh \ |
16 | 27 | mknod.sh \ | ||
17 | 28 | mmap-bmap.sh \ | ||
18 | 26 | mmap-close.sh \ | 29 | mmap-close.sh \ |
19 | 27 | mmap-dir.sh \ | 30 | mmap-dir.sh \ |
20 | 28 | read-dir.sh \ | 31 | read-dir.sh \ |
21 | @@ -42,10 +45,12 @@ | |||
22 | 42 | lp-870326/test \ | 45 | lp-870326/test \ |
23 | 43 | lp-994247/test \ | 46 | lp-994247/test \ |
24 | 44 | miscdev-bad-count/test \ | 47 | miscdev-bad-count/test \ |
25 | 48 | mmap-bmap/test \ | ||
26 | 45 | mmap-close/test \ | 49 | mmap-close/test \ |
27 | 46 | mmap-dir/test \ | 50 | mmap-dir/test \ |
28 | 47 | read-dir/test \ | 51 | read-dir/test \ |
30 | 48 | trunc-file/test | 52 | trunc-file/test \ |
31 | 53 | xattr/test | ||
32 | 49 | endif | 54 | endif |
33 | 50 | 55 | ||
34 | 51 | directory_concurrent_test_SOURCES = directory-concurrent/test.c | 56 | directory_concurrent_test_SOURCES = directory-concurrent/test.c |
35 | @@ -73,6 +78,8 @@ | |||
36 | 73 | miscdev_bad_count_test_SOURCES = miscdev-bad-count/test.c | 78 | miscdev_bad_count_test_SOURCES = miscdev-bad-count/test.c |
37 | 74 | miscdev_bad_count_test_LDADD = $(top_builddir)/src/libecryptfs/libecryptfs.la | 79 | miscdev_bad_count_test_LDADD = $(top_builddir)/src/libecryptfs/libecryptfs.la |
38 | 75 | 80 | ||
39 | 81 | mmap_bmap_test_SOURCES = mmap-bmap/test.c | ||
40 | 82 | |||
41 | 76 | mmap_close_test_SOURCES = mmap-close/test.c | 83 | mmap_close_test_SOURCES = mmap-close/test.c |
42 | 77 | 84 | ||
43 | 78 | mmap_dir_test_SOURCES = mmap-dir/test.c | 85 | mmap_dir_test_SOURCES = mmap-dir/test.c |
44 | @@ -80,3 +87,6 @@ | |||
45 | 80 | read_dir_test_SOURCES = read-dir/test.c | 87 | read_dir_test_SOURCES = read-dir/test.c |
46 | 81 | 88 | ||
47 | 82 | trunc_file_test_SOURCES = trunc-file/test.c | 89 | trunc_file_test_SOURCES = trunc-file/test.c |
48 | 90 | |||
49 | 91 | xattr_test_SOURCES = xattr/test.c | ||
50 | 92 | |||
51 | 83 | 93 | ||
52 | === added file 'tests/kernel/link.sh' | |||
53 | --- tests/kernel/link.sh 1970-01-01 00:00:00 +0000 | |||
54 | +++ tests/kernel/link.sh 2013-01-25 17:05:31 +0000 | |||
55 | @@ -0,0 +1,83 @@ | |||
56 | 1 | #!/bin/bash | ||
57 | 2 | # | ||
58 | 3 | # link.sh : Simple hard link sanity check | ||
59 | 4 | # | ||
60 | 5 | # Author: Colin Ian King <colin.king@canonical.com> | ||
61 | 6 | # | ||
62 | 7 | # Copyright (C) 2013 Canonical Ltd. | ||
63 | 8 | # | ||
64 | 9 | # This program is free software; you can redistribute it and/or | ||
65 | 10 | # modify it under the terms of the GNU General Public License | ||
66 | 11 | # as published by the Free Software Foundation version 2 | ||
67 | 12 | # of the License. | ||
68 | 13 | # | ||
69 | 14 | # This program is distributed in the hope that it will be useful, | ||
70 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
71 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
72 | 17 | # GNU General Public License for more details. | ||
73 | 18 | # | ||
74 | 19 | # You should have received a copy of the GNU General Public License | ||
75 | 20 | # along with this program; if not, write to the Free Software | ||
76 | 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
77 | 22 | |||
78 | 23 | test_script_dir=$(dirname $0) | ||
79 | 24 | rc=1 | ||
80 | 25 | test_dir=0 | ||
81 | 26 | |||
82 | 27 | . ${test_script_dir}/../lib/etl_funcs.sh | ||
83 | 28 | |||
84 | 29 | test_cleanup() | ||
85 | 30 | { | ||
86 | 31 | etl_remove_test_dir $test_dir | ||
87 | 32 | etl_umount | ||
88 | 33 | etl_lumount | ||
89 | 34 | etl_unlink_keys | ||
90 | 35 | exit $rc | ||
91 | 36 | } | ||
92 | 37 | trap test_cleanup 0 1 2 3 15 | ||
93 | 38 | |||
94 | 39 | # TEST | ||
95 | 40 | etl_add_keys || exit | ||
96 | 41 | etl_lmount || exit | ||
97 | 42 | etl_mount_i || exit | ||
98 | 43 | test_dir=$(etl_create_test_dir) || exit | ||
99 | 44 | test_file1="${test_dir}/test1" | ||
100 | 45 | test_file2="${test_dir}/test2" | ||
101 | 46 | |||
102 | 47 | echo "Testing 1 2 3" > $test_file1 | ||
103 | 48 | |||
104 | 49 | ln $test_file1 $test_file2 | ||
105 | 50 | |||
106 | 51 | rc=0 | ||
107 | 52 | # | ||
108 | 53 | # Contents should be the same | ||
109 | 54 | # | ||
110 | 55 | diff $test_file1 $test_file2 > /dev/null 2>&1 | ||
111 | 56 | if [ $? -ne 0 ]; then | ||
112 | 57 | rc=1 | ||
113 | 58 | fi | ||
114 | 59 | |||
115 | 60 | # | ||
116 | 61 | # Size should be the same | ||
117 | 62 | # | ||
118 | 63 | test_file1_size=$(stat -c%s $test_file1) | ||
119 | 64 | test_file2_size=$(stat -c%s $test_file2) | ||
120 | 65 | if [ $test_file1_size -ne $test_file2_size ]; then | ||
121 | 66 | rc=1 | ||
122 | 67 | fi | ||
123 | 68 | |||
124 | 69 | # | ||
125 | 70 | # Link count should be 2 for both | ||
126 | 71 | # | ||
127 | 72 | test_file1_links=$(stat -c%h $test_file1) | ||
128 | 73 | test_file2_links=$(stat -c%h $test_file2) | ||
129 | 74 | if [ $test_file1_links -ne 2 -a $test_file2_links -ne 2 ]; then | ||
130 | 75 | rc=1 | ||
131 | 76 | fi | ||
132 | 77 | |||
133 | 78 | rm -f $test_file1 $test_file2 | ||
134 | 79 | |||
135 | 80 | etl_umount || exit | ||
136 | 81 | etl_mount_i || exit | ||
137 | 82 | |||
138 | 83 | exit | ||
139 | 0 | 84 | ||
140 | === added file 'tests/kernel/mknod.sh' | |||
141 | --- tests/kernel/mknod.sh 1970-01-01 00:00:00 +0000 | |||
142 | +++ tests/kernel/mknod.sh 2013-01-25 17:05:31 +0000 | |||
143 | @@ -0,0 +1,64 @@ | |||
144 | 1 | #!/bin/bash | ||
145 | 2 | # | ||
146 | 3 | # mknod.sh : Simple mknod sanity check | ||
147 | 4 | # | ||
148 | 5 | # Author: Colin Ian King <colin.king@canonical.com> | ||
149 | 6 | # | ||
150 | 7 | # Copyright (C) 2013 Canonical Ltd. | ||
151 | 8 | # | ||
152 | 9 | # This program is free software; you can redistribute it and/or | ||
153 | 10 | # modify it under the terms of the GNU General Public License | ||
154 | 11 | # as published by the Free Software Foundation version 2 | ||
155 | 12 | # of the License. | ||
156 | 13 | # | ||
157 | 14 | # This program is distributed in the hope that it will be useful, | ||
158 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
159 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
160 | 17 | # GNU General Public License for more details. | ||
161 | 18 | # | ||
162 | 19 | # You should have received a copy of the GNU General Public License | ||
163 | 20 | # along with this program; if not, write to the Free Software | ||
164 | 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
165 | 22 | |||
166 | 23 | test_script_dir=$(dirname $0) | ||
167 | 24 | rc=1 | ||
168 | 25 | test_dir=0 | ||
169 | 26 | |||
170 | 27 | . ${test_script_dir}/../lib/etl_funcs.sh | ||
171 | 28 | |||
172 | 29 | test_cleanup() | ||
173 | 30 | { | ||
174 | 31 | etl_remove_test_dir $test_dir | ||
175 | 32 | etl_umount | ||
176 | 33 | etl_lumount | ||
177 | 34 | etl_unlink_keys | ||
178 | 35 | exit $rc | ||
179 | 36 | } | ||
180 | 37 | trap test_cleanup 0 1 2 3 15 | ||
181 | 38 | |||
182 | 39 | # TEST | ||
183 | 40 | etl_add_keys || exit | ||
184 | 41 | etl_lmount || exit | ||
185 | 42 | etl_mount_i || exit | ||
186 | 43 | test_dir=$(etl_create_test_dir) || exit | ||
187 | 44 | test_file="${test_dir}/full" | ||
188 | 45 | |||
189 | 46 | mknod $test_file c 1 7 | ||
190 | 47 | # | ||
191 | 48 | # Check to see if mknod succeeded as expected | ||
192 | 49 | # | ||
193 | 50 | if [ $? -eq 0 ]; then | ||
194 | 51 | dev=$(stat $test_file -c%t:%T) | ||
195 | 52 | if [ $? -eq 0 ]; then | ||
196 | 53 | if [ x$dev == x1:7 ]; then | ||
197 | 54 | rc=0 | ||
198 | 55 | fi | ||
199 | 56 | fi | ||
200 | 57 | fi | ||
201 | 58 | |||
202 | 59 | rm -f $test_file | ||
203 | 60 | |||
204 | 61 | etl_umount || exit | ||
205 | 62 | etl_mount_i || exit | ||
206 | 63 | |||
207 | 64 | exit | ||
208 | 0 | 65 | ||
209 | === added directory 'tests/kernel/mmap-bmap' | |||
210 | === added file 'tests/kernel/mmap-bmap.sh' | |||
211 | --- tests/kernel/mmap-bmap.sh 1970-01-01 00:00:00 +0000 | |||
212 | +++ tests/kernel/mmap-bmap.sh 2013-01-25 17:05:31 +0000 | |||
213 | @@ -0,0 +1,58 @@ | |||
214 | 1 | #!/bin/bash | ||
215 | 2 | # | ||
216 | 3 | # mmap-bmap.sh : Test to see if bmap from upper is a subset of the lower | ||
217 | 4 | # | ||
218 | 5 | # Author: Colin Ian King <colin.king@canonical.com> | ||
219 | 6 | # | ||
220 | 7 | # Copyright (C) 2013 Canonical Ltd. | ||
221 | 8 | # | ||
222 | 9 | # This program is free software; you can redistribute it and/or | ||
223 | 10 | # modify it under the terms of the GNU General Public License | ||
224 | 11 | # as published by the Free Software Foundation version 2 | ||
225 | 12 | # of the License. | ||
226 | 13 | # | ||
227 | 14 | # This program is distributed in the hope that it will be useful, | ||
228 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
229 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
230 | 17 | # GNU General Public License for more details. | ||
231 | 18 | # | ||
232 | 19 | # You should have received a copy of the GNU General Public License | ||
233 | 20 | # along with this program; if not, write to the Free Software | ||
234 | 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
235 | 22 | |||
236 | 23 | test_script_dir=$(dirname $0) | ||
237 | 24 | rc=1 | ||
238 | 25 | test_dir=0 | ||
239 | 26 | |||
240 | 27 | . ${test_script_dir}/../lib/etl_funcs.sh | ||
241 | 28 | |||
242 | 29 | test_cleanup() | ||
243 | 30 | { | ||
244 | 31 | etl_remove_test_dir $test_dir | ||
245 | 32 | etl_umount | ||
246 | 33 | etl_lumount | ||
247 | 34 | etl_unlink_keys | ||
248 | 35 | exit $rc | ||
249 | 36 | } | ||
250 | 37 | trap test_cleanup 0 1 2 3 15 | ||
251 | 38 | |||
252 | 39 | # TEST | ||
253 | 40 | etl_add_keys || exit | ||
254 | 41 | etl_lmount || exit | ||
255 | 42 | etl_mount_i || exit | ||
256 | 43 | test_dir=$(etl_create_test_dir) || exit | ||
257 | 44 | test_file="${test_dir}/test_file" | ||
258 | 45 | |||
259 | 46 | dd if=/dev/zero of=$test_file bs=1M count=1 > /dev/null 2>&1 || exit | ||
260 | 47 | lower_test_file=$(etl_find_lower_path $test_file) | ||
261 | 48 | if [ $? -ne 0 ] || [ -z "$lower_test_file" ]; then | ||
262 | 49 | rc=1 | ||
263 | 50 | exit | ||
264 | 51 | fi | ||
265 | 52 | ${test_script_dir}/mmap-bmap/test $lower_test_file $test_file || exit | ||
266 | 53 | rc=$? | ||
267 | 54 | |||
268 | 55 | etl_umount || exit | ||
269 | 56 | etl_mount_i || exit | ||
270 | 57 | |||
271 | 58 | exit | ||
272 | 0 | 59 | ||
273 | === added file 'tests/kernel/mmap-bmap/test.c' | |||
274 | --- tests/kernel/mmap-bmap/test.c 1970-01-01 00:00:00 +0000 | |||
275 | +++ tests/kernel/mmap-bmap/test.c 2013-01-25 17:05:31 +0000 | |||
276 | @@ -0,0 +1,132 @@ | |||
277 | 1 | /* | ||
278 | 2 | * Author: Colin King <colin.king@canonical.com> | ||
279 | 3 | * | ||
280 | 4 | * Copyright (C) 2013 Canonical, Ltd. | ||
281 | 5 | * | ||
282 | 6 | * This program is free software; you can redistribute it and/or | ||
283 | 7 | * modify it under the terms of the GNU General Public License | ||
284 | 8 | * as published by the Free Software Foundation; either version 2 | ||
285 | 9 | * of the License, or (at your option) any later version. | ||
286 | 10 | * | ||
287 | 11 | * This program is distributed in the hope that it will be useful, | ||
288 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
289 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
290 | 14 | * GNU General Public License for more details. | ||
291 | 15 | * | ||
292 | 16 | * You should have received a copy of the GNU General Public License | ||
293 | 17 | * along with this program; if not, write to the Free Software | ||
294 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
295 | 19 | */ | ||
296 | 20 | |||
297 | 21 | #include <stdio.h> | ||
298 | 22 | #include <stdlib.h> | ||
299 | 23 | #include <stdbool.h> | ||
300 | 24 | #include <string.h> | ||
301 | 25 | #include <unistd.h> | ||
302 | 26 | #include <errno.h> | ||
303 | 27 | #include <fcntl.h> | ||
304 | 28 | #include <sys/ioctl.h> | ||
305 | 29 | #include <sys/types.h> | ||
306 | 30 | #include <sys/stat.h> | ||
307 | 31 | #include <linux/fs.h> | ||
308 | 32 | |||
309 | 33 | static int *get_blocks(const char *filename, int *num_blocks) | ||
310 | 34 | { | ||
311 | 35 | int fd, block_size, i; | ||
312 | 36 | int *blocks; | ||
313 | 37 | struct stat statinfo; | ||
314 | 38 | |||
315 | 39 | if ((fd = open(filename, O_RDONLY)) < 0) { | ||
316 | 40 | fprintf(stderr, "Cannot open %s\n", filename); | ||
317 | 41 | return NULL; | ||
318 | 42 | } | ||
319 | 43 | |||
320 | 44 | if (ioctl(fd, FIGETBSZ, &block_size) < 0) { | ||
321 | 45 | fprintf(stderr, "Cannot get block size\n"); | ||
322 | 46 | close(fd); | ||
323 | 47 | return NULL; | ||
324 | 48 | } | ||
325 | 49 | |||
326 | 50 | if (fstat(fd, &statinfo) < 0) { | ||
327 | 51 | fprintf(stderr, "Cannot stat %s\n", filename); | ||
328 | 52 | close(fd); | ||
329 | 53 | return NULL; | ||
330 | 54 | } | ||
331 | 55 | |||
332 | 56 | *num_blocks = (statinfo.st_size + block_size - 1) / block_size; | ||
333 | 57 | |||
334 | 58 | blocks = malloc(sizeof(int) * *num_blocks); | ||
335 | 59 | if (!blocks) { | ||
336 | 60 | fprintf(stderr, "Cannot allocate buffer for %d blocks\n", *num_blocks); | ||
337 | 61 | close(fd); | ||
338 | 62 | return NULL; | ||
339 | 63 | } | ||
340 | 64 | |||
341 | 65 | /* | ||
342 | 66 | * Collect blocks, some file systems may not support FIBMAP, so | ||
343 | 67 | * silently ignore errors. | ||
344 | 68 | */ | ||
345 | 69 | for (i = 0; i < *num_blocks; i++) { | ||
346 | 70 | blocks[i] = i; | ||
347 | 71 | if (ioctl(fd, FIBMAP, &blocks[i]) < 0) | ||
348 | 72 | blocks[i] = 0; | ||
349 | 73 | } | ||
350 | 74 | close(fd); | ||
351 | 75 | |||
352 | 76 | return blocks; | ||
353 | 77 | } | ||
354 | 78 | |||
355 | 79 | int check_blocks( | ||
356 | 80 | int *lower_blocks, int lower_num_blocks, | ||
357 | 81 | int *upper_blocks, int upper_num_blocks) | ||
358 | 82 | { | ||
359 | 83 | int i, j; | ||
360 | 84 | |||
361 | 85 | /* Upper must not have more blocks than lower */ | ||
362 | 86 | if (upper_num_blocks > lower_num_blocks) | ||
363 | 87 | return EXIT_FAILURE; | ||
364 | 88 | |||
365 | 89 | /* Upper must have blocks that are in the lower */ | ||
366 | 90 | for (i = 0; i < upper_num_blocks; i++) { | ||
367 | 91 | bool found = false; | ||
368 | 92 | for (j = 0; j < lower_num_blocks; j++) { | ||
369 | 93 | if (upper_blocks[i] == lower_blocks[j]) { | ||
370 | 94 | found = true; | ||
371 | 95 | break; | ||
372 | 96 | } | ||
373 | 97 | } | ||
374 | 98 | if (!found) | ||
375 | 99 | return EXIT_FAILURE; | ||
376 | 100 | } | ||
377 | 101 | return EXIT_SUCCESS; | ||
378 | 102 | } | ||
379 | 103 | |||
380 | 104 | int main(int argc, char **argv) { | ||
381 | 105 | |||
382 | 106 | int *lower_blocks, *upper_blocks; | ||
383 | 107 | int lower_num_blocks, upper_num_blocks; | ||
384 | 108 | int rc = EXIT_SUCCESS; | ||
385 | 109 | |||
386 | 110 | if (argc != 3) { | ||
387 | 111 | fprintf(stderr, "Usage: %s lower-file upper-file\n", argv[0]); | ||
388 | 112 | exit(EXIT_FAILURE); | ||
389 | 113 | } | ||
390 | 114 | |||
391 | 115 | lower_blocks = get_blocks(argv[1], &lower_num_blocks); | ||
392 | 116 | if (!lower_blocks) | ||
393 | 117 | exit(EXIT_FAILURE); | ||
394 | 118 | |||
395 | 119 | upper_blocks = get_blocks(argv[2], &upper_num_blocks); | ||
396 | 120 | if (!upper_blocks) { | ||
397 | 121 | free(lower_blocks); | ||
398 | 122 | exit(EXIT_FAILURE); | ||
399 | 123 | } | ||
400 | 124 | |||
401 | 125 | rc = check_blocks(lower_blocks, lower_num_blocks, | ||
402 | 126 | upper_blocks, upper_num_blocks); | ||
403 | 127 | |||
404 | 128 | free(upper_blocks); | ||
405 | 129 | free(lower_blocks); | ||
406 | 130 | |||
407 | 131 | exit(rc); | ||
408 | 132 | } | ||
409 | 0 | 133 | ||
410 | === modified file 'tests/kernel/tests.rc' | |||
411 | --- tests/kernel/tests.rc 2012-11-02 23:20:18 +0000 | |||
412 | +++ tests/kernel/tests.rc 2013-01-25 17:05:31 +0000 | |||
413 | @@ -1,2 +1,2 @@ | |||
414 | 1 | destructive="miscdev-bad-count.sh extend-file-random.sh trunc-file.sh directory-concurrent.sh file-concurrent.sh lp-994247.sh" | 1 | destructive="miscdev-bad-count.sh extend-file-random.sh trunc-file.sh directory-concurrent.sh file-concurrent.sh lp-994247.sh" |
416 | 2 | safe="llseek.sh lp-469664.sh lp-524919.sh lp-509180.sh lp-613873.sh lp-745836.sh lp-870326.sh lp-885744.sh lp-926292.sh inotify.sh mmap-close.sh mmap-dir.sh read-dir.sh setattr-flush-dirty.sh inode-race-stat.sh lp-1009207.sh enospc.sh lp-911507.sh lp-872905.sh lp-561129.sh" | 2 | safe="llseek.sh lp-469664.sh lp-524919.sh lp-509180.sh lp-613873.sh lp-745836.sh lp-870326.sh lp-885744.sh lp-926292.sh inotify.sh mmap-bmap.sh mmap-close.sh mmap-dir.sh read-dir.sh setattr-flush-dirty.sh inode-race-stat.sh lp-1009207.sh enospc.sh lp-911507.sh lp-872905.sh lp-561129.sh mknod.sh link.sh xattr.sh" |
417 | 3 | 3 | ||
418 | === added directory 'tests/kernel/xattr' | |||
419 | === added file 'tests/kernel/xattr.sh' | |||
420 | --- tests/kernel/xattr.sh 1970-01-01 00:00:00 +0000 | |||
421 | +++ tests/kernel/xattr.sh 2013-01-25 17:05:31 +0000 | |||
422 | @@ -0,0 +1,56 @@ | |||
423 | 1 | #!/bin/bash | ||
424 | 2 | # | ||
425 | 3 | # xattr.sh : Simple xattr checks. | ||
426 | 4 | # | ||
427 | 5 | # Author: Colin Ian King <colin.king@canonical.com> | ||
428 | 6 | # | ||
429 | 7 | # Copyright (C) 2013 Canonical Ltd. | ||
430 | 8 | # | ||
431 | 9 | # This program is free software; you can redistribute it and/or | ||
432 | 10 | # modify it under the terms of the GNU General Public License | ||
433 | 11 | # as published by the Free Software Foundation version 2 | ||
434 | 12 | # of the License. | ||
435 | 13 | # | ||
436 | 14 | # This program is distributed in the hope that it will be useful, | ||
437 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
438 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
439 | 17 | # GNU General Public License for more details. | ||
440 | 18 | # | ||
441 | 19 | # You should have received a copy of the GNU General Public License | ||
442 | 20 | # along with this program; if not, write to the Free Software | ||
443 | 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
444 | 22 | |||
445 | 23 | test_script_dir=$(dirname $0) | ||
446 | 24 | rc=1 | ||
447 | 25 | test_dir=0 | ||
448 | 26 | |||
449 | 27 | . ${test_script_dir}/../lib/etl_funcs.sh | ||
450 | 28 | |||
451 | 29 | test_cleanup() | ||
452 | 30 | { | ||
453 | 31 | etl_remove_test_dir $test_dir | ||
454 | 32 | etl_umount | ||
455 | 33 | etl_lumount | ||
456 | 34 | etl_unlink_keys | ||
457 | 35 | exit $rc | ||
458 | 36 | } | ||
459 | 37 | trap test_cleanup 0 1 2 3 15 | ||
460 | 38 | |||
461 | 39 | # TEST | ||
462 | 40 | etl_add_keys || exit | ||
463 | 41 | etl_lmount || exit | ||
464 | 42 | etl_mount_i || exit | ||
465 | 43 | test_dir=$(etl_create_test_dir) || exit | ||
466 | 44 | test_file="${test_dir}/test" | ||
467 | 45 | |||
468 | 46 | echo "testing 1 2 3" > $test_file | ||
469 | 47 | |||
470 | 48 | ${test_script_dir}/xattr/test $test_file || exit | ||
471 | 49 | rc=$? | ||
472 | 50 | |||
473 | 51 | rm -f $test_file1 | ||
474 | 52 | |||
475 | 53 | etl_umount || exit | ||
476 | 54 | etl_mount_i || exit | ||
477 | 55 | |||
478 | 56 | exit | ||
479 | 0 | 57 | ||
480 | === added file 'tests/kernel/xattr/test.c' | |||
481 | --- tests/kernel/xattr/test.c 1970-01-01 00:00:00 +0000 | |||
482 | +++ tests/kernel/xattr/test.c 2013-01-25 17:05:31 +0000 | |||
483 | @@ -0,0 +1,111 @@ | |||
484 | 1 | /* | ||
485 | 2 | * Author: Colin King <colin.king@canonical.com> | ||
486 | 3 | * | ||
487 | 4 | * Copyright (C) 2013 Canonical, Ltd. | ||
488 | 5 | * | ||
489 | 6 | * This program is free software; you can redistribute it and/or | ||
490 | 7 | * modify it under the terms of the GNU General Public License | ||
491 | 8 | * as published by the Free Software Foundation; either version 2 | ||
492 | 9 | * of the License, or (at your option) any later version. | ||
493 | 10 | * | ||
494 | 11 | * This program is distributed in the hope that it will be useful, | ||
495 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
496 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
497 | 14 | * GNU General Public License for more details. | ||
498 | 15 | * | ||
499 | 16 | * You should have received a copy of the GNU General Public License | ||
500 | 17 | * along with this program; if not, write to the Free Software | ||
501 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA | ||
502 | 19 | */ | ||
503 | 20 | |||
504 | 21 | #include <stdio.h> | ||
505 | 22 | #include <stdlib.h> | ||
506 | 23 | #include <stdbool.h> | ||
507 | 24 | #include <string.h> | ||
508 | 25 | #include <unistd.h> | ||
509 | 26 | #include <errno.h> | ||
510 | 27 | #include <sys/xattr.h> | ||
511 | 28 | |||
512 | 29 | static const char *names[] = { | ||
513 | 30 | "user.test1", | ||
514 | 31 | "user.test2", | ||
515 | 32 | "user.test3", | ||
516 | 33 | NULL | ||
517 | 34 | }; | ||
518 | 35 | |||
519 | 36 | static const char *values[] = { | ||
520 | 37 | "test value #1", | ||
521 | 38 | "test value #2", | ||
522 | 39 | "test value #3", | ||
523 | 40 | NULL | ||
524 | 41 | }; | ||
525 | 42 | |||
526 | 43 | int main(int argc, char **argv) | ||
527 | 44 | { | ||
528 | 45 | ssize_t len, names_len = 0; | ||
529 | 46 | int i, rc; | ||
530 | 47 | char buffer[1024]; | ||
531 | 48 | char *ptr = buffer; | ||
532 | 49 | |||
533 | 50 | if (argc != 2) { | ||
534 | 51 | fprintf(stderr, "Usage: %s file\n", argv[0]); | ||
535 | 52 | exit(EXIT_FAILURE); | ||
536 | 53 | } | ||
537 | 54 | |||
538 | 55 | for (i = 0; names[i]; i++) { | ||
539 | 56 | if (setxattr(argv[1], names[i], values[i], strlen(values[i]), 0) < 0) | ||
540 | 57 | exit(EXIT_FAILURE); | ||
541 | 58 | names_len += 1 + strlen(names[i]); | ||
542 | 59 | } | ||
543 | 60 | |||
544 | 61 | /* | ||
545 | 62 | * Sanity check that listxattr returns correct length | ||
546 | 63 | */ | ||
547 | 64 | len = listxattr(argv[1], NULL, 0); | ||
548 | 65 | if (len != names_len) | ||
549 | 66 | exit(EXIT_FAILURE); | ||
550 | 67 | |||
551 | 68 | len = listxattr(argv[1], buffer, sizeof(buffer)); | ||
552 | 69 | if (len < 0) | ||
553 | 70 | exit(EXIT_FAILURE); | ||
554 | 71 | |||
555 | 72 | /* | ||
556 | 73 | * Check listxattr names match what has been just set | ||
557 | 74 | */ | ||
558 | 75 | for (i = 0; names[i]; i++) { | ||
559 | 76 | if (strcmp(names[i], ptr)) | ||
560 | 77 | exit(EXIT_FAILURE); | ||
561 | 78 | ptr += strlen(ptr) + 1; | ||
562 | 79 | } | ||
563 | 80 | |||
564 | 81 | /* | ||
565 | 82 | * Check contents of xattr | ||
566 | 83 | */ | ||
567 | 84 | for (i = 0; names[i]; i++) { | ||
568 | 85 | len = getxattr(argv[1], names[i], buffer, sizeof(buffer)); | ||
569 | 86 | if (len < 0) | ||
570 | 87 | exit(EXIT_FAILURE); | ||
571 | 88 | buffer[len] = '\0'; | ||
572 | 89 | |||
573 | 90 | if (strcmp(values[i], buffer)) | ||
574 | 91 | exit(EXIT_FAILURE); | ||
575 | 92 | } | ||
576 | 93 | |||
577 | 94 | /* | ||
578 | 95 | * Remove xattr | ||
579 | 96 | */ | ||
580 | 97 | for (i = 0; names[i]; i++) { | ||
581 | 98 | rc = removexattr(argv[1], names[i]); | ||
582 | 99 | if (rc < 0) | ||
583 | 100 | exit(EXIT_FAILURE); | ||
584 | 101 | } | ||
585 | 102 | |||
586 | 103 | /* | ||
587 | 104 | * ..and there should be no xattrs left | ||
588 | 105 | */ | ||
589 | 106 | len = listxattr(argv[1], NULL, 0); | ||
590 | 107 | if (len != 0) | ||
591 | 108 | exit(EXIT_FAILURE); | ||
592 | 109 | |||
593 | 110 | exit(EXIT_SUCCESS); | ||
594 | 111 | } |