7 TOP="$(WVPASS pwd)" || exit $?
8 export BUP_DIR="$TOP/buptest.tmp"
10 WVPASS force-delete "$TOP/bupmeta.tmp"
11 timestamp_resolutions="$(t/ns-timestamp-resolutions "$TOP/bupmeta.tmp")" \
13 WVPASS rm "$TOP/bupmeta.tmp"
14 atime_resolution="$(echo $timestamp_resolutions | WVPASS cut -d' ' -f 1)" \
16 mtime_resolution="$(echo $timestamp_resolutions | WVPASS cut -d' ' -f 2)" \
26 "$TOP/t/hardlink-sets" "$@"
31 "$TOP/t/id-other-than" "$@"
34 # Very simple metadata tests -- create a test tree then check that bup
35 # meta can reproduce the metadata correctly (according to bup xstat)
36 # via create, extract, start-extract, and finish-extract. The current
37 # tests are crude, and this does not fully test devices, varying
38 # users/groups, acls, attrs, etc.
43 export PATH="$TOP:$PATH" # pick up bup
44 # Skip atime (test elsewhere) to avoid the observer effect.
45 WVPASS find . | WVPASS sort \
46 | WVPASS xargs bup xstat \
47 --mtime-resolution "$mtime_resolution"ns \
48 --exclude-fields ctime,atime,size
52 test-src-create-extract()
54 # Test bup meta create/extract for ./src -> ./src-restore.
55 # Also writes to ./src-stat and ./src-restore-stat.
57 (WVPASS cd src; WVPASS genstat) > src-stat || exit $?
58 WVPASS bup meta --create --recurse --file src.meta src
60 WVPASS force-delete src-restore
61 WVPASS mkdir src-restore
63 WVPASS bup meta --extract --file ../src.meta
65 (WVPASS cd src; WVPASS genstat >../../src-restore-stat) || exit $?
66 WVPASS diff -U5 ../src-stat ../src-restore-stat
67 # Test start/finish extract.
68 WVPASS force-delete src
69 WVPASS bup meta --start-extract --file ../src.meta
71 WVPASS bup meta --finish-extract --file ../src.meta
72 (WVPASS cd src; WVPASS genstat >../../src-restore-stat) || exit $?
73 WVPASS diff -U5 ../src-stat ../src-restore-stat
77 test-src-save-restore()
79 # Test bup save/restore metadata for ./src -> ./src-restore. Also
80 # writes to ./src.bup. Note that for now this just tests the
81 # restore below src/, in order to avoid having to worry about
82 # operations that require root (like chown /home).
86 export BUP_DIR=$(pwd)/src.bup
89 WVPASS bup save -t -n src src
91 WVPASS force-delete src-restore
92 WVPASS mkdir src-restore
93 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
94 WVPASS test -d src-restore/src
95 WVPASS "$TOP/t/compare-trees" -c src/ src-restore/src/
102 if [ $(t/root-status) != root ]; then return 0; fi
103 umount "$TOP/bupmeta.tmp/testfs" || true
104 umount "$TOP/bupmeta.tmp/testfs-limited" || true
107 WVPASS universal-cleanup
108 trap universal-cleanup EXIT
112 WVPASS force-delete "$BUP_DIR"
113 WVPASS force-delete "$TOP/bupmeta.tmp"
114 WVPASS mkdir -p "$TOP/bupmeta.tmp/src"
115 WVPASS cp -pPR Documentation cmd config lib "$TOP/bupmeta.tmp"/src
117 # Add some hard links for the general tests.
119 WVPASS cd "$TOP/bupmeta.tmp"/src
120 WVPASS touch hardlink-target
121 WVPASS ln hardlink-target hardlink-1
122 WVPASS ln hardlink-target hardlink-2
123 WVPASS ln hardlink-target hardlink-3
126 # Add some trivial files for the index, modify, save tests.
128 WVPASS cd "$TOP/bupmeta.tmp"/src
129 WVPASS mkdir volatile
130 WVPASS touch volatile/{1,2,3}
133 # Regression test for metadata sort order. Previously, these two
134 # entries would sort in the wrong order because the metadata
135 # entries were being sorted by mangled name, but the index isn't.
136 WVPASS dd if=/dev/zero of="$TOP/bupmeta.tmp"/src/foo bs=1k count=33
137 WVPASS touch -t 201111111111 "$TOP/bupmeta.tmp"/src/foo
138 WVPASS touch -t 201112121111 "$TOP/bupmeta.tmp"/src/foo-bar
140 t/mksock "$TOP/bupmeta.tmp/src/test-socket" || true
143 # Use the test tree to check bup meta.
144 WVSTART 'meta --create/--extract'
146 WVPASS setup-test-tree
147 WVPASS cd "$TOP/bupmeta.tmp"
148 WVPASS test-src-create-extract
150 # Test a top-level file (not dir).
151 WVPASS touch src-file
152 WVPASS bup meta -cf src-file.meta src-file
155 WVPASS bup meta -xf ../src-file.meta
158 # Use the test tree to check bup save/restore metadata.
159 WVSTART 'metadata save/restore (general)'
161 WVPASS setup-test-tree
162 WVPASS cd "$TOP/bupmeta.tmp"
163 WVPASS test-src-save-restore
165 # Test a deeper subdir/ to make sure top-level non-dir metadata is
166 # restored correctly. We need at least one dir and one non-dir at
168 WVPASS test -f src/lib/__init__.py
169 WVPASS test -d src/lib/bup
170 WVPASS rm -rf src.bup
172 export BUP_DIR=$(pwd)/src.bup
174 WVPASS touch -t 201111111111 src-restore # Make sure the top won't match.
176 WVPASS bup save -t -n src src
177 WVPASS force-delete src-restore
178 WVPASS bup restore -C src-restore "/src/latest$(pwd)/src/lib/"
179 WVPASS touch -t 201211111111 src-restore # Make sure the top won't match.
180 # Check that the only difference is the top dir.
181 WVFAIL $TOP/t/compare-trees -c src/lib/ src-restore/ > tmp-compare-trees
182 WVPASSEQ $(cat tmp-compare-trees | wc -l) 2
183 WVPASS tail -n +2 tmp-compare-trees | WVPASS grep -qE '^\.d[^ ]+ \./$'
186 # Test that we pull the index (not filesystem) metadata for any
187 # unchanged files whenever we're saving other files in a given
189 WVSTART 'metadata save/restore (using index metadata)'
191 WVPASS setup-test-tree
192 WVPASS cd "$TOP/bupmeta.tmp"
194 # ...for now -- might be a problem with hardlink restores that was
195 # causing noise wrt this test.
196 WVPASS rm -rf src/hardlink*
198 # Pause here to keep the filesystem changes far enough away from
199 # the first index run that bup won't cap their index timestamps
200 # (see "bup help index" for more information). Without this
201 # sleep, the compare-trees test below "Bup should *not* pick up
202 # these metadata..." may fail.
205 WVPASS rm -rf src.bup
207 export BUP_DIR=$(pwd)/src.bup
210 WVPASS bup save -t -n src src
212 WVPASS force-delete src-restore-1
213 WVPASS mkdir src-restore-1
214 WVPASS bup restore -C src-restore-1 "/src/latest$(pwd)/"
215 WVPASS test -d src-restore-1/src
216 WVPASS "$TOP/t/compare-trees" -c src/ src-restore-1/src/
218 WVPASS echo "blarg" > src/volatile/1
219 WVPASS cp -a src/volatile/1 src-restore-1/src/volatile/
222 # Bup should *not* pick up these metadata changes.
223 WVPASS touch src/volatile/2
225 WVPASS bup save -t -n src src
227 WVPASS force-delete src-restore-2
228 WVPASS mkdir src-restore-2
229 WVPASS bup restore -C src-restore-2 "/src/latest$(pwd)/"
230 WVPASS test -d src-restore-2/src
231 WVPASS "$TOP/t/compare-trees" -c src-restore-1/src/ src-restore-2/src/
233 WVPASS rm -rf src.bup
236 setup-hardlink-test()
238 WVPASS rm -rf "$TOP/bupmeta.tmp"/src "$TOP/bupmeta.tmp"/src.bup
239 WVPASS mkdir "$TOP/bupmeta.tmp"/src "$TOP/bupmeta.tmp"/src.bup
243 hardlink-test-run-restore()
245 WVPASS force-delete src-restore
246 WVPASS mkdir src-restore
247 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
248 WVPASS test -d src-restore/src
251 # Test hardlinks more carefully.
252 WVSTART 'metadata save/restore (hardlinks)'
254 export BUP_DIR="$TOP/bupmeta.tmp/src.bup"
255 WVPASS force-delete "$TOP/bupmeta.tmp"
256 WVPASS mkdir -p "$TOP/bupmeta.tmp"
258 WVPASS cd "$TOP/bupmeta.tmp"
260 # Test trivial case - single hardlink.
261 WVPASS setup-hardlink-test
263 WVPASS cd "$TOP/bupmeta.tmp"/src
264 WVPASS touch hardlink-target
265 WVPASS ln hardlink-target hardlink-1
268 WVPASS bup save -t -n src src
269 WVPASS hardlink-test-run-restore
270 WVPASS "$TOP/t/compare-trees" -c src/ src-restore/src/
272 # Test the case where the hardlink hasn't changed, but the tree
273 # needs to be saved again. i.e. the save-cmd.py "if hashvalid:"
276 WVPASS cd "$TOP/bupmeta.tmp"/src
277 WVPASS echo whatever > something-new
280 WVPASS bup save -t -n src src
281 WVPASS hardlink-test-run-restore
282 WVPASS "$TOP/t/compare-trees" -c src/ src-restore/src/
284 # Test hardlink changes between index runs.
286 WVPASS setup-hardlink-test
287 WVPASS cd "$TOP/bupmeta.tmp"/src
288 WVPASS touch hardlink-target-a
289 WVPASS touch hardlink-target-b
290 WVPASS ln hardlink-target-a hardlink-b-1
291 WVPASS ln hardlink-target-a hardlink-a-1
293 WVPASS bup index -vv src
294 WVPASS rm src/hardlink-b-1
295 WVPASS ln src/hardlink-target-b src/hardlink-b-1
296 WVPASS bup index -vv src
297 WVPASS bup save -t -n src src
298 WVPASS hardlink-test-run-restore
299 WVPASS echo ./src/hardlink-a-1 > hardlink-sets.expected
300 WVPASS echo ./src/hardlink-target-a >> hardlink-sets.expected
301 WVPASS echo >> hardlink-sets.expected
302 WVPASS echo ./src/hardlink-b-1 >> hardlink-sets.expected
303 WVPASS echo ./src/hardlink-target-b >> hardlink-sets.expected
304 (WVPASS cd src-restore; WVPASS hardlink-sets .) > hardlink-sets.restored \
306 WVPASS diff -u hardlink-sets.expected hardlink-sets.restored
308 # Test hardlink changes between index and save -- hardlink set [a
309 # b c d] changes to [a b] [c d]. At least right now bup should
310 # notice and recreate the latter.
311 WVPASS setup-hardlink-test
312 WVPASS cd "$TOP/bupmeta.tmp"/src
318 WVPASS bup index -vv src
319 WVPASS rm src/c src/d
321 WVPASS ln src/c src/d
322 WVPASS bup save -t -n src src
323 WVPASS hardlink-test-run-restore
324 WVPASS echo ./src/a > hardlink-sets.expected
325 WVPASS echo ./src/b >> hardlink-sets.expected
326 WVPASS echo >> hardlink-sets.expected
327 WVPASS echo ./src/c >> hardlink-sets.expected
328 WVPASS echo ./src/d >> hardlink-sets.expected
329 (WVPASS cd src-restore; WVPASS hardlink-sets .) > hardlink-sets.restored \
331 WVPASS diff -u hardlink-sets.expected hardlink-sets.restored
333 # Test that we don't link outside restore tree.
334 WVPASS setup-hardlink-test
335 WVPASS cd "$TOP/bupmeta.tmp"
336 WVPASS mkdir src/a src/b
338 WVPASS ln src/a/1 src/b/1
339 WVPASS bup index -vv src
340 WVPASS bup save -t -n src src
341 WVPASS force-delete src-restore
342 WVPASS mkdir src-restore
343 WVPASS bup restore -C src-restore "/src/latest$(pwd)/src/a/"
344 WVPASS test -e src-restore/1
345 WVPASS echo -n > hardlink-sets.expected
346 (WVPASS cd src-restore; WVPASS hardlink-sets .) > hardlink-sets.restored \
348 WVPASS diff -u hardlink-sets.expected hardlink-sets.restored
350 # Test that we do link within separate sub-trees.
351 WVPASS setup-hardlink-test
352 WVPASS cd "$TOP/bupmeta.tmp"
353 WVPASS mkdir src/a src/b
355 WVPASS ln src/a/1 src/b/1
356 WVPASS bup index -vv src/a src/b
357 WVPASS bup save -t -n src src/a src/b
358 WVPASS hardlink-test-run-restore
359 WVPASS echo ./src/a/1 > hardlink-sets.expected
360 WVPASS echo ./src/b/1 >> hardlink-sets.expected
361 (WVPASS cd src-restore; WVPASS hardlink-sets .) > hardlink-sets.restored \
363 WVPASS diff -u hardlink-sets.expected hardlink-sets.restored
366 WVSTART 'meta --edit'
368 WVPASS force-delete "$TOP/bupmeta.tmp"
369 WVPASS mkdir "$TOP/bupmeta.tmp"
370 WVPASS cd "$TOP/bupmeta.tmp"
372 WVPASS bup meta -cf src.meta src
374 WVPASS bup meta --edit --set-uid 0 src.meta | WVPASS bup meta -tvvf - \
375 | WVPASS grep -qE '^uid: 0'
376 WVPASS bup meta --edit --set-uid 1000 src.meta | WVPASS bup meta -tvvf - \
377 | WVPASS grep -qE '^uid: 1000'
379 WVPASS bup meta --edit --set-gid 0 src.meta | WVPASS bup meta -tvvf - \
380 | WVPASS grep -qE '^gid: 0'
381 WVPASS bup meta --edit --set-gid 1000 src.meta | WVPASS bup meta -tvvf - \
382 | WVPASS grep -qE '^gid: 1000'
384 WVPASS bup meta --edit --set-user foo src.meta | WVPASS bup meta -tvvf - \
385 | WVPASS grep -qE '^user: foo'
386 WVPASS bup meta --edit --set-user bar src.meta | WVPASS bup meta -tvvf - \
387 | WVPASS grep -qE '^user: bar'
388 WVPASS bup meta --edit --unset-user src.meta | WVPASS bup meta -tvvf - \
389 | WVPASS grep -qE '^user:'
390 WVPASS bup meta --edit --set-user bar --unset-user src.meta \
391 | WVPASS bup meta -tvvf - | WVPASS grep -qE '^user:'
392 WVPASS bup meta --edit --unset-user --set-user bar src.meta \
393 | WVPASS bup meta -tvvf - | WVPASS grep -qE '^user: bar'
395 WVPASS bup meta --edit --set-group foo src.meta | WVPASS bup meta -tvvf - \
396 | WVPASS grep -qE '^group: foo'
397 WVPASS bup meta --edit --set-group bar src.meta | WVPASS bup meta -tvvf - \
398 | WVPASS grep -qE '^group: bar'
399 WVPASS bup meta --edit --unset-group src.meta | WVPASS bup meta -tvvf - \
400 | WVPASS grep -qE '^group:'
401 WVPASS bup meta --edit --set-group bar --unset-group src.meta \
402 | WVPASS bup meta -tvvf - | WVPASS grep -qE '^group:'
403 WVPASS bup meta --edit --unset-group --set-group bar src.meta \
404 | WVPASS bup meta -tvvf - | grep -qE '^group: bar'
407 WVSTART 'meta --no-recurse'
410 WVPASS force-delete "$TOP/bupmeta.tmp"
411 WVPASS mkdir "$TOP/bupmeta.tmp"
412 WVPASS cd "$TOP/bupmeta.tmp"
415 WVPASS touch src/foo/{1,2,3}
416 WVPASS bup meta -cf src.meta src
417 WVPASSEQ "$(LC_ALL=C; bup meta -tf src.meta | sort)" "src/
422 WVPASS bup meta --no-recurse -cf src.meta src
423 WVPASSEQ "$(LC_ALL=C; bup meta -tf src.meta | sort)" "src/"
426 # Test ownership restoration (when not root or fakeroot).
428 if [ $(t/root-status) != none ]; then
432 first_group="$(WVPASS python -c 'import os,grp; \
433 print grp.getgrgid(os.getgroups()[0])[0]')" || exit $?
434 last_group="$(python -c 'import os,grp; \
435 print grp.getgrgid(os.getgroups()[-1])[0]')" || exit $?
437 WVSTART 'metadata (restoration of ownership)'
438 WVPASS force-delete "$TOP/bupmeta.tmp"
439 WVPASS mkdir "$TOP/bupmeta.tmp"
440 WVPASS cd "$TOP/bupmeta.tmp"
442 # Some systems always assign the parent dir group to new paths
443 # (sgid). Make sure the group is one we're in.
444 WVPASS chgrp -R "$first_group" src
446 WVPASS bup meta -cf src.meta src
450 # Make sure we don't change (or try to change) the user when not root.
451 WVPASS bup meta --edit --set-user root ../src.meta | WVPASS bup meta -x
452 WVPASS bup xstat src | WVPASS grep -qvE '^user: root'
454 WVPASS bup meta --edit --unset-user --set-uid 0 ../src.meta \
456 WVPASS bup xstat src | WVPASS grep -qvE '^user: root'
458 # Make sure we can restore one of the user's groups.
460 WVPASS bup meta --edit --set-group "$last_group" ../src.meta \
462 WVPASS bup xstat src | WVPASS grep -qE "^group: $last_group"
464 # Make sure we can restore one of the user's gids.
466 last_gid="$(echo ${user_gids/* /})"
468 WVPASS bup meta --edit --unset-group --set-gid "$last_gid" ../src.meta \
470 WVPASS bup xstat src | WVPASS grep -qE "^gid: $last_gid"
472 # Test --numeric-ids (gid).
474 current_gidx=$(bup meta -tvvf ../src.meta | grep -e '^gid:')
475 WVPASS bup meta --edit --set-group "$last_group" ../src.meta \
476 | WVPASS bup meta -x --numeric-ids
477 new_gidx=$(bup xstat src | grep -e '^gid:')
478 WVPASSEQ "$current_gidx" "$new_gidx"
480 # Test that restoring an unknown user works.
481 unknown_user=$("$TOP"/t/unknown-owner --user)
483 current_uidx=$(bup meta -tvvf ../src.meta | grep -e '^uid:')
484 WVPASS bup meta --edit --set-user "$unknown_user" ../src.meta \
486 new_uidx=$(bup xstat src | grep -e '^uid:')
487 WVPASSEQ "$current_uidx" "$new_uidx"
489 # Test that restoring an unknown group works.
490 unknown_group=$("$TOP"/t/unknown-owner --group)
492 current_gidx=$(bup meta -tvvf ../src.meta | grep -e '^gid:')
493 WVPASS bup meta --edit --set-group "$unknown_group" ../src.meta \
495 new_gidx=$(bup xstat src | grep -e '^gid:')
496 WVPASSEQ "$current_gidx" "$new_gidx"
499 # Test ownership restoration (when root or fakeroot).
501 if [ $(t/root-status) = none ]; then
505 WVSTART 'metadata (restoration of ownership as root)'
506 WVPASS force-delete "$TOP/bupmeta.tmp"
507 WVPASS mkdir "$TOP/bupmeta.tmp"
508 WVPASS cd "$TOP/bupmeta.tmp"
510 WVPASS chown 0:0 src # In case the parent dir is sgid, etc.
511 WVPASS bup meta -cf src.meta src
514 WVPASS chmod 700 dest # so we can't accidentally do something insecure
517 other_uinfo="$(id-other-than --user "$(id -un)")"
518 other_user="${other_uinfo%%:*}"
519 other_uid="${other_uinfo##*:}"
521 other_ginfo="$(id-other-than --group "$(id -gn)")"
522 other_group="${other_ginfo%%:*}"
523 other_gid="${other_ginfo##*:}"
525 # Make sure we can restore a uid (must be in /etc/passwd b/c cygwin).
526 WVPASS bup meta --edit --unset-user --set-uid "$other_uid" ../src.meta \
528 WVPASS bup xstat src | WVPASS grep -qE "^uid: $other_uid"
530 # Make sure we can restore a gid (must be in /etc/group b/c cygwin).
531 WVPASS bup meta --edit --unset-group --set-gid "$other_gid" ../src.meta \
533 WVPASS bup xstat src | WVPASS grep -qE "^gid: $other_gid"
535 other_uinfo2="$(id-other-than --user "$(id -un)" "$other_user")"
536 other_user2="${other_uinfo2%%:*}"
537 other_uid2="${other_uinfo2##*:}"
539 other_ginfo2="$(id-other-than --group "$(id -gn)" "$other_group")"
540 other_group2="${other_ginfo2%%:*}"
541 other_gid2="${other_ginfo2##*:}"
543 # Try to restore a user (and see that user trumps uid when uid is not 0).
544 WVPASS bup meta --edit \
545 --set-uid "$other_uid2" --set-user "$some_user" ../src.meta \
547 WVPASS bup xstat src | WVPASS grep -qE "^user: $some_user"
549 # Try to restore a group (and see that group trumps gid when gid is not 0).
550 WVPASS bup meta --edit \
551 --set-gid "$other_gid2" --set-group "$some_group" ../src.meta \
553 WVPASS bup xstat src | WVPASS grep -qE "^group: $some_user"
555 # Test --numeric-ids (uid). Note the name 'root' is not handled
556 # specially, so we use that here as the test user name. We assume
557 # that the root user's uid is never 42.
559 WVPASS bup meta --edit --set-user root --set-uid "$other_uid" ../src.meta \
560 | WVPASS bup meta -x --numeric-ids
561 new_uidx=$(bup xstat src | grep -e '^uid:')
562 WVPASSEQ "$new_uidx" "uid: $other_uid"
564 # Test --numeric-ids (gid). Note the name 'root' is not handled
565 # specially, so we use that here as the test group name. We
566 # assume that the root group's gid is never 42.
568 WVPASS bup meta --edit --set-group root --set-gid "$other_gid" ../src.meta \
569 | WVPASS bup meta -x --numeric-ids
570 new_gidx=$(bup xstat src | grep -e '^gid:')
571 WVPASSEQ "$new_gidx" "gid: $other_gid"
573 # Test that restoring an unknown user works.
574 unknown_user=$("$TOP"/t/unknown-owners --user)
576 WVPASS bup meta --edit \
577 --set-uid "$other_uid" --set-user "$unknown_user" ../src.meta \
579 new_uidx=$(bup xstat src | grep -e '^uid:')
580 WVPASSEQ "$new_uidx" "uid: $other_uid"
582 # Test that restoring an unknown group works.
583 unknown_group=$("$TOP"/t/unknown-owners --group)
585 WVPASS bup meta --edit \
586 --set-gid "$other_gid" --set-group "$unknown_group" ../src.meta \
588 new_gidx=$(bup xstat src | grep -e '^gid:')
589 WVPASSEQ "$new_gidx" "gid: $other_gid"
591 if ! [[ $(uname) =~ CYGWIN ]]; then
592 # For now, skip these on Cygwin because it doesn't allow
593 # restoring an unknown uid/gid.
595 # Make sure a uid of 0 trumps a non-root user.
596 WVPASS bup meta --edit --set-user "$some_user" ../src.meta \
598 WVPASS bup xstat src | WVPASS grep -qvE "^user: $some_user"
599 WVPASS bup xstat src | WVPASS grep -qE "^uid: 0"
601 # Make sure a gid of 0 trumps a non-root group.
602 WVPASS bup meta --edit --set-group "$some_user" ../src.meta \
604 WVPASS bup xstat src | WVPASS grep -qvE "^group: $some_group"
605 WVPASS bup xstat src | WVPASS grep -qE "^gid: 0"
610 # Root-only tests that require an FS with all the trimmings: ACLs,
611 # Linux attr, Linux xattr, etc.
612 if [ $(t/root-status) = root ]; then
614 # Some cleanup handled in universal-cleanup() above.
615 # These tests are only likely to work under Linux for now
617 [[ $(uname) =~ Linux ]] || exit 0
619 WVSTART 'meta - general (as root)'
620 WVPASS setup-test-tree
621 WVPASS cd "$TOP/bupmeta.tmp"
624 WVPASS dd if=/dev/zero of=testfs.img bs=1M count=32
625 # Make sure we have all the options the chattr test needs
626 # (i.e. create a "normal" ext4 filesystem).
627 WVPASS mke2fs -F -m 0 \
629 -O has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize \
632 WVPASS mount -o loop,acl,user_xattr testfs.img testfs
633 # Hide, so that tests can't create risks.
634 WVPASS chown root:root testfs
635 WVPASS chmod 0700 testfs
637 umount testfs-limited
638 WVPASS dd if=/dev/zero of=testfs-limited.img bs=1M count=32
639 WVPASS mkfs -t vfat testfs-limited.img
640 WVPASS mkdir testfs-limited
641 WVPASS mount -o loop,uid=root,gid=root,umask=0077 \
642 testfs-limited.img testfs-limited
644 WVPASS cp -pPR src testfs/src
645 (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
647 WVSTART 'meta - atime (as root)'
648 WVPASS force-delete testfs/src
649 WVPASS mkdir testfs/src
651 WVPASS mkdir testfs/src/foo
652 WVPASS touch testfs/src/bar
653 PYTHONPATH="$TOP/lib" \
654 WVPASS python -c "from bup import xstat; \
655 x = xstat.timespec_to_nsecs((42, 0));\
656 xstat.utime('testfs/src/foo', (x, x));\
657 xstat.utime('testfs/src/bar', (x, x));"
659 WVPASS bup meta -v --create --recurse --file src.meta src
660 WVPASS bup meta -tvf src.meta
662 WVPASS force-delete src-restore
663 WVPASS mkdir src-restore
664 WVPASS cd src-restore
665 WVPASS bup meta --extract --file ../src.meta
666 WVPASSEQ "$(bup xstat --include-fields=atime src/foo)" "atime: 42"
667 WVPASSEQ "$(bup xstat --include-fields=atime src/bar)" "atime: 42"
668 # Test start/finish extract.
669 WVPASS force-delete src
670 WVPASS bup meta --start-extract --file ../src.meta
672 WVPASS bup meta --finish-extract --file ../src.meta
673 WVPASSEQ "$(bup xstat --include-fields=atime src/foo)" "atime: 42"
674 WVPASSEQ "$(bup xstat --include-fields=atime src/bar)" "atime: 42"
677 WVSTART 'meta - Linux attr (as root)'
678 WVPASS force-delete testfs/src
679 WVPASS mkdir testfs/src
681 WVPASS touch testfs/src/foo
682 WVPASS mkdir testfs/src/bar
683 WVPASS chattr +acdeijstuADST testfs/src/foo
684 WVPASS chattr +acdeijstuADST testfs/src/bar
685 (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
686 # Test restoration to a limited filesystem (vfat).
688 WVPASS bup meta --create --recurse --file testfs/src.meta \
690 WVPASS force-delete testfs-limited/src-restore
691 WVPASS mkdir testfs-limited/src-restore
692 WVPASS cd testfs-limited/src-restore
693 WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
694 | WVPASS grep -e '^Linux chattr:' \
696 'import sys; exit(not len(sys.stdin.readlines()) == 3)'
700 WVSTART 'meta - Linux xattr (as root)'
701 WVPASS force-delete testfs/src
702 WVPASS mkdir testfs/src
703 WVPASS touch testfs/src/foo
704 WVPASS mkdir testfs/src/bar
705 WVPASS attr -s foo -V bar testfs/src/foo
706 WVPASS attr -s foo -V bar testfs/src/bar
707 (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
709 # Test restoration to a limited filesystem (vfat).
711 WVPASS bup meta --create --recurse --file testfs/src.meta \
713 WVPASS force-delete testfs-limited/src-restore
714 WVPASS mkdir testfs-limited/src-restore
715 WVPASS cd testfs-limited/src-restore
716 WVFAIL bup meta --extract --file ../../testfs/src.meta
717 WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
718 | WVPASS grep -e "^xattr\.set '" \
720 'import sys; exit(not len(sys.stdin.readlines()) == 2)'
723 WVSTART 'meta - POSIX.1e ACLs (as root)'
724 WVPASS force-delete testfs/src
725 WVPASS mkdir testfs/src
726 WVPASS touch testfs/src/foo
727 WVPASS mkdir testfs/src/bar
728 WVPASS setfacl -m u:root:r testfs/src/foo
729 WVPASS setfacl -m u:root:r testfs/src/bar
730 (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
732 # Test restoration to a limited filesystem (vfat).
734 WVPASS bup meta --create --recurse --file testfs/src.meta \
736 WVPASS force-delete testfs-limited/src-restore
737 WVPASS mkdir testfs-limited/src-restore
738 WVPASS cd testfs-limited/src-restore
739 WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
740 | WVPASS grep -e '^POSIX1e ACL applyto:' \
742 'import sys; exit(not len(sys.stdin.readlines()) == 2)'