From 60eda087b053941eaf0e86bee9f6994597c434df Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Tue, 31 Dec 2013 12:33:39 -0600 Subject: [PATCH] Move compression tests from test.sh to test-compression.sh. Signed-off-by: Rob Browning --- Makefile | 1 + t/test-compression.sh | 44 +++++++++++++++++++++++++++++++++++++++++++ t/test.sh | 30 ----------------------------- 3 files changed, 45 insertions(+), 30 deletions(-) create mode 100755 t/test-compression.sh diff --git a/Makefile b/Makefile index 0fe3475..1935d74 100644 --- a/Makefile +++ b/Makefile @@ -89,6 +89,7 @@ runtests-python: all runtests-cmdline: all test -e t/tmp || mkdir t/tmp TMPDIR="$(test_tmp)" t/test-cat-file.sh + TMPDIR="$(test_tmp)" t/test-compression.sh TMPDIR="$(test_tmp)" t/test-index-check-device.sh TMPDIR="$(test_tmp)" t/test-meta.sh TMPDIR="$(test_tmp)" t/test-restore-map-owner.sh diff --git a/t/test-compression.sh b/t/test-compression.sh new file mode 100755 index 0000000..9e3c02d --- /dev/null +++ b/t/test-compression.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +. ./wvtest-bup.sh +. t/lib.sh + +set -o pipefail + +top="$(WVPASS pwd)" || exit $? +tmpdir="$(WVPASS wvmktempdir)" || exit $? + +export BUP_DIR="$tmpdir/bup" +export GIT_DIR="$tmpdir/bup" + +bup() { "$top/bup" "$@"; } + +WVSTART "compression" +WVPASS cd "$tmpdir" + +D=compression0.tmp +WVPASS force-delete "$BUP_DIR" +WVPASS bup init +WVPASS mkdir $D +WVPASS bup index "$top/Documentation" +WVPASS bup save -n compression -0 --strip "$top/Documentation" +# Some platforms set -A by default when root, so just use it everywhere. +expected="$(WVPASS ls -A "$top/Documentation" | WVPASS sort)" || exit $? +actual="$(WVPASS bup ls -A compression/latest/ | WVPASS sort)" || exit $? +WVPASSEQ "$actual" "$expected" +compression_0_size=$(WVPASS du -k -s "$BUP_DIR" | WVPASS cut -f1) || exit $? + +D=compression9.tmp +WVPASS force-delete "$BUP_DIR" +WVPASS bup init +WVPASS mkdir $D +WVPASS bup index "$top/Documentation" +WVPASS bup save -n compression -9 --strip "$top/Documentation" +expected="$(ls -A "$top/Documentation" | sort)" || exit $? +actual="$(bup ls -A compression/latest/ | sort)" || exit $? +WVPASSEQ "$actual" "$expected" +compression_9_size=$(WVPASS du -k -s "$BUP_DIR" | WVPASS cut -f1) || exit $? + +WVPASS [ "$compression_9_size" -lt "$compression_0_size" ] + + +WVPASS rm -rf "$tmpdir" diff --git a/t/test.sh b/t/test.sh index 9c344e2..3483a3f 100755 --- a/t/test.sh +++ b/t/test.sh @@ -451,36 +451,6 @@ WVPASSEQ "$(bup ls -F buptest/latest/)" "a/ c/" -WVSTART "compression" -D=compression0.tmp -export BUP_DIR="$TOP/$D/.bup" -WVPASS force-delete $D -WVPASS mkdir $D -WVPASS bup init -WVPASS bup index $TOP/Documentation -WVPASS bup save -n compression -0 --strip $TOP/Documentation -# 'ls' on NetBSD sets -A by default when running as root, so we have to undo -# it by grepping out any dotfiles. (Normal OSes don't auto-set -A, but this -# is harmless there.) -expected="$(WVPASS ls $TOP/Documentation | grep -v '^\.' | WVPASS sort)" \ - || exit $? -actual="$(WVPASS bup ls compression/latest/ | WVPASS sort)" || exit $? -WVPASSEQ "$actual" "$expected" -COMPRESSION_0_SIZE=$(WVPASS du -k -s $D | WVPASS cut -f1) || exit $? - -D=compression9.tmp -export BUP_DIR="$TOP/$D/.bup" -WVPASS force-delete $D -WVPASS mkdir $D -WVPASS bup init -WVPASS bup index $TOP/Documentation -WVPASS bup save -n compression -9 --strip $TOP/Documentation -WVPASSEQ "$(bup ls compression/latest/ | sort)" \ - "$(ls $TOP/Documentation | grep -v '^\.' | sort)" -COMPRESSION_9_SIZE=$(WVPASS du -k -s $D | WVPASS cut -f1) || exit $? - -WVPASS [ "$COMPRESSION_9_SIZE" -lt "$COMPRESSION_0_SIZE" ] - WVSTART "save disjoint top-level directories" ( # Resolve any symlinks involving the top top-level dirs. -- 2.39.2