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