From: Dave Chinner <dchinner@xxxxxxxxxx>
Test 310 fails with:
mkdir: cannot create directory `/mnt/test/tmp': File exists
$TEST_DIR is persistent, so test directories need to be created with
"mkdir -p" so they don't fail if the directory already exists.
Many other things need fixing, too.
- Tests should define directories they use on $TEST_DIR by
their sequence number, not generic names.
- Use a variable for the directory the test runs in
($SEQ_DIR, in this case) to avoid having to manually code
it everywhere.
- New binaries need to be added to .gitignore.
- Return status for shell functions is 0 for success,
non-zero for failure.
- Setting status=0 if there is no failure in the first test
means that even if the second test fails, the test will
still pass. Change the test to use "_fatal" when a kernel
bug is detected, and only set status=0 when the entire
test has finished.
- reduce the default runtime by to roughly a minute and
scale it with the stress load factor variables. In most
cases, this test is never going to hit problems (as
they've already been fixed) so running it for ~4 minutes
is mostly a waste of time...
Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
.gitignore | 2 ++
tests/generic/310 | 35 +++++++++++++++++------------------
2 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/.gitignore b/.gitignore
index 7a10feb..0bd48c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,6 +67,8 @@
/src/preallo_rw_pattern_writer
/src/pwrite_mmap_blocked
/src/randholes
+/src/t_readdir_1
+/src/t_readdir_2
/src/rename
/src/resvtest
/src/runas
diff --git a/tests/generic/310 b/tests/generic/310
index b5316cd..26d2d4a 100755
--- a/tests/generic/310
+++ b/tests/generic/310
@@ -75,12 +75,11 @@ check_kernel_bug()
new_warning=`dmesg | grep -c "^WARNING"`
new_lockdep=`dmesg | grep -c "possible recursive locking detected"`
-
# no kernel bug is detected
if [ $new_bug -eq $nr_bug -a $new_error -eq $nr_error -a \
$new_null -eq $nr_null -a $new_warning -eq $nr_warning -a \
$new_lockdep -eq $nr_lockdep ]; then
- return 1
+ return 0
fi
nr_bug=$new_bug
@@ -88,37 +87,36 @@ check_kernel_bug()
nr_null=$new_null
nr_warning=$new_warning
nr_lockdep=$new_lockdep
+ return 1
}
-mkdir $TEST_DIR/tmp
+
+RUN_TIME=$((30 * $TIME_FACTOR))
+
+SEQ_DIR=$TEST_DIR/$seq
+mkdir -p $SEQ_DIR
for n in {1..4096}; do
- touch $TEST_DIR/tmp/$n
+ touch $SEQ_DIR/$n
done
_test_read()
{
- src/t_readdir_1 $TEST_DIR/tmp &
- sleep 100
+ src/t_readdir_1 $SEQ_DIR &
+ sleep $RUN_TIME
killall src/t_readdir_1
check_kernel_bug
- if [ $? -eq 1 ]; then
- status=0
- else
- echo "error: kernel bug was found, you can see the
- dmesg for more infomation."
+ if [ $? -ne 0 ]; then
+ _fatal "kernel bug detected, check dmesg for more infomation."
fi
}
_test_lseek()
{
- src/t_readdir_2 $TEST_DIR/tmp &
- sleep 100
+ src/t_readdir_2 $SEQ_DIR &
+ sleep $RUN_TIME
killall src/t_readdir_2
check_kernel_bug
- if [ $? -eq 1 ]; then
- status=0
- else
- echo "error: kernel bug was found, you can see the
- dmesg for more infomation."
+ if [ $? -ne 0 ]; then
+ _fatal "kernel bug detected, check dmesg for more infomation."
fi
}
@@ -127,4 +125,5 @@ _test_lseek
# success, all done
echo "*** done"
+status=0
exit
--
1.7.10.4
|