Whamcloud - gitweb
LU-15626 tests: Fix "error" reported by shellcheck
[fs/lustre-release.git] / lustre / tests / sanity-selinux.sh
index 0897b79..4427a2e 100755 (executable)
@@ -18,7 +18,7 @@ ONLY=${ONLY:-"$*"}
 
 LUSTRE=${LUSTRE:-$(dirname $0)/..}
 . $LUSTRE/tests/test-framework.sh
-init_test_env $@
+init_test_env "$@"
 init_logging
 
 ALWAYS_EXCEPT="$SANITY_SELINUX_EXCEPT"
@@ -120,7 +120,7 @@ test_2a() {
 
        mds_path=${mds_path#/}
 
-       $LFS setdirstripe -i0 -c1 ${DIR}/$tdir || error "create dir failed"
+       mkdir_on_mdt0 ${DIR}/$tdir || error "create dir failed"
        mkdir $dirname || error "cannot mkdir $dirname"
 
        local xattrval=$(check_selinux_xattr "mds1" $mds_path)
@@ -544,7 +544,9 @@ create_nodemap() {
        check_nodemap $nm trusted_nodemap 1
 
        sleep 10
+       l_getsepol || error "cannot get sepol"
        sepol=$(l_getsepol | cut -d':' -f2- | xargs)
+       [ -n "$sepol" ] || error "sepol is empty"
        do_facet mgs $LCTL set_param -P nodemap.$nm.sepol="$sepol"
 
        check_nodemap $nm sepol $sepol
@@ -637,9 +639,12 @@ test_21b() {
        [ "$MDS1_VERSION" -lt $(version_code 2.11.56) ] &&
                skip "Need MDS >= 2.11.56"
 
+       stack_trap "restore_opencache" EXIT
+       disable_opencache
+
        local sepol
 
-       mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
+       mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
        echo test > $DIR/$tdir/toopen ||
                error "failed to write to $DIR/$tdir/toopen"
        touch $DIR/$tdir/ftoremove ||
@@ -749,7 +754,9 @@ test_21b() {
        ln $DIR/$tdir/toopen $DIR/$tdir/toopen_hl3 && error "hardlink (3)"
 
        # reset correct sepol
+       l_getsepol || error "cannot get sepol"
        sepol=$(l_getsepol | cut -d':' -f2- | xargs)
+       [ -n "$sepol" ] || error "sepol is empty"
        do_facet mgs $LCTL set_param -P nodemap.c0.sepol="$sepol"
        check_nodemap c0 sepol $sepol