6 export BUP_DIR="$TOP/buptest.tmp"
13 # Very simple metadata tests -- "make install" to a temp directory,
14 # then check that bup meta can reproduce the metadata correctly
15 # (according to coreutils stat) via create, extract, start-extract,
16 # and finish-extract. The current tests are crude, and this does not
17 # test devices, varying users/groups, acls, attrs, etc.
23 export PATH="${TOP}:${PATH}" # pick up bup
24 # Skip atime (test elsewhere) to avoid the observer effect.
25 find . | sort | xargs bup xstat --exclude-fields ctime,atime
31 if test "$(whoami)" != root
35 # Go to greater lengths to deal with any test detritus.
38 test -e "$@" || continue
39 chattr -fR = "$@" || true
46 test-src-create-extract()
48 # Test bup meta create/extract for ./src -> ./src-restore.
49 # Also writes to ./src-stat and ./src-restore-stat.
51 (cd src && WVPASS genstat) > src-stat
52 WVPASS bup meta --create --recurse --file src.meta src
54 force-delete src-restore
57 WVPASS bup meta --extract --file ../src.meta
59 (cd src && genstat >../../src-restore-stat) || WVFAIL
60 WVPASS diff -u5 ../src-stat ../src-restore-stat
61 # Test start/finish extract.
63 WVPASS bup meta --start-extract --file ../src.meta
65 WVPASS bup meta --finish-extract --file ../src.meta
66 (cd src && genstat >../../src-restore-stat) || WVFAIL
67 WVPASS diff -u5 ../src-stat ../src-restore-stat
71 if test "$(whoami)" == root
73 umount "${TOP}/bupmeta.tmp/testfs" || true
76 force-delete "${BUP_DIR}"
77 force-delete "${TOP}/bupmeta.tmp"
81 mkdir -p "${TOP}/bupmeta.tmp"
82 make DESTDIR="${TOP}/bupmeta.tmp/src" install
83 mkdir "${TOP}/bupmeta.tmp/src/misc"
84 cp -a cmd/bup-* "${TOP}/bupmeta.tmp/src/misc/"
87 # Use the test tree to check bup meta.
89 cd "${TOP}/bupmeta.tmp"
90 test-src-create-extract
93 # Root-only tests: ACLs, Linux attr, Linux xattr, etc.
94 if test "$(whoami)" == root
100 umount "${TOP}/bupmeta.tmp/testfs" || true
103 trap cleanup_at_exit EXIT
105 WVPASS cd "${TOP}/bupmeta.tmp"
106 umount testfs || true
107 dd if=/dev/zero of=test-fs.img bs=1M count=32
108 mke2fs -F -j -m 0 test-fs.img
110 mount -o loop,acl,user_xattr test-fs.img testfs
111 # Hide, so that tests can't create risks.
112 chown root:root testfs
116 (cd testfs && test-src-create-extract)
119 force-delete testfs/src
124 chattr +acdeijstuADST testfs/src/foo
125 chattr +acdeijstuADST testfs/src/bar
126 (cd testfs && test-src-create-extract)
130 force-delete testfs/src
135 attr -s foo -V bar testfs/src/foo
136 attr -s foo -V bar testfs/src/bar
137 (cd testfs && test-src-create-extract)
142 force-delete "${BUP_DIR}"
143 force-delete "$TOP/bupmeta.tmp"