Whamcloud - gitweb
LU-3503 test: only create single directory by test_mkdir()
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index 3182e26..97b7aad 100644 (file)
@@ -3462,19 +3462,10 @@ check_and_setup_lustre() {
 
        if [ $(lower $OSD_TRACK_DECLARES_LBUG) == 'yes' ] ; then
                local facets="$(get_facets OST),$(get_facets MDS),mgs"
-               local facet
-               local nodes
-               local node
-               for facet in ${facets//,/ }; do
-                       if [ $(facet_fstype $node) == "ldiskfs" ] ; then
-                               node=$(facet_host ${facet})
-                               nodes="$nodes $node"
-                       fi
-               done
+               local nodes="$(facets_hosts ${facets})"
                if [ -n "$nodes" ] ; then
-                       nodes=$(for i in $nodes; do echo $i; done | sort -u)
-                       do_nodes $(comma_list $nodes) "$LCTL set_param \
-                                osd-ldiskfs.track_declares_assert=1"
+                       do_nodes $nodes "$LCTL set_param \
+                                osd-ldiskfs.track_declares_assert=1 || true"
                fi
        fi
 
@@ -6237,41 +6228,28 @@ generate_logname() {
        echo "$TESTLOG_PREFIX.$TESTNAME.$logname.$(hostname -s).log"
 }
 
-# mkdir directory on different MDTs
+# make directory on different MDTs
 test_mkdir() {
        local option
        local parent
        local child
        local path
-       local dir
        local rc=0
 
-       if [ $# -eq 2 ]; then
-               option=$1
-               path=$2
-       else
-               path=$1
-       fi
-
-       child=${path##*/}
-       parent=${path%/*}
+       case $# in
+               1) path=$1;;
+               2) option=$1
+                  path=$2;;
+               *) error "Only creating single directory is supported";;
+       esac
 
-       if [ "$parent" == "$child" ]; then
-               parent=$(pwd)
-       fi
+       child=$(basename $path)
+       parent=$(dirname $path)
 
-       if [ "$option" == "-p" -a -d ${parent}/${child} ]; then
+       if [ "$option" == "-p" -a -d $parent/$child ]; then
                return $rc
        fi
 
-       # it needs to check whether there is further / in child
-       dir=$(echo $child | awk -F '/' '{print $2}')
-       if [ ! -z "$dir" ]; then
-               local subparent=$(echo $child | awk -F '/' '{ print $1 }')
-               parent=${parent}"/"${subparent}
-               child=$dir
-       fi
-
        if [ ! -d ${parent} ]; then
                if [ "$option" == "-p" ]; then
                        mkdir -p ${parent}
@@ -6281,19 +6259,18 @@ test_mkdir() {
        fi
 
        if [ $MDSCOUNT -le 1 ]; then
-               mkdir $option ${parent}/${child} || rc=$?
+               mkdir $option $parent/$child || rc=$?
        else
                local mdt_idx=$($LFS getstripe -M $parent)
+               local test_num=$(echo $testnum | sed -e 's/[^0-9]*//g')
 
                if [ "$mdt_idx" -ne 0 ]; then
-                       mkdir $option ${parent}/${child} || rc=$?
-                       return $rc
+                       mkdir $option $parent/$child || rc=$?
+               else
+                       mdt_idx=$((test_num % MDSCOUNT))
+                       echo "mkdir $mdt_idx for $parent/$child"
+                       $LFS setdirstripe -i $mdt_idx $parent/$child || rc=$?
                fi
-
-               local test_num=$(echo $testnum | sed -e 's/[^0-9]*//g')
-               local mdt_idx=$((test_num % MDSCOUNT))
-               echo "mkdir $mdt_idx for ${parent}/${child}"
-               $LFS setdirstripe -i $mdt_idx ${parent}/${child} || rc=$?
        fi
        return $rc
 }