]> arthur.barton.de Git - bup.git/blob - t/test-meta.sh
Add (private for now) "bup xstat" command and use it in the metadata tests.
[bup.git] / t / test-meta.sh
1 #!/usr/bin/env bash
2 . wvtest.sh
3 #set -e
4
5 TOP="$(pwd)"
6 export BUP_DIR="$TOP/buptest.tmp"
7
8 bup()
9 {
10     "$TOP/bup" "$@"
11 }
12
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.
18 WVSTART "meta"
19
20 genstat()
21 {
22   (
23     export PATH="${TOP}:${PATH}" # pick up bup
24     find . | sort | xargs bup xstat --exclude-fields ctime
25   )
26 }
27
28 # Create a test tree and collect its info via stat(1).
29 (
30   set -e
31   rm -rf "${TOP}/bupmeta.tmp"
32   mkdir -p "${TOP}/bupmeta.tmp"
33   make DESTDIR="${TOP}/bupmeta.tmp/src" install
34   mkdir "${TOP}/bupmeta.tmp/src/misc"
35   cp -a cmd/bup-* "${TOP}/bupmeta.tmp/src/misc/"
36   cd "${TOP}/bupmeta.tmp/src"
37   WVPASS genstat >../src-stat
38 ) || WVFAIL
39
40 # Use the test tree to check bup meta.
41 (
42   WVPASS cd "${TOP}/bupmeta.tmp"
43   WVPASS bup meta --create --recurse --file src.meta src
44   WVPASS mkdir src-restore
45   WVPASS cd src-restore
46   WVPASS bup meta --extract --file ../src.meta
47   WVPASS test -d src
48   (cd src && genstat >../../src-restore-stat) || WVFAIL
49   WVPASS diff -u5 ../src-stat ../src-restore-stat
50   WVPASS rm -rf src
51   WVPASS bup meta --start-extract --file ../src.meta
52   WVPASS test -d src
53   WVPASS bup meta --finish-extract --file ../src.meta
54   (cd src && genstat >../../src-restore-stat) || WVFAIL
55   WVPASS diff -u5 ../src-stat ../src-restore-stat
56 )
57
58 exit 0