]> arthur.barton.de Git - bup.git/blob - t/test-meta.sh
test-meta.sh: use the more portable "touch -t" instead of "touch -d".
[bup.git] / t / test-meta.sh
1 #!/usr/bin/env bash
2 . wvtest.sh
3 . t/lib.sh
4
5 TOP="$(pwd)"
6 export BUP_DIR="$TOP/buptest.tmp"
7
8 bup()
9 {
10     "$TOP/bup" "$@"
11 }
12
13 hardlink-sets()
14 {
15     "$TOP/t/hardlink-sets" "$@"
16 }
17
18 # Very simple metadata tests -- create a test tree then check that bup
19 # meta can reproduce the metadata correctly (according to bup xstat)
20 # via create, extract, start-extract, and finish-extract.  The current
21 # tests are crude, and this does not fully test devices, varying
22 # users/groups, acls, attrs, etc.
23
24 genstat()
25 {
26     (
27         export PATH="$TOP:$PATH" # pick up bup
28         # Skip atime (test elsewhere) to avoid the observer effect.
29         find . | sort | xargs bup xstat --exclude-fields ctime,atime,size
30     )
31 }
32
33 test-src-create-extract()
34 {
35     # Test bup meta create/extract for ./src -> ./src-restore.
36     # Also writes to ./src-stat and ./src-restore-stat.
37     (
38         (cd src && WVPASS genstat) > src-stat
39         WVPASS bup meta --create --recurse --file src.meta src
40         # Test extract.
41         force-delete src-restore
42         mkdir src-restore
43         cd src-restore
44         WVPASS bup meta --extract --file ../src.meta
45         WVPASS test -d src
46         (cd src && genstat >../../src-restore-stat) || WVFAIL
47         WVPASS diff -U5 ../src-stat ../src-restore-stat
48         # Test start/finish extract.
49         force-delete src
50         WVPASS bup meta --start-extract --file ../src.meta
51         WVPASS test -d src
52         WVPASS bup meta --finish-extract --file ../src.meta
53         (cd src && genstat >../../src-restore-stat) || WVFAIL
54         WVPASS diff -U5 ../src-stat ../src-restore-stat
55     )
56 }
57
58 test-src-save-restore()
59 {
60     # Test bup save/restore metadata for ./src -> ./src-restore.  Also
61     # writes to ./src.bup.  Note that for now this just tests the
62     # restore below src/, in order to avoid having to worry about
63     # operations that require root (like chown /home).
64     (
65         set -x
66         rm -rf src.bup
67         mkdir src.bup
68         export BUP_DIR=$(pwd)/src.bup
69         WVPASS bup init
70         WVPASS bup index src
71         WVPASS bup save -t -n src src
72         # Test extract.
73         force-delete src-restore
74         mkdir src-restore
75         WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
76         WVPASS test -d src-restore/src
77         WVPASS "$TOP/t/compare-trees" -c src/ src-restore/src/
78         rm -rf src.bup
79         set +x
80     )
81 }
82
83 universal-cleanup()
84 {
85     if [ $(t/root-status) != root ]; then return 0; fi
86     cd "$TOP"
87     umount "$TOP/bupmeta.tmp/testfs" || true
88     umount "$TOP/bupmeta.tmp/testfs-limited" || true
89 }
90
91 universal-cleanup
92 trap universal-cleanup EXIT
93
94 setup-test-tree()
95 (
96     set -e
97     force-delete "$BUP_DIR"
98     force-delete "$TOP/bupmeta.tmp"
99     mkdir -p "$TOP/bupmeta.tmp/src"
100     cp -pPR Documentation cmd lib t "$TOP/bupmeta.tmp"/src
101
102     # Add some hard links for the general tests.
103     (
104         cd "$TOP/bupmeta.tmp"/src
105         touch hardlink-target
106         ln hardlink-target hardlink-1
107         ln hardlink-target hardlink-2
108         ln hardlink-target hardlink-3
109     )
110
111     # Add some trivial files for the index, modify, save tests.
112     (
113         cd "$TOP/bupmeta.tmp"/src
114         mkdir volatile
115         touch volatile/{1,2,3}
116     )
117
118     # Regression test for metadata sort order.  Previously, these two
119     # entries would sort in the wrong order because the metadata
120     # entries were being sorted by mangled name, but the index isn't.
121     dd if=/dev/zero of="$TOP/bupmeta.tmp"/src/foo bs=1k count=33
122     touch -t 201111111111 "$TOP/bupmeta.tmp"/src/foo
123     touch -t 201112121111 "$TOP/bupmeta.tmp"/src/foo-bar
124
125     t/mksock "$TOP/bupmeta.tmp/src/test-socket" || true
126 ) || WVFAIL
127
128 # Use the test tree to check bup meta.
129 WVSTART 'meta --create/--extract'
130 (
131     setup-test-tree
132     cd "$TOP/bupmeta.tmp"
133     test-src-create-extract
134
135     # Test a top-level file (not dir).
136     touch src-file
137     WVPASS bup meta -cf src-file.meta src-file
138     mkdir dest
139     cd dest
140     WVPASS bup meta -xf ../src-file.meta
141 )
142
143 # Use the test tree to check bup save/restore metadata.
144 WVSTART 'metadata save/restore (general)'
145 (
146     setup-test-tree
147     cd "$TOP/bupmeta.tmp"
148     test-src-save-restore
149 )
150
151 # Test that we pull the index (not filesystem) metadata for any
152 # unchanged files whenever we're saving other files in a given
153 # directory.
154 WVSTART 'metadata save/restore (using index metadata)'
155 (
156     setup-test-tree
157     cd "$TOP/bupmeta.tmp"
158
159     # ...for now -- might be a problem with hardlink restores that was
160     # causing noise wrt this test.
161     rm -rf src/hardlink*
162
163     # Pause here to keep the filesystem changes far enough away from
164     # the first index run that bup won't cap their index timestamps
165     # (see "bup help index" for more information).  Without this
166     # sleep, the compare-trees test below "Bup should *not* pick up
167     # these metadata..." may fail.
168     sleep 1
169
170     set -x
171     rm -rf src.bup
172     mkdir src.bup
173     export BUP_DIR=$(pwd)/src.bup
174     WVPASS bup init
175     WVPASS bup index src
176     WVPASS bup save -t -n src src
177
178     force-delete src-restore-1
179     mkdir src-restore-1
180     WVPASS bup restore -C src-restore-1 "/src/latest$(pwd)/"
181     WVPASS test -d src-restore-1/src
182     WVPASS "$TOP/t/compare-trees" -c src/ src-restore-1/src/
183
184     echo "blarg" > src/volatile/1
185     cp -a src/volatile/1 src-restore-1/src/volatile/
186     WVPASS bup index src
187
188     # Bup should *not* pick up these metadata changes.
189     touch src/volatile/2
190
191     WVPASS bup save -t -n src src
192
193     force-delete src-restore-2
194     mkdir src-restore-2
195     WVPASS bup restore -C src-restore-2 "/src/latest$(pwd)/"
196     WVPASS test -d src-restore-2/src
197     WVPASS "$TOP/t/compare-trees" -c src-restore-1/src/ src-restore-2/src/
198
199     rm -rf src.bup
200     set +x
201 )
202
203 setup-hardlink-test()
204 {
205     (
206         cd "$TOP/bupmeta.tmp"
207         rm -rf src src.bup
208         mkdir src src.bup
209         WVPASS bup init
210     )
211 }
212
213 hardlink-test-run-restore()
214 {
215     force-delete src-restore
216     mkdir src-restore
217     WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
218     WVPASS test -d src-restore/src
219 }
220
221 # Test hardlinks more carefully.
222 WVSTART 'metadata save/restore (hardlinks)'
223 (
224     set -e
225     set -x
226     export BUP_DIR="$TOP/bupmeta.tmp/src.bup"
227     force-delete "$TOP/bupmeta.tmp"
228     mkdir -p "$TOP/bupmeta.tmp"
229
230     cd "$TOP/bupmeta.tmp"
231
232     # Test trivial case - single hardlink.
233     setup-hardlink-test
234     (
235         cd "$TOP/bupmeta.tmp"/src
236         touch hardlink-target
237         ln hardlink-target hardlink-1
238     )
239     WVPASS bup index src
240     WVPASS bup save -t -n src src
241     hardlink-test-run-restore
242     WVPASS "$TOP/t/compare-trees" -c src/ src-restore/src/
243
244     # Test the case where the hardlink hasn't changed, but the tree
245     # needs to be saved again. i.e. the save-cmd.py "if hashvalid:"
246     # case.
247     (
248         cd "$TOP/bupmeta.tmp"/src
249         echo whatever > something-new
250     )
251     WVPASS bup index src
252     WVPASS bup save -t -n src src
253     hardlink-test-run-restore
254     WVPASS "$TOP/t/compare-trees" -c src/ src-restore/src/
255
256     # Test hardlink changes between index runs.
257     #
258     setup-hardlink-test
259     cd "$TOP/bupmeta.tmp"/src
260     touch hardlink-target-a
261     touch hardlink-target-b
262     ln hardlink-target-a hardlink-b-1
263     ln hardlink-target-a hardlink-a-1
264     cd ..
265     WVPASS bup index -vv src
266     rm src/hardlink-b-1
267     ln src/hardlink-target-b src/hardlink-b-1
268     WVPASS bup index -vv src
269     WVPASS bup save -t -n src src
270     hardlink-test-run-restore
271     echo ./src/hardlink-a-1 > hardlink-sets.expected
272     echo ./src/hardlink-target-a >> hardlink-sets.expected
273     echo >> hardlink-sets.expected
274     echo ./src/hardlink-b-1 >> hardlink-sets.expected
275     echo ./src/hardlink-target-b >> hardlink-sets.expected
276     (cd src-restore && hardlink-sets .) > hardlink-sets.restored
277     WVPASS diff -u hardlink-sets.expected hardlink-sets.restored
278
279     # Test hardlink changes between index and save -- hardlink set [a
280     # b c d] changes to [a b] [c d].  At least right now bup should
281     # notice and recreate the latter.
282     setup-hardlink-test
283     cd "$TOP/bupmeta.tmp"/src
284     touch a
285     ln a b
286     ln a c
287     ln a d
288     cd ..
289     WVPASS bup index -vv src
290     rm src/c src/d
291     touch src/c
292     ln src/c src/d
293     WVPASS bup save -t -n src src
294     hardlink-test-run-restore
295     echo ./src/a > hardlink-sets.expected
296     echo ./src/b >> hardlink-sets.expected
297     echo >> hardlink-sets.expected
298     echo ./src/c >> hardlink-sets.expected
299     echo ./src/d >> hardlink-sets.expected
300     (cd src-restore && hardlink-sets .) > hardlink-sets.restored
301     WVPASS diff -u hardlink-sets.expected hardlink-sets.restored
302
303     # Test that we don't link outside restore tree.
304     setup-hardlink-test
305     cd "$TOP/bupmeta.tmp"
306     mkdir src/a src/b
307     touch src/a/1
308     ln src/a/1 src/b/1
309     WVPASS bup index -vv src
310     WVPASS bup save -t -n src src
311     force-delete src-restore
312     mkdir src-restore
313     WVPASS bup restore -C src-restore "/src/latest$(pwd)/src/a/"
314     WVPASS test -e src-restore/1
315     echo -n > hardlink-sets.expected
316     (cd src-restore && hardlink-sets .) > hardlink-sets.restored
317     WVPASS diff -u hardlink-sets.expected hardlink-sets.restored
318
319     # Test that we do link within separate sub-trees.
320     setup-hardlink-test
321     cd "$TOP/bupmeta.tmp"
322     mkdir src/a src/b
323     touch src/a/1
324     ln src/a/1 src/b/1
325     WVPASS bup index -vv src/a src/b
326     WVPASS bup save -t -n src src/a src/b
327     hardlink-test-run-restore
328     echo ./src/a/1 > hardlink-sets.expected
329     echo ./src/b/1 >> hardlink-sets.expected
330     (cd src-restore && hardlink-sets .) > hardlink-sets.restored
331     WVPASS diff -u hardlink-sets.expected hardlink-sets.restored
332 )
333
334 WVSTART 'meta --edit'
335 (
336     force-delete "$TOP/bupmeta.tmp"
337     mkdir "$TOP/bupmeta.tmp"
338     cd "$TOP/bupmeta.tmp"
339     mkdir src
340     WVPASS bup meta -cf src.meta src
341
342     WVPASS bup meta --edit --set-uid 0 src.meta | WVPASS bup meta -tvvf - \
343         | WVPASS grep -qE '^uid: 0'
344     WVPASS bup meta --edit --set-uid 1000 src.meta | WVPASS bup meta -tvvf - \
345         | WVPASS grep -qE '^uid: 1000'
346
347     WVPASS bup meta --edit --set-gid 0 src.meta | WVPASS bup meta -tvvf - \
348         | WVPASS grep -qE '^gid: 0'
349     WVPASS bup meta --edit --set-gid 1000 src.meta | WVPASS bup meta -tvvf - \
350         | WVPASS grep -qE '^gid: 1000'
351
352     WVPASS bup meta --edit --set-user foo src.meta | WVPASS bup meta -tvvf - \
353         | WVPASS grep -qE '^user: foo'
354     WVPASS bup meta --edit --set-user bar src.meta | WVPASS bup meta -tvvf - \
355         | WVPASS grep -qE '^user: bar'
356     WVPASS bup meta --edit --unset-user src.meta | WVPASS bup meta -tvvf - \
357         | WVPASS grep -qE '^user:'
358     WVPASS bup meta --edit --set-user bar --unset-user src.meta \
359         | WVPASS bup meta -tvvf - | WVPASS grep -qE '^user:'
360     WVPASS bup meta --edit --unset-user --set-user bar src.meta \
361         | WVPASS bup meta -tvvf - | WVPASS grep -qE '^user: bar'
362
363     WVPASS bup meta --edit --set-group foo src.meta | WVPASS bup meta -tvvf - \
364         | WVPASS grep -qE '^group: foo'
365     WVPASS bup meta --edit --set-group bar src.meta | WVPASS bup meta -tvvf - \
366         | WVPASS grep -qE '^group: bar'
367     WVPASS bup meta --edit --unset-group src.meta | WVPASS bup meta -tvvf - \
368         | WVPASS grep -qE '^group:'
369     WVPASS bup meta --edit --set-group bar --unset-group src.meta \
370         | WVPASS bup meta -tvvf - | WVPASS grep -qE '^group:'
371     WVPASS bup meta --edit --unset-group --set-group bar src.meta \
372         | WVPASS bup meta -tvvf - | grep -qE '^group: bar'
373 )
374
375 # Test ownership restoration (when not root or fakeroot).
376 (
377     if [ $(t/root-status) != none ]; then
378         exit 0
379     fi
380
381     WVSTART 'metadata (restoration of ownership)'
382     force-delete "$TOP/bupmeta.tmp"
383     mkdir "$TOP/bupmeta.tmp"
384     cd "$TOP/bupmeta.tmp"
385     touch src
386     WVPASS bup meta -cf src.meta src
387
388     mkdir dest
389     cd dest
390     # Make sure we don't change (or try to change) the user when not root.
391     WVPASS bup meta --edit --set-user root ../src.meta | WVPASS bup meta -x
392     WVPASS bup xstat src | WVPASS grep -qvE '^user: root'
393     rm -rf src
394     WVPASS bup meta --edit --unset-user --set-uid 0 ../src.meta \
395         | WVPASS bup meta -x
396     WVPASS bup xstat src | grep -qvE '^user: root'
397
398     # Make sure we can restore one of the user's groups.
399     last_group="$(python -c 'import os,grp; \
400       print grp.getgrgid(os.getgroups()[0])[0]')"
401     rm -rf src
402     WVPASS bup meta --edit --set-group "$last_group" ../src.meta \
403         | WVPASS bup meta -x
404     WVPASS bup xstat src | WVPASS grep -qE "^group: $last_group"
405
406     # Make sure we can restore one of the user's gids.
407     user_gids="$(id -G)"
408     last_gid="$(echo ${user_gids/* /})"
409     rm -rf src
410     WVPASS bup meta --edit --unset-group --set-gid "$last_gid" ../src.meta \
411         | WVPASS bup meta -x
412     WVPASS bup xstat src | WVPASS grep -qE "^gid: $last_gid"
413
414     # Test --numeric-ids (gid).
415     rm -rf src
416     current_gidx=$(bup meta -tvvf ../src.meta | grep -e '^gid:')
417     WVPASS bup meta --edit --set-group "$last_group" ../src.meta \
418         | WVPASS bup meta -x --numeric-ids
419     new_gidx=$(bup xstat src | grep -e '^gid:')
420     WVPASSEQ "$current_gidx" "$new_gidx"
421
422     # Test that restoring an unknown user works.
423     unknown_user=$("$TOP"/t/unknown-owner --user)
424     rm -rf src
425     current_uidx=$(bup meta -tvvf ../src.meta | grep -e '^uid:')
426     WVPASS bup meta --edit --set-user "$unknown_user" ../src.meta \
427         | WVPASS bup meta -x
428     new_uidx=$(bup xstat src | grep -e '^uid:')
429     WVPASSEQ "$current_uidx" "$new_uidx"
430
431     # Test that restoring an unknown group works.
432     unknown_group=$("$TOP"/t/unknown-owner --group)
433     rm -rf src
434     current_gidx=$(bup meta -tvvf ../src.meta | grep -e '^gid:')
435     WVPASS bup meta --edit --set-group "$unknown_group" ../src.meta \
436         | WVPASS bup meta -x
437     new_gidx=$(bup xstat src | grep -e '^gid:')
438     WVPASSEQ "$current_gidx" "$new_gidx"
439 )
440
441 # Test ownership restoration (when root or fakeroot).
442 (
443     if [ $(t/root-status) == none ]; then
444         exit 0
445     fi
446
447     WVSTART 'metadata (restoration of ownership as root)'
448     force-delete "$TOP/bupmeta.tmp"
449     mkdir "$TOP/bupmeta.tmp"
450     cd "$TOP/bupmeta.tmp"
451     touch src
452     chown 0:0 src # In case the parent dir is sgid, etc.
453     WVPASS bup meta -cf src.meta src
454
455     mkdir dest
456     chmod 700 dest # so we can't accidentally do something insecure
457     cd dest
458
459     # Make sure we can restore a uid.
460     WVPASS bup meta --edit --unset-user --set-uid 42 ../src.meta \
461         | WVPASS bup meta -x
462     WVPASS bup xstat src | WVPASS grep -qE '^uid: 42'
463
464     # Make sure we can restore a gid.
465     WVPASS bup meta --edit --unset-group --set-gid 42 ../src.meta \
466         | WVPASS bup meta -x
467     WVPASS bup xstat src | WVPASS grep -qE '^gid: 42'
468
469     some_user=$("$TOP"/t/some-owner --user)
470     some_group=$("$TOP"/t/some-owner --group)
471
472     # Try to restore a user (and see that user trumps uid when uid is not 0).
473     WVPASS bup meta --edit --set-uid 42 --set-user "$some_user" ../src.meta \
474         | WVPASS bup meta -x
475     WVPASS bup xstat src | WVPASS grep -qE "^user: $some_user"
476
477     # Try to restore a group (and see that group trumps gid when gid is not 0).
478     WVPASS bup meta --edit --set-gid 42 --set-group "$some_group" ../src.meta \
479         | WVPASS bup meta -x
480     WVPASS bup xstat src | WVPASS grep -qE "^group: $some_user"
481
482     # Make sure a uid of 0 trumps a non-root user.
483     WVPASS bup meta --edit --set-user "$some_user" ../src.meta \
484         | WVPASS bup meta -x
485     WVPASS bup xstat src | WVPASS grep -qvE "^user: $some_user"
486     WVPASS bup xstat src | WVPASS grep -qE "^uid: 0"
487
488     # Make sure a gid of 0 trumps a non-root group.
489     WVPASS bup meta --edit --set-group "$some_user" ../src.meta \
490         | WVPASS bup meta -x
491     WVPASS bup xstat src | WVPASS grep -qvE "^group: $some_group"
492     WVPASS bup xstat src | WVPASS grep -qE "^gid: 0"
493
494     # Test --numeric-ids (gid).  Note the name 'root' is not handled
495     # specially, so we use that here as the test group name.  We
496     # assume that the root group's gid is never 42.
497     rm -rf src
498     WVPASS bup meta --edit --set-group root --set-gid 42 ../src.meta \
499         | WVPASS bup meta -x --numeric-ids
500     new_gidx=$(bup xstat src | grep -e '^gid:')
501     WVPASSEQ "$new_gidx" 'gid: 42'
502
503     # Test --numeric-ids (uid).  Note the name 'root' is not handled
504     # specially, so we use that here as the test user name.  We assume
505     # that the root user's uid is never 42.
506     rm -rf src
507     WVPASS bup meta --edit --set-user root --set-uid 42 ../src.meta \
508         | WVPASS bup meta -x --numeric-ids
509     new_uidx=$(bup xstat src | grep -e '^uid:')
510     WVPASSEQ "$new_uidx" 'uid: 42'
511
512     # Test that restoring an unknown user works.
513     unknown_user=$("$TOP"/t/unknown-owners --user)
514     rm -rf src
515     WVPASS bup meta --edit --set-uid 42 --set-user "$unknown_user" ../src.meta \
516         | WVPASS bup meta -x
517     new_uidx=$(bup xstat src | grep -e '^uid:')
518     WVPASSEQ "$new_uidx" 'uid: 42'
519
520     # Test that restoring an unknown group works.
521     unknown_group=$("$TOP"/t/unknown-owners --group)
522     rm -rf src
523     WVPASS bup meta --edit \
524         --set-gid 42 --set-group "$unknown_group" ../src.meta \
525         | WVPASS bup meta -x
526     new_gidx=$(bup xstat src | grep -e '^gid:')
527     WVPASSEQ "$new_gidx" 'gid: 42'
528 )
529
530 # Root-only tests that require an FS with all the trimmings: ACLs,
531 # Linux attr, Linux xattr, etc.
532 if [ $(t/root-status) == root ]; then
533     (
534         set -e
535         # Some cleanup handled in universal-cleanup() above.
536         # These tests are only likely to work under Linux for now
537         # (patches welcome).
538         [[ $(uname) =~ Linux ]] || exit 0
539
540         WVSTART 'meta - general (as root)'
541         setup-test-tree
542         cd "$TOP/bupmeta.tmp"
543
544         umount testfs || true
545         dd if=/dev/zero of=testfs.img bs=1M count=32
546         mke2fs -F -j -m 0 testfs.img
547         mkdir testfs
548         mount -o loop,acl,user_xattr testfs.img testfs
549         # Hide, so that tests can't create risks.
550         chown root:root testfs
551         chmod 0700 testfs
552
553         umount testfs-limited || true
554         dd if=/dev/zero of=testfs-limited.img bs=1M count=32
555         mkfs -t vfat testfs-limited.img
556         mkdir testfs-limited
557         mount -o loop,uid=root,gid=root,umask=0077 \
558             testfs-limited.img testfs-limited
559
560         #cp -a src testfs/src
561         cp -pPR src testfs/src
562         (cd testfs && test-src-create-extract)
563
564         WVSTART 'meta - atime (as root)'
565         force-delete testfs/src
566         mkdir testfs/src
567         (
568             mkdir testfs/src/foo
569             touch testfs/src/bar
570             PYTHONPATH="$TOP/lib" \
571                 python -c "from bup import xstat; \
572                 x = xstat.timespec_to_nsecs((42, 0));\
573                    xstat.utime('testfs/src/foo', (x, x));\
574                    xstat.utime('testfs/src/bar', (x, x));"
575             cd testfs
576             WVPASS bup meta -v --create --recurse --file src.meta src
577             bup meta -tvf src.meta
578             # Test extract.
579             force-delete src-restore
580             mkdir src-restore
581             cd src-restore
582             WVPASS bup meta --extract --file ../src.meta
583             WVPASSEQ "$(bup xstat --include-fields=atime src/foo)" "atime: 42"
584             WVPASSEQ "$(bup xstat --include-fields=atime src/bar)" "atime: 42"
585             # Test start/finish extract.
586             force-delete src
587             WVPASS bup meta --start-extract --file ../src.meta
588             WVPASS test -d src
589             WVPASS bup meta --finish-extract --file ../src.meta
590             WVPASSEQ "$(bup xstat --include-fields=atime src/foo)" "atime: 42"
591             WVPASSEQ "$(bup xstat --include-fields=atime src/bar)" "atime: 42"
592         )
593
594         WVSTART 'meta - Linux attr (as root)'
595         force-delete testfs/src
596         mkdir testfs/src
597         (
598             touch testfs/src/foo
599             mkdir testfs/src/bar
600             chattr +acdeijstuADST testfs/src/foo
601             chattr +acdeijstuADST testfs/src/bar
602             (cd testfs && test-src-create-extract)
603             # Test restoration to a limited filesystem (vfat).
604             (
605                 WVPASS bup meta --create --recurse --file testfs/src.meta \
606                     testfs/src
607                 force-delete testfs-limited/src-restore
608                 mkdir testfs-limited/src-restore
609                 cd testfs-limited/src-restore
610                 WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
611                     | WVPASS grep -e '^Linux chattr:' \
612                     | WVPASS python -c \
613                       'import sys; exit(not len(sys.stdin.readlines()) == 2)'
614             )
615         )
616
617         WVSTART 'meta - Linux xattr (as root)'
618         force-delete testfs/src
619         mkdir testfs/src
620         (
621             touch testfs/src/foo
622             mkdir testfs/src/bar
623             attr -s foo -V bar testfs/src/foo
624             attr -s foo -V bar testfs/src/bar
625             (cd testfs && test-src-create-extract)
626
627             # Test restoration to a limited filesystem (vfat).
628             (
629                 WVPASS bup meta --create --recurse --file testfs/src.meta \
630                     testfs/src
631                 force-delete testfs-limited/src-restore
632                 mkdir testfs-limited/src-restore
633                 cd testfs-limited/src-restore
634                 WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
635                     | WVPASS grep -e '^xattr\.set:' \
636                     | WVPASS python -c \
637                       'import sys; exit(not len(sys.stdin.readlines()) == 2)'
638             )
639         )
640
641         WVSTART 'meta - POSIX.1e ACLs (as root)'
642         force-delete testfs/src
643         mkdir testfs/src
644         (
645             touch testfs/src/foo
646             mkdir testfs/src/bar
647             setfacl -m u:root:r testfs/src/foo
648             setfacl -m u:root:r testfs/src/bar
649             (cd testfs && test-src-create-extract)
650
651             # Test restoration to a limited filesystem (vfat).
652             (
653                 WVPASS bup meta --create --recurse --file testfs/src.meta \
654                     testfs/src
655                 force-delete testfs-limited/src-restore
656                 mkdir testfs-limited/src-restore
657                 cd testfs-limited/src-restore
658                 WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
659                     | WVPASS grep -e '^POSIX1e ACL applyto:' \
660                     | WVPASS python -c \
661                       'import sys; exit(not len(sys.stdin.readlines()) == 2)'
662             )
663         )
664     )
665 fi
666
667 exit 0