btrfs-progs: tests/fuzz: Add fuzzed test image for btrfs check BUG_ON
[btrfs-progs-unstable/devel.git] / tests / export-testsuite.sh
blob31b6ecf4806dcb3ee00b5676146d7258c8086f1a
1 #!/bin/bash
2 # export the testsuite files to a separate tar
4 if ! [ -f testsuite-files ]; then
5 echo "ERROR: cannot find testsuite-files"
6 exit 1
7 fi
9 set -e
11 TESTSUITE_TAR="btrfs-progs-tests.tar.gz"
12 rm -f "$TESTSUITE_TAR"
14 TIMESTAMP=`date -u "+%Y-%m-%d %T %Z"`
17 echo "VERSION=`cat ../VERSION`"
18 echo "GIT_VERSION=`git describe`"
19 echo "TIMESTAMP='$TIMESTAMP'"
20 } > testsuite-id
22 # Due to potentially unwanted files in the testsuite (restored images or other
23 # temporary files) we can't simply copy everything so the tar
25 # The testsuite-files specifier:
26 # F file
27 # - directly copy the file from the given path, may be a git tracked file or
28 # a built binary
29 # G path
30 # - a path relative to the top of git, recursively traversed; path
31 # postprocessing is needed so the tar gets it relative to tests/
32 while read t f; do
33 case "$t" in
34 F) echo "$f";;
36 here=`pwd`
37 cd ..
38 git ls-tree -r --name-only --full-name HEAD "$f" |
39 sed -e 's#^tests/##' |
40 sed -e 's#^Documentation#../Documentation#'
41 cd "$here"
43 esac
44 done < testsuite-files > testsuite-files-all
46 echo "create tar: $TESTSUITE_TAR"
47 tar cz --sparse -f "$TESTSUITE_TAR" -T testsuite-files-all
48 if [ $? -eq 0 ]; then
49 echo "tar created successfully"
50 cat testsuite-id
51 rm -f testsuite-files-all
52 rm -f testsuite-id
53 else
54 exit $?