fsx: Replace use of bcmp() with memcmp()
[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         for i in $@; do
42                 CHECKED_SID=`${DMAPI_QASUITE1_DIR}../simple/dm_getall_sessions \
43                         | perl -ne "if (/^sids.*[\"|\s]($i)[\"|\s].*/) {print \$1} ;"`
44                 if [ -z "$CHECKED_SID" ] ; then
45                         echo "ERROR: SID(s) not created"
46                         ${DMAPI_QASUITE1_DIR}../simple/dm_getall_sessions >>$seq.full
47                         return
48                 fi
49         done
50 }
51
52 # get standard environment, filters and checks
53 . ./common.rc
54 . ./common.filter
55 . ./common.dmapi
56
57 # real QA test starts here
58 _supported_fs xfs
59 _supported_os Linux IRIX
60
61 _require_scratch
62 _scratch_mkfs_xfs >/dev/null 2>&1
63 _dmapi_scratch_mount
64
65 echo "*** create 3 sessions"
66 _dm_create_session
67 sid1=$newsid
68 _dm_create_session
69 sid2=$newsid
70 _dm_create_session
71 sid3=$newsid
72
73 echo "*** check 3 sessions exist"
74 _check_sids $sid1 $sid2 $sid3
75
76 echo "*** destroy first session"
77 ${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid1
78
79 #should fail
80 echo "*** check first session no longer exists"
81 _check_sids $sid1
82
83 #should still remain
84 echo "*** check last 2 session exist"
85 _check_sids $sid2 $sid3
86
87 echo "*** query"
88 ${DMAPI_QASUITE1_DIR}../simple/dm_query_session -s $sid2
89
90 echo "*** remove remaining sessions"
91 ${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid2
92 ${DMAPI_QASUITE1_DIR}../simple/dm_destroy_session -s $sid3
93
94 echo "*** check second session no longer exists"
95 _check_sids $sid2
96
97 echo "*** check third session no longer exists"
98 _check_sids $sid3
99
100 status=0
101 exit