aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2017-11-02 12:15:38 +0200
committerEryu Guan <eguan@redhat.com>2017-11-10 12:33:37 +0800
commitd732a15548eff4f97bea6f732da5483f24b0a9ee (patch)
tree26955529fdcea832ceed7726dd4ddd38295c4587
parent48a67c3543046b024dd43f0f1556276ab03f04ce (diff)
downloadxfstests-d732a15548eff4f97bea6f732da5483f24b0a9ee.tar.gz
generic/426: factor out helper functions
Helper test_file_handles() outputs the sub-test command to output, so if errors are detected in one of the sub-tests, it is easier to know which sub-tests have failed. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Eryu Guan <eguan@redhat.com>
-rwxr-xr-xtests/generic/42640
-rw-r--r--tests/generic/426.out4
2 files changed, 33 insertions, 11 deletions
diff --git a/tests/generic/426 b/tests/generic/426
index 2d96c1d8ec..68ff169f6c 100755
--- a/tests/generic/426
+++ b/tests/generic/426
@@ -52,25 +52,43 @@ _require_test
_require_test_program "open_by_handle"
_require_exportfs
-numfiles=1024
+NUMFILES=1024
testdir=$TEST_DIR/$seq-dir
mkdir -p $testdir
+# Create empty test files in test dir
+create_test_files()
+{
+ local dir=$1
+ local opt=$2
+
+ mkdir -p $dir
+ rm -f $dir/*
+ src/open_by_handle -c $dir $NUMFILES
+}
+
+# Test encode/decode file handles
+test_file_handles()
+{
+ local dir=$1
+ local opt=$2
+
+ echo test_file_handles $* | _filter_test_dir
+ src/open_by_handle $opt $dir $NUMFILES
+}
+
# Check stale handles to deleted files
-rm -f $testdir/*
-src/open_by_handle -c $testdir $numfiles
-src/open_by_handle -d $testdir $numfiles
+create_test_files $testdir
+test_file_handles $testdir -d
# Check non-stale handles to linked files
-rm -f $testdir/*
-src/open_by_handle -c $testdir $numfiles
-src/open_by_handle $testdir $numfiles
+create_test_files $testdir
+test_file_handles $testdir
# Check non-stale handles to files that were hardlinked and original deleted
-rm -f $testdir/*
-src/open_by_handle -c $testdir $numfiles
-src/open_by_handle -l $testdir $numfiles
-src/open_by_handle -u $testdir $numfiles
+create_test_files $testdir
+test_file_handles $testdir -l
+test_file_handles $testdir -u
echo "Silence is golden"
status=0
diff --git a/tests/generic/426.out b/tests/generic/426.out
index 777cbcd07a..9a25123d4c 100644
--- a/tests/generic/426.out
+++ b/tests/generic/426.out
@@ -1,2 +1,6 @@
QA output created by 426
+test_file_handles TEST_DIR/426-dir -d
+test_file_handles TEST_DIR/426-dir
+test_file_handles TEST_DIR/426-dir -l
+test_file_handles TEST_DIR/426-dir -u
Silence is golden