diff mbox

[RFC,v2,1/4] btrfs-progs: Add package command for packaging tests

Message ID 1517560445-5712-2-git-send-email-gujx@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gu Jinxiang Feb. 2, 2018, 8:34 a.m. UTC
Export the testsuite files to a separate tar.
Since fsck tests depend on btrfs-corrupt-block, and misc
tests depends on both btrfs-corrupt-block and fssum,
so set it as prerequisites for package commad.

Because,
althougth fssum can be generated by source that are all in
tests directory, and has no rely on the btrfs's structure.
But btrfs-corrupt-block deeply relys on btrfs's structure.
For consistency, at the present stage, generete the two
when create test tar.

Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
---
 Makefile              |  4 ++++
 tests/export-tests.sh | 28 ++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100755 tests/export-tests.sh
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 6369e8f4..23decc4d 100644
--- a/Makefile
+++ b/Makefile
@@ -333,6 +333,10 @@  test-inst: all
 
 test: test-fsck test-mkfs test-convert test-misc test-fuzz test-cli
 
+package: btrfs-corrupt-block fssum
+	@echo "Export tests as a package"
+	$(Q)bash tests/export-tests.sh
+
 #
 # NOTE: For static compiles, you need to have all the required libs
 # 	static equivalent available
diff --git a/tests/export-tests.sh b/tests/export-tests.sh
new file mode 100755
index 00000000..d7f6ca17
--- /dev/null
+++ b/tests/export-tests.sh
@@ -0,0 +1,28 @@ 
+#!/bin/bash
+# export the testsuite files to a separate tar
+
+SCRIPT_DIR=$(dirname $(readlink -f "$0"))
+TESTDIR=$(basename $SCRIPT_DIR)
+FSSUM=fssum
+CORRUPT=btrfs-corrupt-block
+DESTNAME="tests.tar.gz"
+DESTDIR="."
+
+test -n "$EXPORT" && DESTDIR=$(realpath "$EXPORT")
+if [ ! -d $DESTDIR ]; then
+	echo "dest directory is not exsit."
+	exit 1
+fi
+
+DEST=$DESTDIR/$DESTNAME
+
+if [ -f $DEST ];then
+	echo "remove exsit package: " $DEST
+	rm $DEST
+fi
+
+echo "begin create tar:  " $DEST
+tar --exclude-vcs-ignores -zScf $DEST $TESTDIR $FSSUM $CORRUPT
+if [ $? -eq 0 ]; then
+	echo "create tar successfully."
+fi