]> arthur.barton.de Git - bup.git/blob - t/test-compression.sh
test-restore-map-owner: accommodate python 3 and test there
[bup.git] / t / test-compression.sh
1 #!/usr/bin/env bash
2 . ./wvtest-bup.sh || exit $?
3 . t/lib.sh || exit $?
4
5 set -o pipefail
6
7 top="$(WVPASS pwd)" || exit $?
8 tmpdir="$(WVPASS wvmktempdir)" || exit $?
9
10 export BUP_DIR="$tmpdir/bup"
11 export GIT_DIR="$tmpdir/bup"
12
13 bup() { "$top/bup" "$@"; }
14 fs-size() { tar cf - "$@" | wc -c; }
15
16 WVSTART "compression"
17 WVPASS cd "$tmpdir"
18
19 D=compression0.tmp
20 WVPASS force-delete "$BUP_DIR"
21 WVPASS bup init
22 WVPASS mkdir $D
23 WVPASS bup index "$top/Documentation"
24 WVPASS bup save -n compression -0 --strip "$top/Documentation"
25 # Some platforms set -A by default when root, so just use it everywhere.
26 expected="$(WVPASS ls -A "$top/Documentation" | WVPASS sort)" || exit $?
27 actual="$(WVPASS bup ls -A compression/latest/ | WVPASS sort)" || exit $?
28 WVPASSEQ "$actual" "$expected"
29 compression_0_size=$(WVPASS fs-size "$BUP_DIR") || exit $?
30
31 D=compression9.tmp
32 WVPASS force-delete "$BUP_DIR"
33 WVPASS bup init
34 WVPASS mkdir $D
35 WVPASS bup index "$top/Documentation"
36 WVPASS bup save -n compression -9 --strip "$top/Documentation"
37 expected="$(ls -A "$top/Documentation" | sort)" || exit $?
38 actual="$(bup ls -A compression/latest/ | sort)" || exit $?
39 WVPASSEQ "$actual" "$expected"
40 compression_9_size=$(WVPASS fs-size "$BUP_DIR") || exit $?
41
42 WVPASS [ "$compression_9_size" -lt "$compression_0_size" ]
43
44
45 WVPASS rm -rf "$tmpdir"