]> arthur.barton.de Git - bup.git/blob - t/test-compression.sh
Move compression tests from test.sh to test-compression.sh.
[bup.git] / t / test-compression.sh
1 #!/usr/bin/env bash
2 . ./wvtest-bup.sh
3 . t/lib.sh
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
15 WVSTART "compression"
16 WVPASS cd "$tmpdir"
17
18 D=compression0.tmp
19 WVPASS force-delete "$BUP_DIR"
20 WVPASS bup init
21 WVPASS mkdir $D
22 WVPASS bup index "$top/Documentation"
23 WVPASS bup save -n compression -0 --strip "$top/Documentation"
24 # Some platforms set -A by default when root, so just use it everywhere.
25 expected="$(WVPASS ls -A "$top/Documentation" | WVPASS sort)" || exit $?
26 actual="$(WVPASS bup ls -A compression/latest/ | WVPASS sort)" || exit $?
27 WVPASSEQ "$actual" "$expected"
28 compression_0_size=$(WVPASS du -k -s "$BUP_DIR" | WVPASS cut -f1) || exit $?
29
30 D=compression9.tmp
31 WVPASS force-delete "$BUP_DIR"
32 WVPASS bup init
33 WVPASS mkdir $D
34 WVPASS bup index "$top/Documentation"
35 WVPASS bup save -n compression -9 --strip "$top/Documentation"
36 expected="$(ls -A "$top/Documentation" | sort)" || exit $?
37 actual="$(bup ls -A compression/latest/ | sort)" || exit $?
38 WVPASSEQ "$actual" "$expected"
39 compression_9_size=$(WVPASS du -k -s "$BUP_DIR" | WVPASS cut -f1) || exit $?
40
41 WVPASS [ "$compression_9_size" -lt "$compression_0_size" ]
42
43
44 WVPASS rm -rf "$tmpdir"