7 TOP="$(WVPASS pwd)" || exit $?
8 export BUP_DIR="$TOP/buptest.tmp"
17 "$TOP/t/hardlink-sets" "$@"
22 "$TOP/t/id-other-than" "$@"
25 # Very simple metadata tests -- create a test tree then check that bup
26 # meta can reproduce the metadata correctly (according to bup xstat)
27 # via create, extract, start-extract, and finish-extract. The current
28 # tests are crude, and this does not fully test devices, varying
29 # users/groups, acls, attrs, etc.
34 export PATH="$TOP:$PATH" # pick up bup
35 # Skip atime (test elsewhere) to avoid the observer effect.
36 WVPASS find . | WVPASS sort \
37 | WVPASS xargs bup xstat --exclude-fields ctime,atime,size
41 test-src-create-extract()
43 # Test bup meta create/extract for ./src -> ./src-restore.
44 # Also writes to ./src-stat and ./src-restore-stat.
46 (WVPASS cd src; WVPASS genstat) > src-stat || exit $?
47 WVPASS bup meta --create --recurse --file src.meta src
49 WVPASS force-delete src-restore
50 WVPASS mkdir src-restore
52 WVPASS bup meta --extract --file ../src.meta
54 (WVPASS cd src; WVPASS genstat >../../src-restore-stat) || exit $?
55 WVPASS diff -U5 ../src-stat ../src-restore-stat
56 # Test start/finish extract.
57 WVPASS force-delete src
58 WVPASS bup meta --start-extract --file ../src.meta
60 WVPASS bup meta --finish-extract --file ../src.meta
61 (WVPASS cd src; WVPASS genstat >../../src-restore-stat) || exit $?
62 WVPASS diff -U5 ../src-stat ../src-restore-stat
66 test-src-save-restore()
68 # Test bup save/restore metadata for ./src -> ./src-restore. Also
69 # writes to ./src.bup. Note that for now this just tests the
70 # restore below src/, in order to avoid having to worry about
71 # operations that require root (like chown /home).
75 export BUP_DIR=$(pwd)/src.bup
78 WVPASS bup save -t -n src src
80 WVPASS force-delete src-restore
81 WVPASS mkdir src-restore
82 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
83 WVPASS test -d src-restore/src
84 WVPASS "$TOP/t/compare-trees" -c src/ src-restore/src/
91 if [ $(t/root-status) != root ]; then return 0; fi
92 umount "$TOP/bupmeta.tmp/testfs" || true
93 umount "$TOP/bupmeta.tmp/testfs-limited" || true
96 WVPASS universal-cleanup
97 trap universal-cleanup EXIT
101 WVPASS force-delete "$BUP_DIR"
102 WVPASS force-delete "$TOP/bupmeta.tmp"
103 WVPASS mkdir -p "$TOP/bupmeta.tmp/src"
104 WVPASS cp -pPR Documentation cmd lib t "$TOP/bupmeta.tmp"/src
106 # Add some hard links for the general tests.
108 WVPASS cd "$TOP/bupmeta.tmp"/src
109 WVPASS touch hardlink-target
110 WVPASS ln hardlink-target hardlink-1
111 WVPASS ln hardlink-target hardlink-2
112 WVPASS ln hardlink-target hardlink-3
115 # Add some trivial files for the index, modify, save tests.
117 WVPASS cd "$TOP/bupmeta.tmp"/src
118 WVPASS mkdir volatile
119 WVPASS touch volatile/{1,2,3}
122 # Regression test for metadata sort order. Previously, these two
123 # entries would sort in the wrong order because the metadata
124 # entries were being sorted by mangled name, but the index isn't.
125 WVPASS dd if=/dev/zero of="$TOP/bupmeta.tmp"/src/foo bs=1k count=33
126 WVPASS touch -t 201111111111 "$TOP/bupmeta.tmp"/src/foo
127 WVPASS touch -t 201112121111 "$TOP/bupmeta.tmp"/src/foo-bar
129 t/mksock "$TOP/bupmeta.tmp/src/test-socket" || true
132 # Use the test tree to check bup meta.
133 WVSTART 'meta --create/--extract'
135 WVPASS setup-test-tree
136 WVPASS cd "$TOP/bupmeta.tmp"
137 WVPASS test-src-create-extract
139 # Test a top-level file (not dir).
140 WVPASS touch src-file
141 WVPASS bup meta -cf src-file.meta src-file
144 WVPASS bup meta -xf ../src-file.meta
147 # Use the test tree to check bup save/restore metadata.
148 WVSTART 'metadata save/restore (general)'
150 WVPASS setup-test-tree
151 WVPASS cd "$TOP/bupmeta.tmp"
152 WVPASS test-src-save-restore
154 # Test a deeper subdir/ to make sure top-level non-dir metadata is
155 # restored correctly. We need at least one dir and one non-dir at
157 WVPASS test -f src/lib/__init__.py
158 WVPASS test -d src/lib/bup
159 WVPASS rm -rf src.bup
161 export BUP_DIR=$(pwd)/src.bup
163 WVPASS touch -t 201111111111 src-restore # Make sure the top won't match.
165 WVPASS bup save -t -n src src
166 WVPASS force-delete src-restore
167 WVPASS bup restore -C src-restore "/src/latest$(pwd)/src/lib/"
168 WVPASS touch -t 201211111111 src-restore # Make sure the top won't match.
169 # Check that the only difference is the top dir.
170 WVFAIL $TOP/t/compare-trees -c src/lib/ src-restore/ > tmp-compare-trees
171 WVPASSEQ $(cat tmp-compare-trees | wc -l) 2
172 WVPASS tail -n +2 tmp-compare-trees | WVPASS grep -qE '^\.d[^ ]+ \./$'
175 # Test that we pull the index (not filesystem) metadata for any
176 # unchanged files whenever we're saving other files in a given
178 WVSTART 'metadata save/restore (using index metadata)'
180 WVPASS setup-test-tree
181 WVPASS cd "$TOP/bupmeta.tmp"
183 # ...for now -- might be a problem with hardlink restores that was
184 # causing noise wrt this test.
185 WVPASS rm -rf src/hardlink*
187 # Pause here to keep the filesystem changes far enough away from
188 # the first index run that bup won't cap their index timestamps
189 # (see "bup help index" for more information). Without this
190 # sleep, the compare-trees test below "Bup should *not* pick up
191 # these metadata..." may fail.
194 WVPASS rm -rf src.bup
196 export BUP_DIR=$(pwd)/src.bup
199 WVPASS bup save -t -n src src
201 WVPASS force-delete src-restore-1
202 WVPASS mkdir src-restore-1
203 WVPASS bup restore -C src-restore-1 "/src/latest$(pwd)/"
204 WVPASS test -d src-restore-1/src
205 WVPASS "$TOP/t/compare-trees" -c src/ src-restore-1/src/
207 WVPASS echo "blarg" > src/volatile/1
208 WVPASS cp -a src/volatile/1 src-restore-1/src/volatile/
211 # Bup should *not* pick up these metadata changes.
212 WVPASS touch src/volatile/2
214 WVPASS bup save -t -n src src
216 WVPASS force-delete src-restore-2
217 WVPASS mkdir src-restore-2
218 WVPASS bup restore -C src-restore-2 "/src/latest$(pwd)/"
219 WVPASS test -d src-restore-2/src
220 WVPASS "$TOP/t/compare-trees" -c src-restore-1/src/ src-restore-2/src/
222 WVPASS rm -rf src.bup
225 setup-hardlink-test()
227 WVPASS rm -rf "$TOP/bupmeta.tmp"/src "$TOP/bupmeta.tmp"/src.bup
228 WVPASS mkdir "$TOP/bupmeta.tmp"/src "$TOP/bupmeta.tmp"/src.bup
232 hardlink-test-run-restore()
234 WVPASS force-delete src-restore
235 WVPASS mkdir src-restore
236 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
237 WVPASS test -d src-restore/src
240 # Test hardlinks more carefully.
241 WVSTART 'metadata save/restore (hardlinks)'
243 export BUP_DIR="$TOP/bupmeta.tmp/src.bup"
244 WVPASS force-delete "$TOP/bupmeta.tmp"
245 WVPASS mkdir -p "$TOP/bupmeta.tmp"
247 WVPASS cd "$TOP/bupmeta.tmp"
249 # Test trivial case - single hardlink.
250 WVPASS setup-hardlink-test
252 WVPASS cd "$TOP/bupmeta.tmp"/src
253 WVPASS touch hardlink-target
254 WVPASS ln hardlink-target hardlink-1
257 WVPASS bup save -t -n src src
258 WVPASS hardlink-test-run-restore
259 WVPASS "$TOP/t/compare-trees" -c src/ src-restore/src/
261 # Test the case where the hardlink hasn't changed, but the tree
262 # needs to be saved again. i.e. the save-cmd.py "if hashvalid:"
265 WVPASS cd "$TOP/bupmeta.tmp"/src
266 WVPASS echo whatever > something-new
269 WVPASS bup save -t -n src src
270 WVPASS hardlink-test-run-restore
271 WVPASS "$TOP/t/compare-trees" -c src/ src-restore/src/
273 # Test hardlink changes between index runs.
275 WVPASS setup-hardlink-test
276 WVPASS cd "$TOP/bupmeta.tmp"/src
277 WVPASS touch hardlink-target-a
278 WVPASS touch hardlink-target-b
279 WVPASS ln hardlink-target-a hardlink-b-1
280 WVPASS ln hardlink-target-a hardlink-a-1
282 WVPASS bup index -vv src
283 WVPASS rm src/hardlink-b-1
284 WVPASS ln src/hardlink-target-b src/hardlink-b-1
285 WVPASS bup index -vv src
286 WVPASS bup save -t -n src src
287 WVPASS hardlink-test-run-restore
288 WVPASS echo ./src/hardlink-a-1 > hardlink-sets.expected
289 WVPASS echo ./src/hardlink-target-a >> hardlink-sets.expected
290 WVPASS echo >> hardlink-sets.expected
291 WVPASS echo ./src/hardlink-b-1 >> hardlink-sets.expected
292 WVPASS echo ./src/hardlink-target-b >> hardlink-sets.expected
293 (WVPASS cd src-restore; WVPASS hardlink-sets .) > hardlink-sets.restored \
295 WVPASS diff -u hardlink-sets.expected hardlink-sets.restored
297 # Test hardlink changes between index and save -- hardlink set [a
298 # b c d] changes to [a b] [c d]. At least right now bup should
299 # notice and recreate the latter.
300 WVPASS setup-hardlink-test
301 WVPASS cd "$TOP/bupmeta.tmp"/src
307 WVPASS bup index -vv src
308 WVPASS rm src/c src/d
310 WVPASS ln src/c src/d
311 WVPASS bup save -t -n src src
312 WVPASS hardlink-test-run-restore
313 WVPASS echo ./src/a > hardlink-sets.expected
314 WVPASS echo ./src/b >> hardlink-sets.expected
315 WVPASS echo >> hardlink-sets.expected
316 WVPASS echo ./src/c >> hardlink-sets.expected
317 WVPASS echo ./src/d >> hardlink-sets.expected
318 (WVPASS cd src-restore; WVPASS hardlink-sets .) > hardlink-sets.restored \
320 WVPASS diff -u hardlink-sets.expected hardlink-sets.restored
322 # Test that we don't link outside restore tree.
323 WVPASS setup-hardlink-test
324 WVPASS cd "$TOP/bupmeta.tmp"
325 WVPASS mkdir src/a src/b
327 WVPASS ln src/a/1 src/b/1
328 WVPASS bup index -vv src
329 WVPASS bup save -t -n src src
330 WVPASS force-delete src-restore
331 WVPASS mkdir src-restore
332 WVPASS bup restore -C src-restore "/src/latest$(pwd)/src/a/"
333 WVPASS test -e src-restore/1
334 WVPASS echo -n > hardlink-sets.expected
335 (WVPASS cd src-restore; WVPASS hardlink-sets .) > hardlink-sets.restored \
337 WVPASS diff -u hardlink-sets.expected hardlink-sets.restored
339 # Test that we do link within separate sub-trees.
340 WVPASS setup-hardlink-test
341 WVPASS cd "$TOP/bupmeta.tmp"
342 WVPASS mkdir src/a src/b
344 WVPASS ln src/a/1 src/b/1
345 WVPASS bup index -vv src/a src/b
346 WVPASS bup save -t -n src src/a src/b
347 WVPASS hardlink-test-run-restore
348 WVPASS echo ./src/a/1 > hardlink-sets.expected
349 WVPASS echo ./src/b/1 >> hardlink-sets.expected
350 (WVPASS cd src-restore; WVPASS hardlink-sets .) > hardlink-sets.restored \
352 WVPASS diff -u hardlink-sets.expected hardlink-sets.restored
355 WVSTART 'meta --edit'
357 WVPASS force-delete "$TOP/bupmeta.tmp"
358 WVPASS mkdir "$TOP/bupmeta.tmp"
359 WVPASS cd "$TOP/bupmeta.tmp"
361 WVPASS bup meta -cf src.meta src
363 WVPASS bup meta --edit --set-uid 0 src.meta | WVPASS bup meta -tvvf - \
364 | WVPASS grep -qE '^uid: 0'
365 WVPASS bup meta --edit --set-uid 1000 src.meta | WVPASS bup meta -tvvf - \
366 | WVPASS grep -qE '^uid: 1000'
368 WVPASS bup meta --edit --set-gid 0 src.meta | WVPASS bup meta -tvvf - \
369 | WVPASS grep -qE '^gid: 0'
370 WVPASS bup meta --edit --set-gid 1000 src.meta | WVPASS bup meta -tvvf - \
371 | WVPASS grep -qE '^gid: 1000'
373 WVPASS bup meta --edit --set-user foo src.meta | WVPASS bup meta -tvvf - \
374 | WVPASS grep -qE '^user: foo'
375 WVPASS bup meta --edit --set-user bar src.meta | WVPASS bup meta -tvvf - \
376 | WVPASS grep -qE '^user: bar'
377 WVPASS bup meta --edit --unset-user src.meta | WVPASS bup meta -tvvf - \
378 | WVPASS grep -qE '^user:'
379 WVPASS bup meta --edit --set-user bar --unset-user src.meta \
380 | WVPASS bup meta -tvvf - | WVPASS grep -qE '^user:'
381 WVPASS bup meta --edit --unset-user --set-user bar src.meta \
382 | WVPASS bup meta -tvvf - | WVPASS grep -qE '^user: bar'
384 WVPASS bup meta --edit --set-group foo src.meta | WVPASS bup meta -tvvf - \
385 | WVPASS grep -qE '^group: foo'
386 WVPASS bup meta --edit --set-group bar src.meta | WVPASS bup meta -tvvf - \
387 | WVPASS grep -qE '^group: bar'
388 WVPASS bup meta --edit --unset-group src.meta | WVPASS bup meta -tvvf - \
389 | WVPASS grep -qE '^group:'
390 WVPASS bup meta --edit --set-group bar --unset-group src.meta \
391 | WVPASS bup meta -tvvf - | WVPASS grep -qE '^group:'
392 WVPASS bup meta --edit --unset-group --set-group bar src.meta \
393 | WVPASS bup meta -tvvf - | grep -qE '^group: bar'
396 WVSTART 'meta --no-recurse'
399 WVPASS force-delete "$TOP/bupmeta.tmp"
400 WVPASS mkdir "$TOP/bupmeta.tmp"
401 WVPASS cd "$TOP/bupmeta.tmp"
404 WVPASS touch src/foo/{1,2,3}
405 WVPASS bup meta -cf src.meta src
406 WVPASSEQ "$(LC_ALL=C; bup meta -tf src.meta | sort)" "src/
411 WVPASS bup meta --no-recurse -cf src.meta src
412 WVPASSEQ "$(LC_ALL=C; bup meta -tf src.meta | sort)" "src/"
415 # Test ownership restoration (when not root or fakeroot).
417 if [ $(t/root-status) != none ]; then
421 WVSTART 'metadata (restoration of ownership)'
422 WVPASS force-delete "$TOP/bupmeta.tmp"
423 WVPASS mkdir "$TOP/bupmeta.tmp"
424 WVPASS cd "$TOP/bupmeta.tmp"
426 WVPASS bup meta -cf src.meta src
430 # Make sure we don't change (or try to change) the user when not root.
431 WVPASS bup meta --edit --set-user root ../src.meta | WVPASS bup meta -x
432 WVPASS bup xstat src | WVPASS grep -qvE '^user: root'
434 WVPASS bup meta --edit --unset-user --set-uid 0 ../src.meta \
436 WVPASS bup xstat src | grep -qvE '^user: root'
438 # Make sure we can restore one of the user's groups.
439 last_group="$(python -c 'import os,grp; \
440 print grp.getgrgid(os.getgroups()[0])[0]')"
442 WVPASS bup meta --edit --set-group "$last_group" ../src.meta \
444 WVPASS bup xstat src | WVPASS grep -qE "^group: $last_group"
446 # Make sure we can restore one of the user's gids.
448 last_gid="$(echo ${user_gids/* /})"
450 WVPASS bup meta --edit --unset-group --set-gid "$last_gid" ../src.meta \
452 WVPASS bup xstat src | WVPASS grep -qE "^gid: $last_gid"
454 # Test --numeric-ids (gid).
456 current_gidx=$(bup meta -tvvf ../src.meta | grep -e '^gid:')
457 WVPASS bup meta --edit --set-group "$last_group" ../src.meta \
458 | WVPASS bup meta -x --numeric-ids
459 new_gidx=$(bup xstat src | grep -e '^gid:')
460 WVPASSEQ "$current_gidx" "$new_gidx"
462 # Test that restoring an unknown user works.
463 unknown_user=$("$TOP"/t/unknown-owner --user)
465 current_uidx=$(bup meta -tvvf ../src.meta | grep -e '^uid:')
466 WVPASS bup meta --edit --set-user "$unknown_user" ../src.meta \
468 new_uidx=$(bup xstat src | grep -e '^uid:')
469 WVPASSEQ "$current_uidx" "$new_uidx"
471 # Test that restoring an unknown group works.
472 unknown_group=$("$TOP"/t/unknown-owner --group)
474 current_gidx=$(bup meta -tvvf ../src.meta | grep -e '^gid:')
475 WVPASS bup meta --edit --set-group "$unknown_group" ../src.meta \
477 new_gidx=$(bup xstat src | grep -e '^gid:')
478 WVPASSEQ "$current_gidx" "$new_gidx"
481 # Test ownership restoration (when root or fakeroot).
483 if [ $(t/root-status) == none ]; then
487 WVSTART 'metadata (restoration of ownership as root)'
488 WVPASS force-delete "$TOP/bupmeta.tmp"
489 WVPASS mkdir "$TOP/bupmeta.tmp"
490 WVPASS cd "$TOP/bupmeta.tmp"
492 WVPASS chown 0:0 src # In case the parent dir is sgid, etc.
493 WVPASS bup meta -cf src.meta src
496 WVPASS chmod 700 dest # so we can't accidentally do something insecure
499 other_uinfo="$(id-other-than --user "$(id -un)")"
500 other_user="${other_uinfo%%:*}"
501 other_uid="${other_uinfo##*:}"
503 other_ginfo="$(id-other-than --group "$(id -gn)")"
504 other_group="${other_ginfo%%:*}"
505 other_gid="${other_ginfo##*:}"
507 # Make sure we can restore a uid (must be in /etc/passwd b/c cygwin).
508 WVPASS bup meta --edit --unset-user --set-uid "$other_uid" ../src.meta \
510 WVPASS bup xstat src | WVPASS grep -qE "^uid: $other_uid"
512 # Make sure we can restore a gid (must be in /etc/group b/c cygwin).
513 WVPASS bup meta --edit --unset-group --set-gid "$other_gid" ../src.meta \
515 WVPASS bup xstat src | WVPASS grep -qE "^gid: $other_gid"
517 other_uinfo2="$(id-other-than --user "$(id -un)" "$other_user")"
518 other_user2="${other_uinfo2%%:*}"
519 other_uid2="${other_uinfo2##*:}"
521 other_ginfo2="$(id-other-than --group "$(id -gn)" "$other_group")"
522 other_group2="${other_ginfo2%%:*}"
523 other_gid2="${other_ginfo2##*:}"
525 # Try to restore a user (and see that user trumps uid when uid is not 0).
526 WVPASS bup meta --edit \
527 --set-uid "$other_uid2" --set-user "$some_user" ../src.meta \
529 WVPASS bup xstat src | WVPASS grep -qE "^user: $some_user"
531 # Try to restore a group (and see that group trumps gid when gid is not 0).
532 WVPASS bup meta --edit \
533 --set-gid "$other_gid2" --set-group "$some_group" ../src.meta \
535 WVPASS bup xstat src | WVPASS grep -qE "^group: $some_user"
537 # Test --numeric-ids (uid). Note the name 'root' is not handled
538 # specially, so we use that here as the test user name. We assume
539 # that the root user's uid is never 42.
541 WVPASS bup meta --edit --set-user root --set-uid "$other_uid" ../src.meta \
542 | WVPASS bup meta -x --numeric-ids
543 new_uidx=$(bup xstat src | grep -e '^uid:')
544 WVPASSEQ "$new_uidx" "uid: $other_uid"
546 # Test --numeric-ids (gid). Note the name 'root' is not handled
547 # specially, so we use that here as the test group name. We
548 # assume that the root group's gid is never 42.
550 WVPASS bup meta --edit --set-group root --set-gid "$other_gid" ../src.meta \
551 | WVPASS bup meta -x --numeric-ids
552 new_gidx=$(bup xstat src | grep -e '^gid:')
553 WVPASSEQ "$new_gidx" "gid: $other_gid"
555 # Test that restoring an unknown user works.
556 unknown_user=$("$TOP"/t/unknown-owners --user)
558 WVPASS bup meta --edit \
559 --set-uid "$other_uid" --set-user "$unknown_user" ../src.meta \
561 new_uidx=$(bup xstat src | grep -e '^uid:')
562 WVPASSEQ "$new_uidx" "uid: $other_uid"
564 # Test that restoring an unknown group works.
565 unknown_group=$("$TOP"/t/unknown-owners --group)
567 WVPASS bup meta --edit \
568 --set-gid "$other_gid" --set-group "$unknown_group" ../src.meta \
570 new_gidx=$(bup xstat src | grep -e '^gid:')
571 WVPASSEQ "$new_gidx" "gid: $other_gid"
573 if ! [[ $(uname) =~ CYGWIN ]]; then
574 # For now, skip these on Cygwin because it doesn't allow
575 # restoring an unknown uid/gid.
577 # Make sure a uid of 0 trumps a non-root user.
578 WVPASS bup meta --edit --set-user "$some_user" ../src.meta \
580 WVPASS bup xstat src | WVPASS grep -qvE "^user: $some_user"
581 WVPASS bup xstat src | WVPASS grep -qE "^uid: 0"
583 # Make sure a gid of 0 trumps a non-root group.
584 WVPASS bup meta --edit --set-group "$some_user" ../src.meta \
586 WVPASS bup xstat src | WVPASS grep -qvE "^group: $some_group"
587 WVPASS bup xstat src | WVPASS grep -qE "^gid: 0"
592 # Root-only tests that require an FS with all the trimmings: ACLs,
593 # Linux attr, Linux xattr, etc.
594 if [ $(t/root-status) == root ]; then
596 # Some cleanup handled in universal-cleanup() above.
597 # These tests are only likely to work under Linux for now
599 [[ $(uname) =~ Linux ]] || exit 0
601 WVSTART 'meta - general (as root)'
602 WVPASS setup-test-tree
603 WVPASS cd "$TOP/bupmeta.tmp"
606 WVPASS dd if=/dev/zero of=testfs.img bs=1M count=32
607 # Make sure we have all the options the chattr test needs
608 # (i.e. create a "normal" ext4 filesystem).
609 WVPASS mke2fs -F -m 0 \
611 -O has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize \
614 WVPASS mount -o loop,acl,user_xattr testfs.img testfs
615 # Hide, so that tests can't create risks.
616 WVPASS chown root:root testfs
617 WVPASS chmod 0700 testfs
619 umount testfs-limited
620 WVPASS dd if=/dev/zero of=testfs-limited.img bs=1M count=32
621 WVPASS mkfs -t vfat testfs-limited.img
622 WVPASS mkdir testfs-limited
623 WVPASS mount -o loop,uid=root,gid=root,umask=0077 \
624 testfs-limited.img testfs-limited
626 WVPASS cp -pPR src testfs/src
627 (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
629 WVSTART 'meta - atime (as root)'
630 WVPASS force-delete testfs/src
631 WVPASS mkdir testfs/src
633 WVPASS mkdir testfs/src/foo
634 WVPASS touch testfs/src/bar
635 PYTHONPATH="$TOP/lib" \
636 WVPASS python -c "from bup import xstat; \
637 x = xstat.timespec_to_nsecs((42, 0));\
638 xstat.utime('testfs/src/foo', (x, x));\
639 xstat.utime('testfs/src/bar', (x, x));"
641 WVPASS bup meta -v --create --recurse --file src.meta src
642 WVPASS bup meta -tvf src.meta
644 WVPASS force-delete src-restore
645 WVPASS mkdir src-restore
646 WVPASS cd src-restore
647 WVPASS bup meta --extract --file ../src.meta
648 WVPASSEQ "$(bup xstat --include-fields=atime src/foo)" "atime: 42"
649 WVPASSEQ "$(bup xstat --include-fields=atime src/bar)" "atime: 42"
650 # Test start/finish extract.
651 WVPASS force-delete src
652 WVPASS bup meta --start-extract --file ../src.meta
654 WVPASS bup meta --finish-extract --file ../src.meta
655 WVPASSEQ "$(bup xstat --include-fields=atime src/foo)" "atime: 42"
656 WVPASSEQ "$(bup xstat --include-fields=atime src/bar)" "atime: 42"
659 WVSTART 'meta - Linux attr (as root)'
660 WVPASS force-delete testfs/src
661 WVPASS mkdir testfs/src
663 WVPASS touch testfs/src/foo
664 WVPASS mkdir testfs/src/bar
665 WVPASS chattr +acdeijstuADST testfs/src/foo
666 WVPASS chattr +acdeijstuADST testfs/src/bar
667 (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
668 # Test restoration to a limited filesystem (vfat).
670 WVPASS bup meta --create --recurse --file testfs/src.meta \
672 WVPASS force-delete testfs-limited/src-restore
673 WVPASS mkdir testfs-limited/src-restore
674 WVPASS cd testfs-limited/src-restore
675 WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
676 | WVPASS grep -e '^Linux chattr:' \
678 'import sys; exit(not len(sys.stdin.readlines()) == 3)'
682 WVSTART 'meta - Linux xattr (as root)'
683 WVPASS force-delete testfs/src
684 WVPASS mkdir testfs/src
685 WVPASS touch testfs/src/foo
686 WVPASS mkdir testfs/src/bar
687 WVPASS attr -s foo -V bar testfs/src/foo
688 WVPASS attr -s foo -V bar testfs/src/bar
689 (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
691 # Test restoration to a limited filesystem (vfat).
693 WVPASS bup meta --create --recurse --file testfs/src.meta \
695 WVPASS force-delete testfs-limited/src-restore
696 WVPASS mkdir testfs-limited/src-restore
697 WVPASS cd testfs-limited/src-restore
698 WVFAIL bup meta --extract --file ../../testfs/src.meta
699 WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
700 | WVPASS grep -e '^xattr\.set:' \
702 'import sys; exit(not len(sys.stdin.readlines()) == 2)'
705 WVSTART 'meta - POSIX.1e ACLs (as root)'
706 WVPASS force-delete testfs/src
707 WVPASS mkdir testfs/src
708 WVPASS touch testfs/src/foo
709 WVPASS mkdir testfs/src/bar
710 WVPASS setfacl -m u:root:r testfs/src/foo
711 WVPASS setfacl -m u:root:r testfs/src/bar
712 (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
714 # Test restoration to a limited filesystem (vfat).
716 WVPASS bup meta --create --recurse --file testfs/src.meta \
718 WVPASS force-delete testfs-limited/src-restore
719 WVPASS mkdir testfs-limited/src-restore
720 WVPASS cd testfs-limited/src-restore
721 WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
722 | WVPASS grep -e '^POSIX1e ACL applyto:' \
724 'import sys; exit(not len(sys.stdin.readlines()) == 2)'