-
[xfstests-dev.git] / 151
1 #! /bin/sh
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 #
12 # creator
13 owner=allanr@sgi.com
14
15 seq=`basename $0`
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1    # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25     _cleanup_testdir
26 }
27
28 _dm_create_session()
29 {
30     eval `${DMAPI_QASUITE1_DIR}../simple/dm_create_session`
31     echo "RET=$ret NEWSID=NUM"
32 }
33
34 _filter_sid_list()
35 {
36     $SED_PROG -e "s/sids=\"[0-9| ]*\"/sids=NUMS/"
37 }
38
39 _check_sids()
40 {
41     ${DMAPI_QASUITE1_DIR}../simple/dm_getall_sessions | grep "$@" > /dev/null
42     if [ $? -ne 0 ] ; then
43         echo "ERROR: SID(s) not created"
44         ${DMAPI_QASUITE1_DIR}../simple/dm_getall_sessions >>$seq.full
45     fi
46 }
47
48 # get standard environment, filters and checks
49 . ./common.rc
50 . ./common.filter
51 . ./common.dmapi
52
53 # real QA test starts here
54 _supported_fs xfs
55 _supported_os Linux IRIX
56
57 _require_scratch
58 _scratch_mkfs_xfs >/dev/null 2>&1
59 _dmapi_scratch_mount
60
61 echo "*** create 3 sessions"
62 _dm_create_session
63 sid1=$newsid
64 _dm_create_session
65 sid2=$newsid
66 _dm_create_session
67 sid3=$newsid
68
69 echo "*** check 3 sessions exist"
70 _check_sids "$sid1 $sid2 $sid3"
71
72 echo "*** destroy first session"
73 ${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid1
74
75 #should fail
76 echo "*** check first session no longer exists"
77 _check_sids "$sid1"
78
79 #should still remain
80 echo "*** check last 2 session exist"
81 _check_sids "$sid2 $sid3"
82
83 echo "*** query"
84 ${DMAPI_QASUITE1_DIR}../simple/dm_query_session -s $sid2
85
86 echo "*** remove remaining sessions"
87 ${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid2
88 ${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid3
89
90 echo "*** check second session no longer exists"
91 _check_sids "$sid2"
92
93 echo "*** check third session no longer exists"
94 _check_sids "$sid3"
95
96 status=0
97 exit