Whamcloud - gitweb
LU-15103 tests: clean up busy cifs mount
[fs/lustre-release.git] / lustre / tests / lutf.sh
1 # Run select tests by setting ONLY, or as arguments to the script.
2 # Skip specific tests by setting EXCEPT.
3 #
4
5 export ONLY=${ONLY:-"$*"}
6 export SUITE=${SUITE:-"$*"}
7 export PATTERN=${PATTERN:-"$*"}
8
9 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
10 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
11
12 LUSTRE=${LUSTRE:-$(dirname $0)/..}
13
14 . $LUSTRE/tests/test-framework.sh
15 init_test_env $@
16 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
17 init_logging
18
19 # bug number for skipped test:
20 ALWAYS_EXCEPT="$SANITY_LNET_EXCEPT "
21
22 export LNETCTL=${LNETCTL:-"$LUSTRE/../lnet/utils/lnetctl"}
23 [ ! -f "$LNETCTL" ] &&
24         export LNETCTL=$(which lnetctl 2> /dev/null)
25 [[ -z $LNETCTL ]] && skip "Need lnetctl"
26
27 restore_mounts=false
28 if is_mounted $MOUNT || is_mounted $MOUNT2; then
29         cleanupall || error "Failed cleanup prior to test execution"
30         restore_mounts=true
31 fi
32
33 cleanup_lnet() {
34         echo "Cleaning up LNet"
35         lsmod | grep -q lnet &&
36                 $LNETCTL lnet unconfigure 2>/dev/null
37         unload_modules
38 }
39
40 restore_modules=false
41 if module_loaded lnet ; then
42         cleanup_lnet || error "Failed to unload modules before test execution"
43         restore_modules=true
44 fi
45
46 cleanup_testsuite() {
47         trap "" EXIT
48         cleanup_lnet
49         if $restore_mounts; then
50                 setupall || error "Failed to setup Lustre after test execution"
51         elif $restore_modules; then
52                 load_modules ||
53                         error "Couldn't load modules after test execution"
54         fi
55         return 0
56 }
57
58 set_env_vars_on_remote() {
59         local list=$(comma_list $(all_nodes))
60         do_rpc_nodes "$list" "echo $PATH; echo $LUSTRE; echo $LNETCTL; echo $LCTL"
61 }
62
63 set_env_vars_on_remote
64
65 rm /tmp/tf.skip
66
67 # do not exit if LUTF fails
68 set +e
69
70 echo "+++++++++++STARTING LUTF"
71 . $LUSTRE/tests/lutf/python/config/lutf_start.sh $CONFIG
72 rc=$?
73 echo "-----------STOPPING LUTF: $rc"
74
75 if [ -d /tmp/lutf/ ]; then
76         tar -czf /tmp/lutf.tar.gz /tmp/lutf
77         mv /tmp/lutf.tar.gz $LOGDIR
78 fi
79
80
81 complete $SECONDS
82
83 cleanup_testsuite
84
85 exit $rc