common/rc: factor out _scratch_xfs_[get|set]_sb_field
[xfstests-dev.git] / tests / xfs / 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
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1    # failure is the default!
34 trap "exit \$status" 0 1 2 3 15
35
36 _dm_create_session()
37 {
38     eval `${DMAPI_QASUITE1_DIR}../simple/dm_create_session`
39     echo "RET=$ret NEWSID=NUM"
40 }
41
42 _filter_sid_list()
43 {
44     $SED_PROG -e "s/sids=\"[0-9| ]*\"/sids=NUMS/"
45 }
46
47 _check_sids()
48 {
49         for i in $@; do
50                 CHECKED_SID=`${DMAPI_QASUITE1_DIR}../simple/dm_getall_sessions \
51                         | perl -ne "if (/^sids.*[\"|\s]($i)[\"|\s].*/) {print \$1} ;"`
52                 if [ -z "$CHECKED_SID" ] ; then
53                         echo "ERROR: SID(s) not created"
54                         ${DMAPI_QASUITE1_DIR}../simple/dm_getall_sessions >>$seqres.full
55                         return
56                 fi
57         done
58 }
59
60 # get standard environment, filters and checks
61 . ./common/rc
62 . ./common/filter
63 . ./common/dmapi
64
65 # real QA test starts here
66 _supported_fs xfs
67 _supported_os Linux
68
69 _require_scratch
70 _scratch_mkfs_xfs >/dev/null 2>&1
71 _dmapi_scratch_mount
72
73 echo "*** create 3 sessions"
74 _dm_create_session
75 sid1=$newsid
76 _dm_create_session
77 sid2=$newsid
78 _dm_create_session
79 sid3=$newsid
80
81 echo "*** check 3 sessions exist"
82 _check_sids $sid1 $sid2 $sid3
83
84 echo "*** destroy first session"
85 ${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid1
86
87 #should fail
88 echo "*** check first session no longer exists"
89 _check_sids $sid1
90
91 #should still remain
92 echo "*** check last 2 session exist"
93 _check_sids $sid2 $sid3
94
95 echo "*** query"
96 ${DMAPI_QASUITE1_DIR}../simple/dm_query_session -s $sid2
97
98 echo "*** remove remaining sessions"
99 ${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid2
100 ${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid3
101
102 echo "*** check second session no longer exists"
103 _check_sids $sid2
104
105 echo "*** check third session no longer exists"
106 _check_sids $sid3
107
108 status=0
109 exit