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 uid=$(WVPASS id -un) || exit $?
506 gid=$(WVPASS id -gn) || exit $?
508 WVSTART 'metadata (restoration of ownership as root)'
509 WVPASS force-delete "$TOP/bupmeta.tmp"
510 WVPASS mkdir "$TOP/bupmeta.tmp"
511 WVPASS cd "$TOP/bupmeta.tmp"
513 WVPASS chown "$uid:$gid" src # In case the parent dir is sgid, etc.
514 WVPASS bup meta -cf src.meta src
517 WVPASS chmod 700 dest # so we can't accidentally do something insecure
520 other_uinfo="$(id-other-than --user "$uid")"
521 other_user="${other_uinfo%%:*}"
522 other_uid="${other_uinfo##*:}"
524 other_ginfo="$(id-other-than --group "$gid")"
525 other_group="${other_ginfo%%:*}"
526 other_gid="${other_ginfo##*:}"
528 # Make sure we can restore a uid (must be in /etc/passwd b/c cygwin).
529 WVPASS bup meta --edit --unset-user --set-uid "$other_uid" ../src.meta \
531 WVPASS bup xstat src | WVPASS grep -qE "^uid: $other_uid"
533 # Make sure we can restore a gid (must be in /etc/group b/c cygwin).
534 WVPASS bup meta --edit --unset-group --set-gid "$other_gid" ../src.meta \
536 WVPASS bup xstat src | WVPASS grep -qE "^gid: $other_gid"
538 other_uinfo2="$(id-other-than --user "$(id -un)" "$other_user")"
539 other_user2="${other_uinfo2%%:*}"
540 other_uid2="${other_uinfo2##*:}"
542 other_ginfo2="$(id-other-than --group "$(id -gn)" "$other_group")"
543 other_group2="${other_ginfo2%%:*}"
544 other_gid2="${other_ginfo2##*:}"
546 # Try to restore a user (and see that user trumps uid when uid is not 0).
547 WVPASS bup meta --edit \
548 --set-uid "$other_uid2" --set-user "$some_user" ../src.meta \
550 WVPASS bup xstat src | WVPASS grep -qE "^user: $some_user"
552 # Try to restore a group (and see that group trumps gid when gid is not 0).
553 WVPASS bup meta --edit \
554 --set-gid "$other_gid2" --set-group "$some_group" ../src.meta \
556 WVPASS bup xstat src | WVPASS grep -qE "^group: $some_user"
558 # Test --numeric-ids (uid). Note the name 'root' is not handled
559 # specially, so we use that here as the test user name. We assume
560 # that the root user's uid is never 42.
562 WVPASS bup meta --edit --set-user root --set-uid "$other_uid" ../src.meta \
563 | WVPASS bup meta -x --numeric-ids
564 new_uidx=$(bup xstat src | grep -e '^uid:')
565 WVPASSEQ "$new_uidx" "uid: $other_uid"
567 # Test --numeric-ids (gid). Note the name 'root' is not handled
568 # specially, so we use that here as the test group name. We
569 # assume that the root group's gid is never 42.
571 WVPASS bup meta --edit --set-group root --set-gid "$other_gid" ../src.meta \
572 | WVPASS bup meta -x --numeric-ids
573 new_gidx=$(bup xstat src | grep -e '^gid:')
574 WVPASSEQ "$new_gidx" "gid: $other_gid"
576 # Test that restoring an unknown user works.
577 unknown_user=$("$TOP"/t/unknown-owners --user)
579 WVPASS bup meta --edit \
580 --set-uid "$other_uid" --set-user "$unknown_user" ../src.meta \
582 new_uidx=$(bup xstat src | grep -e '^uid:')
583 WVPASSEQ "$new_uidx" "uid: $other_uid"
585 # Test that restoring an unknown group works.
586 unknown_group=$("$TOP"/t/unknown-owners --group)
588 WVPASS bup meta --edit \
589 --set-gid "$other_gid" --set-group "$unknown_group" ../src.meta \
591 new_gidx=$(bup xstat src | grep -e '^gid:')
592 WVPASSEQ "$new_gidx" "gid: $other_gid"
594 if ! [[ $(uname) =~ CYGWIN ]]; then
595 # For now, skip these on Cygwin because it doesn't allow
596 # restoring an unknown uid/gid.
598 # Make sure a uid of 0 trumps a non-root user.
599 WVPASS bup meta --edit --set-user "$some_user" ../src.meta \
601 WVPASS bup xstat src | WVPASS grep -qvE "^user: $some_user"
602 WVPASS bup xstat src | WVPASS grep -qE "^uid: 0"
604 # Make sure a gid of 0 trumps a non-root group.
605 WVPASS bup meta --edit --set-group "$some_user" ../src.meta \
607 WVPASS bup xstat src | WVPASS grep -qvE "^group: $some_group"
608 WVPASS bup xstat src | WVPASS grep -qE "^gid: 0"
613 # Root-only tests that require an FS with all the trimmings: ACLs,
614 # Linux attr, Linux xattr, etc.
615 if [ $(t/root-status) = root ]; then
617 # Some cleanup handled in universal-cleanup() above.
618 # These tests are only likely to work under Linux for now
620 [[ $(uname) =~ Linux ]] || exit 0
622 WVSTART 'meta - general (as root)'
623 WVPASS setup-test-tree
624 WVPASS cd "$TOP/bupmeta.tmp"
627 WVPASS dd if=/dev/zero of=testfs.img bs=1M count=32
628 # Make sure we have all the options the chattr test needs
629 # (i.e. create a "normal" ext4 filesystem).
630 WVPASS mke2fs -F -m 0 \
632 -O has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize \
635 WVPASS mount -o loop,acl,user_xattr testfs.img testfs
636 # Hide, so that tests can't create risks.
637 WVPASS chown root:root testfs
638 WVPASS chmod 0700 testfs
640 umount testfs-limited
641 WVPASS dd if=/dev/zero of=testfs-limited.img bs=1M count=32
642 WVPASS mkfs -t vfat testfs-limited.img
643 WVPASS mkdir testfs-limited
644 WVPASS mount -o loop,uid=root,gid=root,umask=0077 \
645 testfs-limited.img testfs-limited
647 WVPASS cp -pPR src testfs/src
648 (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
650 WVSTART 'meta - atime (as root)'
651 WVPASS force-delete testfs/src
652 WVPASS mkdir testfs/src
654 WVPASS mkdir testfs/src/foo
655 WVPASS touch testfs/src/bar
656 PYTHONPATH="$TOP/lib" \
657 WVPASS python -c "from bup import xstat; \
658 x = xstat.timespec_to_nsecs((42, 0));\
659 xstat.utime('testfs/src/foo', (x, x));\
660 xstat.utime('testfs/src/bar', (x, x));"
662 WVPASS bup meta -v --create --recurse --file src.meta src
663 WVPASS bup meta -tvf src.meta
665 WVPASS force-delete src-restore
666 WVPASS mkdir src-restore
667 WVPASS cd src-restore
668 WVPASS bup meta --extract --file ../src.meta
669 WVPASSEQ "$(bup xstat --include-fields=atime src/foo)" "atime: 42"
670 WVPASSEQ "$(bup xstat --include-fields=atime src/bar)" "atime: 42"
671 # Test start/finish extract.
672 WVPASS force-delete src
673 WVPASS bup meta --start-extract --file ../src.meta
675 WVPASS bup meta --finish-extract --file ../src.meta
676 WVPASSEQ "$(bup xstat --include-fields=atime src/foo)" "atime: 42"
677 WVPASSEQ "$(bup xstat --include-fields=atime src/bar)" "atime: 42"
680 WVSTART 'meta - Linux attr (as root)'
681 WVPASS force-delete testfs/src
682 WVPASS mkdir testfs/src
684 WVPASS touch testfs/src/foo
685 WVPASS mkdir testfs/src/bar
686 WVPASS chattr +acdeijstuADST testfs/src/foo
687 WVPASS chattr +acdeijstuADST testfs/src/bar
688 (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
689 # Test restoration to a limited filesystem (vfat).
691 WVPASS bup meta --create --recurse --file testfs/src.meta \
693 WVPASS force-delete testfs-limited/src-restore
694 WVPASS mkdir testfs-limited/src-restore
695 WVPASS cd testfs-limited/src-restore
696 WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
697 | WVPASS grep -e '^Linux chattr:' \
699 'import sys; exit(not len(sys.stdin.readlines()) == 3)'
703 WVSTART 'meta - Linux xattr (as root)'
704 WVPASS force-delete testfs/src
705 WVPASS mkdir testfs/src
706 WVPASS touch testfs/src/foo
707 WVPASS mkdir testfs/src/bar
708 WVPASS attr -s foo -V bar testfs/src/foo
709 WVPASS attr -s foo -V bar testfs/src/bar
710 (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
712 # Test restoration to a limited filesystem (vfat).
714 WVPASS bup meta --create --recurse --file testfs/src.meta \
716 WVPASS force-delete testfs-limited/src-restore
717 WVPASS mkdir testfs-limited/src-restore
718 WVPASS cd testfs-limited/src-restore
719 WVFAIL bup meta --extract --file ../../testfs/src.meta
720 WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
721 | WVPASS grep -e "^xattr\.set '" \
723 'import sys; exit(not len(sys.stdin.readlines()) == 2)'
726 WVSTART 'meta - POSIX.1e ACLs (as root)'
727 WVPASS force-delete testfs/src
728 WVPASS mkdir testfs/src
729 WVPASS touch testfs/src/foo
730 WVPASS mkdir testfs/src/bar
731 WVPASS setfacl -m u:root:r testfs/src/foo
732 WVPASS setfacl -m u:root:r testfs/src/bar
733 (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
735 # Test restoration to a limited filesystem (vfat).
737 WVPASS bup meta --create --recurse --file testfs/src.meta \
739 WVPASS force-delete testfs-limited/src-restore
740 WVPASS mkdir testfs-limited/src-restore
741 WVPASS cd testfs-limited/src-restore
742 WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
743 | WVPASS grep -e '^POSIX1e ACL applyto:' \
745 'import sys; exit(not len(sys.stdin.readlines()) == 2)'