Files
apfstests/151
T
David Disseldorp 48b4c4b13a _check_sids previously grepped the entire output of dm_getall_sessions for sids, which is:
ret=dm_getall_sessions return value
rnelem=number of sessions
sids="sid1 sid2 ... sidn "

If the session id of a previously destroyed session matches the current number of sessions (rnelem),
then _check_sids() $PREV_DESTROYED_SID will _not_ flag ERROR: SID(s) not created.

This fix also makes _check_sids() not rely on sids being consecutive. DMF may be running on a FS in background.

Tested on Linux and Irix.
Merge of master-melb:xfs-cmds:28043a by kenmcd.

  change _check_sids to go through sids line 1 by 1 checking for matches
2007-02-07 14:37:33 +00:00

102 lines
2.1 KiB
Bash
Executable File

#! /bin/sh
# FSQA Test No. 151
#
# Create three DMAPI sessions,
# verify they have been created,
# then distroy first session
#
#-----------------------------------------------------------------------
# Copyright (c) 2006 Silicon Graphics, Inc. All Rights Reserved.
#-----------------------------------------------------------------------
#
# creator
owner=allanr@sgi.com
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
_cleanup_testdir
}
_dm_create_session()
{
eval `${DMAPI_QASUITE1_DIR}../simple/dm_create_session`
echo "RET=$ret NEWSID=NUM"
}
_filter_sid_list()
{
$SED_PROG -e "s/sids=\"[0-9| ]*\"/sids=NUMS/"
}
_check_sids()
{
for i in $@; do
CHECKED_SID=`${DMAPI_QASUITE1_DIR}../simple/dm_getall_sessions \
| perl -ne "if (/^sids.*[\"|\s]($i)[\"|\s].*/) {print \$1} ;"`
if [ -z "$CHECKED_SID" ] ; then
echo "ERROR: SID(s) not created"
${DMAPI_QASUITE1_DIR}../simple/dm_getall_sessions >>$seq.full
return
fi
done
}
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
. ./common.dmapi
# real QA test starts here
_supported_fs xfs
_supported_os Linux IRIX
_require_scratch
_scratch_mkfs_xfs >/dev/null 2>&1
_dmapi_scratch_mount
echo "*** create 3 sessions"
_dm_create_session
sid1=$newsid
_dm_create_session
sid2=$newsid
_dm_create_session
sid3=$newsid
echo "*** check 3 sessions exist"
_check_sids $sid1 $sid2 $sid3
echo "*** destroy first session"
${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid1
#should fail
echo "*** check first session no longer exists"
_check_sids $sid1
#should still remain
echo "*** check last 2 session exist"
_check_sids $sid2 $sid3
echo "*** query"
${DMAPI_QASUITE1_DIR}../simple/dm_query_session -s $sid2
echo "*** remove remaining sessions"
${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid2
${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid3
echo "*** check second session no longer exists"
_check_sids $sid2
echo "*** check third session no longer exists"
_check_sids $sid3
status=0
exit