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