diff options
author | David Sterba <dsterba@suse.com> | 2018-02-08 15:34:04 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-02-13 15:41:32 +0100 |
commit | 04cd2c0bcac7129026c80661933b4ab97d4ab9ca (patch) | |
tree | 75b5c7350131ca7b1d8c0cfc9f3b0d0115157449 /tests/export-testsuite.sh | |
parent | eb2fe7d1c476ebfa434ec2cf8afd1b52cce0f28e (diff) |
btrfs-progs: rework testsuite export
Move the testsuite to tests/ and make the tarball generation more
deterministic. As there could be many random temporary files left in the
test directories, we can't just copy them. Use 'git ls-tree' to
filter just what we want, this needs a slight extension of the file list
specification.
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tests/export-testsuite.sh')
-rwxr-xr-x | tests/export-testsuite.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/export-testsuite.sh b/tests/export-testsuite.sh new file mode 100755 index 00000000..31b6ecf4 --- /dev/null +++ b/tests/export-testsuite.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# export the testsuite files to a separate tar + +if ! [ -f testsuite-files ]; then + echo "ERROR: cannot find testsuite-files" + exit 1 +fi + +set -e + +TESTSUITE_TAR="btrfs-progs-tests.tar.gz" +rm -f "$TESTSUITE_TAR" + +TIMESTAMP=`date -u "+%Y-%m-%d %T %Z"` + +{ + echo "VERSION=`cat ../VERSION`" + echo "GIT_VERSION=`git describe`" + echo "TIMESTAMP='$TIMESTAMP'" +} > testsuite-id + +# Due to potentially unwanted files in the testsuite (restored images or other +# temporary files) we can't simply copy everything so the tar +# +# The testsuite-files specifier: +# F file +# - directly copy the file from the given path, may be a git tracked file or +# a built binary +# G path +# - a path relative to the top of git, recursively traversed; path +# postprocessing is needed so the tar gets it relative to tests/ +while read t f; do + case "$t" in + F) echo "$f";; + G) + here=`pwd` + cd .. + git ls-tree -r --name-only --full-name HEAD "$f" | + sed -e 's#^tests/##' | + sed -e 's#^Documentation#../Documentation#' + cd "$here" + ;; + esac +done < testsuite-files > testsuite-files-all + +echo "create tar: $TESTSUITE_TAR" +tar cz --sparse -f "$TESTSUITE_TAR" -T testsuite-files-all +if [ $? -eq 0 ]; then + echo "tar created successfully" + cat testsuite-id + rm -f testsuite-files-all + rm -f testsuite-id +else + exit $? +fi |