5 export BUP_DIR="$TOP/buptest.tmp"
12 # Very simple metadata tests -- "make install" to a temp directory,
13 # then check that bup meta can reproduce the metadata correctly
14 # (according to coreutils stat) via create, extract, start-extract,
15 # and finish-extract. The current tests are crude, and this does not
16 # test devices, varying users/groups, acls, attrs, etc.
21 export PATH="$TOP:$PATH" # pick up bup
22 # Skip atime (test elsewhere) to avoid the observer effect.
23 find . | sort | xargs bup xstat --exclude-fields ctime,atime
29 test "$(whoami)" == root -a -z "$FAKEROOTKEY"
38 # Go to greater lengths to deal with any test detritus.
41 test -e "$@" || continue
42 chattr -fR = "$@" || true
49 test-src-create-extract()
51 # Test bup meta create/extract for ./src -> ./src-restore.
52 # Also writes to ./src-stat and ./src-restore-stat.
54 (cd src && WVPASS genstat) > src-stat
55 WVPASS bup meta --create --recurse --file src.meta src
57 force-delete src-restore
60 WVPASS bup meta --extract --file ../src.meta
62 (cd src && genstat >../../src-restore-stat) || WVFAIL
63 WVPASS diff -U5 ../src-stat ../src-restore-stat
64 # Test start/finish extract.
66 WVPASS bup meta --start-extract --file ../src.meta
68 WVPASS bup meta --finish-extract --file ../src.meta
69 (cd src && genstat >../../src-restore-stat) || WVFAIL
70 WVPASS diff -U5 ../src-stat ../src-restore-stat
76 umount "$TOP/bupmeta.tmp/testfs" || true
79 force-delete "$BUP_DIR"
80 force-delete "$TOP/bupmeta.tmp"
84 mkdir -p "$TOP/bupmeta.tmp"
85 make DESTDIR="$TOP/bupmeta.tmp/src" install
86 mkdir "$TOP/bupmeta.tmp/src/misc"
87 cp -a cmd/bup-* "$TOP/bupmeta.tmp/src/misc/"
90 # Use the test tree to check bup meta.
91 WVSTART 'meta - general'
94 test-src-create-extract
97 # Root-only tests: ACLs, Linux attr, Linux xattr, etc.
104 umount "$TOP/bupmeta.tmp/testfs" || true
107 trap cleanup_at_exit EXIT
109 WVSTART 'meta - general (as root)'
110 WVPASS cd "$TOP/bupmeta.tmp"
111 umount testfs || true
112 dd if=/dev/zero of=testfs.img bs=1M count=32
113 mke2fs -F -j -m 0 testfs.img
115 mount -o loop,acl,user_xattr testfs.img testfs
116 # Hide, so that tests can't create risks.
117 chown root:root testfs
121 (cd testfs && test-src-create-extract)
123 WVSTART 'meta - atime (as root)'
124 force-delete testfs/src
129 PYTHONPATH="$TOP/lib" \
130 python -c "from bup.xstat import lutime, FSTime; \
131 x = FSTime.from_secs(42);\
132 lutime('testfs/src/foo', (x, x));\
133 lutime('testfs/src/bar', (x, x));"
135 WVPASS bup meta -v --create --recurse --file src.meta src
136 bup meta -tvf src.meta
138 force-delete src-restore
141 WVPASS bup meta --extract --file ../src.meta
142 WVPASSEQ "$(bup xstat --include-fields=atime src/foo)" "atime: 42"
143 WVPASSEQ "$(bup xstat --include-fields=atime src/bar)" "atime: 42"
144 # Test start/finish extract.
146 WVPASS bup meta --start-extract --file ../src.meta
148 WVPASS bup meta --finish-extract --file ../src.meta
149 WVPASSEQ "$(bup xstat --include-fields=atime src/foo)" "atime: 42"
150 WVPASSEQ "$(bup xstat --include-fields=atime src/bar)" "atime: 42"
153 WVSTART 'meta - Linux attr (as root)'
154 force-delete testfs/src
159 chattr +acdeijstuADST testfs/src/foo
160 chattr +acdeijstuADST testfs/src/bar
161 (cd testfs && test-src-create-extract)
164 WVSTART 'meta - Linux xattr (as root)'
165 force-delete testfs/src
170 attr -s foo -V bar testfs/src/foo
171 attr -s foo -V bar testfs/src/bar
172 (cd testfs && test-src-create-extract)
175 WVSTART 'meta - POSIX.1e ACLs (as root)'
176 force-delete testfs/src
181 setfacl -m u:root:r testfs/src/foo
182 setfacl -m u:root:r testfs/src/bar
183 (cd testfs && test-src-create-extract)