]> arthur.barton.de Git - bup.git/blob - t/test-xdev.sh
Set sort LC_ALL=C correctly in test-meta and test-xdev
[bup.git] / t / test-xdev.sh
1 #!/usr/bin/env bash
2 . ./wvtest-bup.sh || exit $?
3
4 set -o pipefail
5
6 if [ $(t/root-status) != root ]; then
7     WVSTART 'not root: skipping tests'
8     exit 0 # FIXME: add WVSKIP.
9 fi
10
11 if ! modprobe loop; then
12     WVSTART 'unable to load loopback module; skipping tests' 1>&2
13     exit 0
14 fi
15
16 # These tests are only likely to work under Linux for now
17 # (patches welcome).
18 if ! [[ $(uname) =~ Linux ]]; then
19     WVSTART 'not Linux: skipping tests'
20     exit 0 # FIXME: add WVSKIP.
21 fi
22
23 top="$(WVPASS pwd)" || exit $?
24 tmpdir="$(WVPASS wvmktempdir)" || exit $?
25
26 export BUP_DIR="$tmpdir/bup"
27 export GIT_DIR="$tmpdir/bup"
28
29 bup() { "$top/bup" "$@"; }
30
31 WVPASS bup init
32 WVPASS pushd "$tmpdir"
33
34 WVSTART 'drecurse'
35
36 WVPASS dd if=/dev/zero of=testfs.img bs=1M count=32
37 WVPASS mkfs -F testfs.img # Don't care what type.
38 WVPASS mkdir -p src/mnt/{a,b,c}
39 WVPASS mount -o loop testfs.img src/mnt
40 WVPASS mkdir -p src/mnt/x
41 WVPASS touch src/1 src/mnt/2 src/mnt/x/3
42
43 WVPASSEQ "$(bup drecurse src | grep -vF lost+found)" "src/mnt/x/3
44 src/mnt/x/
45 src/mnt/2
46 src/mnt/
47 src/1
48 src/"
49
50 WVPASSEQ "$(bup drecurse -x src)" "src/mnt/
51 src/1
52 src/"
53
54 WVSTART 'index/save/restore'
55
56 WVPASS bup index src
57 WVPASS bup save -n src src
58 WVPASS mkdir src-restore
59 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
60 WVPASS test -d src-restore/src
61 WVPASS "$top/t/compare-trees" -c src/ src-restore/src/
62
63 WVPASS rm -r "$BUP_DIR" src-restore
64 WVPASS bup init
65 WVPASS bup index -x src
66 WVPASS bup save -n src src
67 WVPASS mkdir src-restore
68 WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
69 WVPASS test -d src-restore/src
70 WVPASSEQ "$(cd src-restore/src && find . -not -name lost+found | LC_ALL=C sort)" \
71 ".
72 ./1
73 ./mnt"
74
75 WVPASS popd
76 WVPASS umount "$tmpdir/src/mnt"
77 WVPASS rm -r "$tmpdir"