xfs: wrap xfs_db calls to the test device
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 15 Sep 2020 01:43:34 +0000 (18:43 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 20 Sep 2020 16:47:27 +0000 (00:47 +0800)
Create a _test_xfs_db analogue to _scratch_xfs_db so that we can
encapsulate whatever strange test fs options were fed to us by the test
runner.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/xfs
tests/xfs/003
tests/xfs/016
tests/xfs/045

index d9a9784f2fb9557a5747db88d3817a4a5947eae3..eab5e2929a90d7f3799f8ed80397a25b588f32db 100644 (file)
@@ -218,6 +218,19 @@ _scratch_xfs_db()
        $XFS_DB_PROG "$@" $(_scratch_xfs_db_options)
 }
 
+_test_xfs_db_options()
+{
+       TEST_OPTIONS=""
+       [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
+               TEST_OPTIONS="-l$TEST_LOGDEV"
+       echo $TEST_OPTIONS $* $TEST_DEV
+}
+
+_test_xfs_db()
+{
+       $XFS_DB_PROG "$@" $(_test_xfs_db_options)
+}
+
 _scratch_xfs_admin()
 {
        local options=("$SCRATCH_DEV")
index 1ce3e5ce71a10963b6975375e718bfa13d943b29..736bf20637aec816baf5bf397480c6ff45883781 100755 (executable)
@@ -38,32 +38,32 @@ test_done()
 # real QA test starts here
 
 echo "=== TEST 1 ==="
-xfs_db -r -c 'pop' -c 'type sb' $TEST_DEV
+_test_xfs_db -r -c 'pop' -c 'type sb'
 test_done
 
 echo "=== TEST 2 ==="
-xfs_db -r -c 'push sb' $TEST_DEV
+_test_xfs_db -r -c 'push sb'
 test_done
 
 echo "=== TEST 3 ==="
-xfs_db -r -c 'pop' -c 'push sb' $TEST_DEV
+_test_xfs_db -r -c 'pop' -c 'push sb'
 test_done
 
 echo "=== TEST 4 ==="
-xfs_db -r -c 'type sb' -c 'print' $TEST_DEV
+_test_xfs_db -r -c 'type sb' -c 'print'
 test_done
 
 echo "=== TEST 5 ==="
-xfs_db -r -c 'inode 128' -c 'push' -c 'type' $TEST_DEV >$tmp.out 2>&1
+_test_xfs_db -r -c 'inode 128' -c 'push' -c 'type' >$tmp.out 2>&1
 test_done
 if ! grep -q "current type is \"inode\"" $tmp.out; then
     cat $tmp.out
 fi
 
 echo "=== TEST 6 ==="
-xfs_db -r -c 'sb' -c 'a' $TEST_DEV >$tmp.out 2>&1 # don't care about output
+_test_xfs_db -r -c 'sb' -c 'a' >$tmp.out 2>&1 # don't care about output
 test_done
 
 echo "=== TEST 7 ==="
-xfs_db -r -c 'ring' $TEST_DEV
+_test_xfs_db -r -c 'ring'
 test_done
index 2b41127e33ce58a3404c2a90cab811f64849da38..e1b1b6b84cb76b71ff84970318c603a352326c5a 100755 (executable)
@@ -149,7 +149,7 @@ _log_sunit()
 
 _after_log()
 {
-    xfs_db -r $1 -c "sb" -c "print" | $AWK_PROG '
+    _scratch_xfs_db -r -c "sb" -c "print" | $AWK_PROG '
         /logstart/  { logstart = $3 }
         /logblocks/ { logblocks = $3 }
         END {
@@ -163,7 +163,7 @@ _check_corrupt()
     f="c6c6c6c6"
     echo "*** check for corruption"
     echo "expect $f..." >>$seqres.full
-    xfs_db -r -c "fsblock $2" -c "print" $1 | head | tee -a $seqres.full | \
+    _scratch_xfs_db -r -c "fsblock $2" -c "print" | head | tee -a $seqres.full | \
         grep -q -v "$f $f $f $f $f $f $f $f" && \
             _fail "!!! block $2 corrupted!"
 }
index 0c9e1b79a00c1edbf7da63908c070d3ce77f9e07..6a44da560f8c86d7695115bd47a35849406f3525 100755 (executable)
@@ -21,7 +21,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 
 _get_existing_uuid()
 {
-    xfs_db -r $TEST_DEV -c "uuid" | $AWK_PROG '/^UUID/ { print $3 }'
+       _test_xfs_db -r -c "uuid" | $AWK_PROG '/^UUID/ { print $3 }'
 }
 
 # real QA test starts here