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.
22 export PATH="${TOP}:${PATH}" # pick up bup
23 # Skip atime (test elsewhere) to avoid the observer effect.
24 find . | sort | xargs bup xstat --exclude-fields ctime,atime
30 if test "$(whoami)" != root
34 # Go to greater lengths to deal with any test detritus.
37 test -e "$@" || continue
38 chattr -fR = "$@" || true
45 test-src-create-extract()
47 # Test bup meta create/extract for ./src -> ./src-restore.
48 # Also writes to ./src-stat and ./src-restore-stat.
50 (cd src && WVPASS genstat) > src-stat
51 WVPASS bup meta --create --recurse --file src.meta src
53 force-delete src-restore
56 WVPASS bup meta --extract --file ../src.meta
58 (cd src && genstat >../../src-restore-stat) || WVFAIL
59 WVPASS diff -u5 ../src-stat ../src-restore-stat
60 # Test start/finish extract.
62 WVPASS bup meta --start-extract --file ../src.meta
64 WVPASS bup meta --finish-extract --file ../src.meta
65 (cd src && genstat >../../src-restore-stat) || WVFAIL
66 WVPASS diff -u5 ../src-stat ../src-restore-stat
70 if test "$(whoami)" == root
72 umount "${TOP}/bupmeta.tmp/testfs" || true
75 force-delete "${BUP_DIR}"
76 force-delete "${TOP}/bupmeta.tmp"
80 mkdir -p "${TOP}/bupmeta.tmp"
81 make DESTDIR="${TOP}/bupmeta.tmp/src" install
82 mkdir "${TOP}/bupmeta.tmp/src/misc"
83 cp -a cmd/bup-* "${TOP}/bupmeta.tmp/src/misc/"
86 # Use the test tree to check bup meta.
87 WVSTART 'meta - general'
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 WVSTART 'meta - general (as root)'
106 WVPASS cd "${TOP}/bupmeta.tmp"
107 umount testfs || true
108 dd if=/dev/zero of=test-fs.img bs=1M count=32
109 mke2fs -F -j -m 0 test-fs.img
111 mount -o loop,acl,user_xattr test-fs.img testfs
112 # Hide, so that tests can't create risks.
113 chown root:root testfs
117 (cd testfs && test-src-create-extract)
119 WVSTART 'meta - Linux attr (as root)'
120 force-delete testfs/src
125 chattr +acdeijstuADST testfs/src/foo
126 chattr +acdeijstuADST testfs/src/bar
127 (cd testfs && test-src-create-extract)
130 WVSTART 'meta - Linux xattr (as root)'
131 force-delete testfs/src
136 attr -s foo -V bar testfs/src/foo
137 attr -s foo -V bar testfs/src/bar
138 (cd testfs && test-src-create-extract)
141 WVSTART 'meta - POSIX.1e ACLs (as root)'
142 force-delete testfs/src
147 setfacl -m u:root:r testfs/src/foo
148 setfacl -m u:root:r testfs/src/bar
149 (cd testfs && test-src-create-extract)
154 force-delete "${BUP_DIR}"
155 force-delete "$TOP/bupmeta.tmp"