xfstests: update README file to document some recent changes
[xfstests-dev.git] / 151
1 #! /bin/bash
2 # FSQA Test No. 151
3 #
4 # Create three DMAPI sessions,
5 # verify they have been created,
6 # then distroy first session
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #
24 #-----------------------------------------------------------------------
25 #
26 # creator
27 owner=allanr@sgi.com
28
29 seq=`basename $0`
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1    # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39     _cleanup_testdir
40 }
41
42 _dm_create_session()
43 {
44     eval `${DMAPI_QASUITE1_DIR}../simple/dm_create_session`
45     echo "RET=$ret NEWSID=NUM"
46 }
47
48 _filter_sid_list()
49 {
50     $SED_PROG -e "s/sids=\"[0-9| ]*\"/sids=NUMS/"
51 }
52
53 _check_sids()
54 {
55         for i in $@; do
56                 CHECKED_SID=`${DMAPI_QASUITE1_DIR}../simple/dm_getall_sessions \
57                         | perl -ne "if (/^sids.*[\"|\s]($i)[\"|\s].*/) {print \$1} ;"`
58                 if [ -z "$CHECKED_SID" ] ; then
59                         echo "ERROR: SID(s) not created"
60                         ${DMAPI_QASUITE1_DIR}../simple/dm_getall_sessions >>$seq.full
61                         return
62                 fi
63         done
64 }
65
66 # get standard environment, filters and checks
67 . ./common.rc
68 . ./common.filter
69 . ./common.dmapi
70
71 # real QA test starts here
72 _supported_fs xfs
73 _supported_os Linux IRIX
74
75 _require_scratch
76 _scratch_mkfs_xfs >/dev/null 2>&1
77 _dmapi_scratch_mount
78
79 echo "*** create 3 sessions"
80 _dm_create_session
81 sid1=$newsid
82 _dm_create_session
83 sid2=$newsid
84 _dm_create_session
85 sid3=$newsid
86
87 echo "*** check 3 sessions exist"
88 _check_sids $sid1 $sid2 $sid3
89
90 echo "*** destroy first session"
91 ${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid1
92
93 #should fail
94 echo "*** check first session no longer exists"
95 _check_sids $sid1
96
97 #should still remain
98 echo "*** check last 2 session exist"
99 _check_sids $sid2 $sid3
100
101 echo "*** query"
102 ${DMAPI_QASUITE1_DIR}../simple/dm_query_session -s $sid2
103
104 echo "*** remove remaining sessions"
105 ${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid2
106 ${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid3
107
108 echo "*** check second session no longer exists"
109 _check_sids $sid2
110
111 echo "*** check third session no longer exists"
112 _check_sids $sid3
113
114 status=0
115 exit