trap cleanup SIGHUP SIGINT SIGTERM
# gets echoclient device number and attach it to the client UUID
-#
+# Results are returned by an echo followed by an exit
+# This must run in a subshell.
+#
# parameter: 1. hostname
# 2. client name, ex:- ns8:ECHO_ns8
# 3. name of ost instances, ex:- lustre-OST0001
get_ec_devno () {
+ exec 8>&1 1>&2
local host=$1
local client_name="$2"
local ost_name="$3"
if [ -z "$client_name" ]; then
if [ -z "$ost_name" ]; then
- echo "client and ost name both null" 1>&2
- return
+ echo "client and ost name both null"
+ exit 1
fi
client_name=${ost_name}_ecc
fi
ec=`get_devno $host echo_client $client_name`
if [ -n "$ec" ]; then
- echo $ec $client_name $client_name
- return
+ echo $ec $client_name $client_name >&8
+ exit 0
fi
if [ -z "$ost_name" ]; then
- echo "no echo client and ost_name not set, client: $client_name, host: $host" 1>&2
- return
+ echo "no echo client and ost_name not set, client:" \
+ "$client_name, host: $host"
+ exit 1
fi
ost=`get_devno $host obdfilter $ost_name`
if [ -z "$ost" ]; then
- echo "OST $ost_name not setup" 1>&2
- return
+ echo "OST $ost_name not setup"
+ exit 1
fi
client_name=${ost_name}_ecc
remote_shell $host "$lctl <<EOF
EOF"
ec=`get_devno $host echo_client $client_name`
if [ -z "$ec" ]; then
- echo "Can't setup echo-client" 1>&2
- return
+ echo "Can't setup echo-client"
+ exit 1
fi
- echo $ec $client_name 1
+ echo $ec $client_name 1 >&8
+ exit 0
}
# Create echo-clients using osc_names and osc_uuid
# client systems on which this test runs.]
# include library
-source libecho
+source $(dirname $0)/libecho
# The following variables can be set in the environment, or on the
# command line
# End of variables
# create a set of objects, check there are 'n' contiguous ones and
-# return the first or 'ERROR'
+# echo out the first or 'ERROR'
# parameter: 1. hostname
# 2. device number
# 3. number of object to be created (specified by user)
prev=0
count=0
error=0
- while read line; do
- echo "$line" | grep -q 'is object id'
- if [ $? -ne 0 ]; then
- continue
- fi
- if [ $first -eq 0 ]; then
- first=$(echo $line | awk '{print $6}')
- first=$(printf "%d" $first)
- prev=$first
- count=1
- else
- obj=$(echo $line | awk '{print $6}')
- obj=$(printf "%d" $obj)
- diff=$((obj - (prev+1)))
- if [ $diff -ne 0 ]; then
- error=1
- fi
- prev=$obj
- count=$((count+1))
- fi
- done < $rfile
+
+ # Count number of objects (lines containing " is object id "), and
+ # ensure that the objects numbers are sequential.
+ #
+ exec 3< $rfile
+ while read -u3 line; do
+ case "$line" in
+ ( *' is object id '* )
+ set -- $line
+ if test $(( count += 1 )) -gt 1 ; then
+ (( $6 != prev + 1 )) && error=1
+ else
+ first=$(( $6 + 0 ))
+ fi
+ prev=$6
+ ;;
+ esac
+ done
+ exec 3<&-
+
if [ $nobj -ne $count ]; then
echo "ERROR: $nobj != $count" >&2
cat $rfile >&2
echo "ERROR"
elif [ $error -ne 0 ]; then
- echo "ERROR: non contiguous objs found" >&2
+ echo "ERROR: non contiguous objs found" >&2
+ echo ERROR
else
echo $first
fi
+ return $error
}
# destroys all objects created in create_objects routine