btrfs-progs: print-tree: Remove btrfs_root parameter
[platform/upstream/btrfs-progs.git] / tests / export-testsuite.sh
1 #!/bin/bash
2 # export the testsuite files to a separate tar
3
4 if ! [ -f testsuite-files ]; then
5         echo "ERROR: cannot find testsuite-files"
6         exit 1
7 fi
8
9 set -e
10
11 TESTSUITE_TAR="btrfs-progs-tests.tar.gz"
12 rm -f "$TESTSUITE_TAR"
13
14 TIMESTAMP=`date -u "+%Y-%m-%d %T %Z"`
15
16 {
17         echo "VERSION=`cat ../VERSION`"
18         echo "GIT_VERSION=`git describe`"
19         echo "TIMESTAMP='$TIMESTAMP'"
20 } > testsuite-id
21
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
24 #
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";;
35                 G)
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"
42                         ;;
43         esac
44 done < testsuite-files > testsuite-files-all
45
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 $?
55 fi