fstests: Add path $here before src/<file>

Calling src/<file> without path '$here' may cause the problem that
the file cannot be found.

For example, Running generic/192 with overlayfs(Let ubifs as base
fs) yields the following output:

  generic/192 - output mismatch
     QA output created by 192
     sleep for 5 seconds
     test
    +./common/rc: line 316: src/t_dir_type: No such file or directory
     delta1 is in range
     delta2 is in range
    ...

When the use case fails, the call stack in generic/192 is:

  local unknowns=$(src/t_dir_type $dir u | wc -l)	common/rc
  _supports_filetype					common/rc
  _overlay_mount					common/overlay
  _overlay_test_mount					common/overlay
  _test_mount						common/rc
  _test_cycle_mount					generic/192

Before _test_cycle_mount() being invoked, generic/192 executed 'cd
/' to change work dir from 'xfstests-dev' to '/', so src/t_dir_type
was not found.

[Eryu: some tests run src/<file> as regular user, don't add $here
prefix in such case, as a regular user may have no search permission
on $here]

Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Zhihao Cheng
2019-10-21 21:35:46 +08:00
committed by Eryu Guan
parent 74dfaaaacd
commit b7cecbea22
94 changed files with 222 additions and 205 deletions
+1 -1
View File
@@ -467,7 +467,7 @@ _do_verify_ciphertext_for_encryption_policy()
local set_encpolicy_args=$4
local keydesc=$5
local raw_key_hex=$6
local crypt_cmd="src/fscrypt-crypt-util $7"
local crypt_cmd="$here/src/fscrypt-crypt-util $7"
local blocksize=$(_get_block_size $SCRATCH_MNT)
local test_contents_files=()
+2 -2
View File
@@ -45,7 +45,7 @@ _run_generic() {
touch $TESTFILE
# Start the server
src/locktest $mode $TESTFILE 2> $SERVER_LOG 1> $SERVER_PORT &
$here/src/locktest $mode $TESTFILE 2> $SERVER_LOG 1> $SERVER_PORT &
server_pid=$!
timeout=30
@@ -71,7 +71,7 @@ _run_generic() {
# Start the client
src/locktest $mode -p $PORT -h localhost $TESTFILE 2> $CLIENT_LOG
$here/src/locktest $mode -p $PORT -h localhost $TESTFILE 2> $CLIENT_LOG
client_result=$?
client_pid=$!
if [ $client_result -ne 0 ]; then
+1 -1
View File
@@ -39,7 +39,7 @@ __populate_create_file() {
__populate_fragment_file() {
local fname="$1"
test -f "${fname}" && ./src/punch-alternating "${fname}"
test -f "${fname}" && $here/src/punch-alternating "${fname}"
}
# Create a large directory
+2 -2
View File
@@ -42,7 +42,7 @@ _require_quota()
#
_require_xfs_quota()
{
src/feature -q $TEST_DEV
$here/src/feature -q $TEST_DEV
[ $? -ne 0 ] && _notrun "Installed kernel does not support XFS quota"
if [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ]; then
_notrun "Quotas not supported on realtime test device"
@@ -87,7 +87,7 @@ _require_prjquota()
[ $? -ne 0 ] && _notrun "Installed kernel does not support project quotas"
return
fi
src/feature -P $_dev
$here/src/feature -P $_dev
[ $? -ne 0 ] && _notrun "Installed kernel does not support project quotas"
if [ "$USE_EXTERNAL" = yes ]; then
if [ -n "$TEST_RTDEV" -o -n "$SCRATCH_RTDEV" ]; then
+14 -14
View File
@@ -313,7 +313,7 @@ _supports_filetype()
local testfile=$dir/$$.ftype
touch $testfile
# look for DT_UNKNOWN files
local unknowns=$(src/t_dir_type $dir u | wc -l)
local unknowns=$($here/src/t_dir_type $dir u | wc -l)
rm $testfile
# 0 unknowns is success
return $unknowns
@@ -386,10 +386,10 @@ _scratch_shutdown()
if [ -z $OVL_BASE_SCRATCH_DEV ]; then
_fail "_scratch_shutdown: call _require_scratch_shutdown first in test"
else
src/godown $* $OVL_BASE_SCRATCH_MNT
$here/src/godown $* $OVL_BASE_SCRATCH_MNT
fi
else
src/godown $* $SCRATCH_MNT
$here/src/godown $* $SCRATCH_MNT
fi
}
@@ -1295,7 +1295,7 @@ _is_block_dev()
fi
if [ -b "$dev" ]; then
src/lstat64 "$dev" | $AWK_PROG '/Device type:/ { print $9 }'
$here/src/lstat64 "$dev" | $AWK_PROG '/Device type:/ { print $9 }'
fi
}
@@ -1314,7 +1314,7 @@ _is_char_dev()
fi
if [ -c "$dev" ]; then
src/lstat64 "$dev" | $AWK_PROG '/Device type:/ { print $9 }'
$here/src/lstat64 "$dev" | $AWK_PROG '/Device type:/ { print $9 }'
fi
}
@@ -1919,10 +1919,10 @@ _require_aiodio()
{
if [ -z "$1" ]
then
AIO_TEST=src/aio-dio-regress/aiodio_sparse2
AIO_TEST=$here/src/aio-dio-regress/aiodio_sparse2
[ -x $AIO_TEST ] || _notrun "aio-dio utilities required"
else
AIO_TEST=src/aio-dio-regress/$1
AIO_TEST=$here/src/aio-dio-regress/$1
[ -x $AIO_TEST ] || _notrun "$AIO_TEST not built"
fi
_require_aio
@@ -1934,7 +1934,7 @@ _require_aiodio()
#
_require_test_program()
{
local prog=src/$1
local prog=$here/src/$1
[ -x $prog ] || _notrun "$prog not built"
}
@@ -3095,7 +3095,7 @@ _require_exportfs()
# Does shutdown work on this fs?
_require_scratch_shutdown()
{
[ -x src/godown ] || _notrun "src/godown executable not found"
[ -x $here/src/godown ] || _notrun "src/godown executable not found"
_scratch_mkfs > /dev/null 2>&1 || _notrun "_scratch_mkfs failed on $SCRATCH_DEV"
_scratch_mount
@@ -3108,11 +3108,11 @@ _require_scratch_shutdown()
# running shutdown to avoid shutting down base fs accidently.
_notrun "This test requires a valid $OVL_BASE_SCRATCH_DEV as ovl base fs"
else
src/godown -f $OVL_BASE_SCRATCH_MNT 2>&1 \
$here/src/godown -f $OVL_BASE_SCRATCH_MNT 2>&1 \
|| _notrun "Underlying filesystem does not support shutdown"
fi
else
src/godown -f $SCRATCH_MNT 2>&1 \
$here/src/godown -f $SCRATCH_MNT 2>&1 \
|| _notrun "$FSTYP does not support shutdown"
fi
@@ -3347,8 +3347,8 @@ _require_relatime()
_require_userns()
{
[ -x src/nsexec ] || _notrun "src/nsexec executable not found"
src/nsexec -U true 2>/dev/null || _notrun "userns not supported by this kernel"
[ -x $here/src/nsexec ] || _notrun "src/nsexec executable not found"
$here/src/nsexec -U true 2>/dev/null || _notrun "userns not supported by this kernel"
}
_create_loop_device()
@@ -3426,7 +3426,7 @@ _require_ofd_locks()
# EINVAL will be returned.
_require_test_program "t_ofd_locks"
touch $TEST_DIR/ofd_testfile
src/t_ofd_locks -t $TEST_DIR/ofd_testfile > /dev/null 2>&1
$here/src/t_ofd_locks -t $TEST_DIR/ofd_testfile > /dev/null 2>&1
[ $? -eq 22 ] && _notrun "Require OFD locks support"
}
+3 -3
View File
@@ -67,7 +67,7 @@ _rename_tests_source_dest()
echo -n "$options $stype/$dtype -> "
_setup_one $source $stype
_setup_one $dest $dtype
src/renameat2 $source $dest $flags
$here/src/renameat2 $source $dest $flags
if test $? == 0; then
_showtype_one $source
echo -n "/"
@@ -107,7 +107,7 @@ _require_renameat2()
local rename_dir=$TEST_DIR/$$
local cmd=""
if test ! -x src/renameat2; then
if test ! -x $here/src/renameat2; then
_notrun "renameat2 binary not found"
fi
@@ -133,7 +133,7 @@ _require_renameat2()
_fail "_require_renameat2: only support noreplace,exchange,whiteout rename flags"
;;
esac
if ! src/renameat2 -t $cmd; then
if ! $here/src/renameat2 -t $cmd; then
rm -rf $rename_dir
_notrun "kernel doesn't support renameat2 syscall"
fi
+1 -1
View File
@@ -19,7 +19,7 @@ _zero_position()
exit
fi
length=`expr $length / 512`
src/devzero -v $value -b 1 -n $length -o $offset $SCRATCH_DEV \
$here/src/devzero -v $value -b 1 -n $length -o $offset $SCRATCH_DEV \
| perl -npe 's/\d\.\d\dKb/X.XXKb/g'
}
+4 -4
View File
@@ -40,22 +40,22 @@ touch $TEST_DIR/$tmp.1
for l in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
do
ln $TEST_DIR/$tmp.1 $TEST_DIR/$tmp.$l
x=`src/lstat64 $TEST_DIR/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
x=`$here/src/lstat64 $TEST_DIR/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
if [ "$l" -ne $x ]
then
echo "Arrgh, created link #$l and lstat64 looks like ..."
src/lstat64 $TEST_DIR/$tmp.1
$here/src/lstat64 $TEST_DIR/$tmp.1
status=1
fi
done
for l in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
do
x=`src/lstat64 $TEST_DIR/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
x=`$here/src/lstat64 $TEST_DIR/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
if [ "$l" -ne $x ]
then
echo "Arrgh, about to remove link #$l and lstat64 looks like ..."
src/lstat64 $TEST_DIR/$tmp.1
$here/src/lstat64 $TEST_DIR/$tmp.1
status=1
fi
rm -f $TEST_DIR/$tmp.$l
+1 -1
View File
@@ -45,7 +45,7 @@ echo "brevity is wit..."
echo "------"
echo "test 1"
echo "------"
src/truncfile -c 10000 $TEST_DIR/truncfile.$$.0 >$tmp.out 2>&1
$here/src/truncfile -c 10000 $TEST_DIR/truncfile.$$.0 >$tmp.out 2>&1
ret=$?
if [ "$ret" -ne 0 ]; then
out=`cat $tmp.out`
+2 -2
View File
@@ -43,7 +43,7 @@ file1=$rename_dir/file1
file2=$rename_dir/file2
touch $file1
touch $file2
src/t_rename_overwrite $file1 $file2
$here/src/t_rename_overwrite $file1 $file2
rm $file2
echo "overwriting directory:"
@@ -51,7 +51,7 @@ dir1=$rename_dir/dir1
dir2=$rename_dir/dir2
mkdir $dir1
mkdir $dir2
src/t_rename_overwrite $dir1 $dir2
$here/src/t_rename_overwrite $dir1 $dir2
rmdir $dir2
rmdir $rename_dir
+1 -1
View File
@@ -56,7 +56,7 @@ _crashtest()
# write, run the test command and shutdown the fs
$XFS_IO_PROG -f -c "pwrite -S 1 0 64k" -c "$cmd 60k 4k" $file | \
_filter_xfs_io
./src/godown -f $mnt
$here/src/godown -f $mnt
$UMOUNT_PROG $mnt
_mount $img $mnt
+1 -1
View File
@@ -77,7 +77,7 @@ touch $tmp.running
procs=2
while [ -f "$tmp.running" ]
do
src/fstest -m -p $FSTEST_DIR -n $procs -f 4 > /dev/null 2>&1
$here/src/fstest -m -p $FSTEST_DIR -n $procs -f 4 > /dev/null 2>&1
done
rm -rf $FSTEST_DIR/*
+1 -1
View File
@@ -54,7 +54,7 @@ _scratch_mkfs >>$seqres.full 2>&1
_scratch_mount
# create, open & unlinked files so unlinked inode list is not empty
src/multi_open_unlink -f $SCRATCH_MNT/$seq.unlinked -n $nr_cpu &
$here/src/multi_open_unlink -f $SCRATCH_MNT/$seq.unlinked -n $nr_cpu &
open_pid=$!
# start link/unlink storm
+1 -1
View File
@@ -32,7 +32,7 @@ _supported_os Linux
_require_test
path=$TEST_DIR/t_access
src/t_access_root $path | tee $seqres.full | _filter
$here/src/t_access_root $path | tee $seqres.full | _filter
# success, all done
status=0
+3
View File
@@ -70,6 +70,9 @@ rm -f $file
touch $file
chown $qa_user $file
chmod ugo+w $TEST_DIR
# don't use $here/src/writemod, as we're running it as a regular user, and
# $here may contain path component that a regular user doesn't have search
# permission
su $qa_user -c "src/writemod $file" | filefilter
cat $file
+6 -6
View File
@@ -31,14 +31,14 @@ _scratch_mkfs >/dev/null 2>&1 || _fail "mkfs failed"
_compare_access_times()
{
original_access_time="`cat $tmp.out | sed -n '5p'|awk '{ print substr($0,0,32)}'`"
accessed_time="`src/lstat64 $1 | sed -n '5p'| awk '{ print substr($0,0,32)}'`"
accessed_time="`$here/src/lstat64 $1 | sed -n '5p'| awk '{ print substr($0,0,32)}'`"
echo "*** compare access times ***"
if [ "$original_access_time" != "$accessed_time" ]
then
echo "*** file access time updated on $2 (unexpected) ***"
cat $tmp.out
echo "---------------------------------------------------"
src/lstat64 $1
$here/src/lstat64 $1
mount | grep $SCRATCH_MNT
fi
@@ -53,8 +53,8 @@ fi
#executable file
echo "*** copying file ***"
cp src/lstat64 $SCRATCH_MNT
src/lstat64 $SCRATCH_MNT/lstat64 >$tmp.out
cp $here/src/lstat64 $SCRATCH_MNT
$here/src/lstat64 $SCRATCH_MNT/lstat64 >$tmp.out
sleep 5
echo "*** executing file ***"
$SCRATCH_MNT/lstat64 $SCRATCH_MNT/lstat64 >/dev/null
@@ -63,7 +63,7 @@ _compare_access_times $SCRATCH_MNT/lstat64 "executing file"
#reading file
echo "*** creating file ***"
touch $SCRATCH_MNT/testfile
src/lstat64 $SCRATCH_MNT/testfile >$tmp.out
$here/src/lstat64 $SCRATCH_MNT/testfile >$tmp.out
sleep 5
echo "*** reading file ***"
cat $SCRATCH_MNT/testfile >/dev/null
@@ -72,7 +72,7 @@ _compare_access_times $SCRATCH_MNT/testfile "reading file"
#writing file
echo "*** creating file ***"
touch $SCRATCH_MNT/testfile2
src/lstat64 $SCRATCH_MNT/testfile2 >$tmp.out
$here/src/lstat64 $SCRATCH_MNT/testfile2 >$tmp.out
sleep 5
echo "*** writing to file ***"
echo "asdf" >> $SCRATCH_MNT/testfile2
+2 -2
View File
@@ -43,8 +43,8 @@ for TESTFILE in $TEST_DIR/rw_pattern.tmp $SCRATCH_MNT/rw_pattern.tmp
count=1
while (( count < 101 ))
do
src/preallo_rw_pattern_writer $TESTFILE
src/preallo_rw_pattern_reader $TESTFILE
$here/src/preallo_rw_pattern_writer $TESTFILE
$here/src/preallo_rw_pattern_reader $TESTFILE
if (test $? -ne 0) then
echo Read/Write Pattern Test FAILED.
_cleanup
+3 -1
View File
@@ -39,13 +39,15 @@ touch $TESTFILE
chmod a+rw $TESTDIR
chmod a+rw $TESTFILE
# don't use $here/src/ftrunc, as we're running it as a regular user, and $here
# may contain path component that a regular user doesn't have search permission
su $qa_user -c "./src/ftrunc -f $TESTFILE"
if [ "$?" != "0" ]; then
echo src/ftrunc returned non 0 status!
fi
src/trunc -f $TESTFILE
$here/src/trunc -f $TESTFILE
if (test $? -eq 0 ) then
status=0
fi
+4 -4
View File
@@ -37,10 +37,10 @@ _scratch_mount "-o nosuid"
mkdir $SCRATCH_MNT/looptest
src/looptest -i 100000 -r -w -b 8192 -s $SCRATCH_MNT/looptest/looptest1.tst
src/looptest -i 10000 -t -r -w -s -b 102400 $SCRATCH_MNT/looptest/looptest2.tst
src/looptest -i 50000 -r -w -b 256 -s $SCRATCH_MNT/looptest/looptest3.tst
src/looptest -i 2000 -o -r -w -b 8192 -s $SCRATCH_MNT/looptest/looptest4.tst
$here/src/looptest -i 100000 -r -w -b 8192 -s $SCRATCH_MNT/looptest/looptest1.tst
$here/src/looptest -i 10000 -t -r -w -s -b 102400 $SCRATCH_MNT/looptest/looptest2.tst
$here/src/looptest -i 50000 -r -w -b 256 -s $SCRATCH_MNT/looptest/looptest3.tst
$here/src/looptest -i 2000 -o -r -w -b 8192 -s $SCRATCH_MNT/looptest/looptest4.tst
status=0
exit
+4 -4
View File
@@ -56,9 +56,9 @@ for SUNIT_K in 8 16 32 64 128; do
$XFS_IO_PROG -f -c "pwrite -b $SIZE 0 $SIZE" \
$SCRATCH_MNT/file-$FILE-$SIZE-write \
>> $seqres.full 2>&1
src/t_stripealign $SCRATCH_MNT/file-$FILE-$SIZE-falloc \
$here/src/t_stripealign $SCRATCH_MNT/file-$FILE-$SIZE-falloc \
$SUNIT_BLOCKS | _filter_scratch
src/t_stripealign $SCRATCH_MNT/file-$FILE-$SIZE-write \
$here/src/t_stripealign $SCRATCH_MNT/file-$FILE-$SIZE-write \
$SUNIT_BLOCKS | _filter_scratch
done
done
@@ -66,7 +66,7 @@ for SUNIT_K in 8 16 32 64 128; do
echo "=== Testing size 1g falloc on ${SUNIT_K}k stripe ==="
$XFS_IO_PROG -f -c "falloc 0 1g" \
$SCRATCH_MNT/file-1g-falloc >> $seqres.full 2>&1
src/t_stripealign $SCRATCH_MNT/file-1g-falloc $SUNIT_BLOCKS \
$here/src/t_stripealign $SCRATCH_MNT/file-1g-falloc $SUNIT_BLOCKS \
| _filter_scratch
rm -f $SCRATCH_MNT/file-1g-falloc | _filter_scratch
@@ -74,7 +74,7 @@ for SUNIT_K in 8 16 32 64 128; do
echo "=== Testing size 1073745920 falloc on ${SUNIT_K}k stripe ==="
$XFS_IO_PROG -f -c "falloc 0 1073745920" \
$SCRATCH_MNT/file-1073745920-falloc >> $seqres.full 2>&1
src/t_stripealign $SCRATCH_MNT/file-1073745920-falloc \
$here/src/t_stripealign $SCRATCH_MNT/file-1073745920-falloc \
$SUNIT_BLOCKS | _filter_scratch
_scratch_unmount

Some files were not shown because too many files have changed in this diff Show More