5d9d4ebba737aa9c6d11cf15663133d613a548e0
[xfstests-dev.git] / 168
1 #! /bin/sh
2 # FSQA Test No. 168
3 #
4 # Check for DMAPI destroy events when removing files without attributes
5 # See PV960928 for details
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2007 Silicon Graphics, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25 # creator
26 owner=ddiss@sgi.com
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 rm -f $seq.full
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 _filter_dmapi_print_event() {
43     $PERL_PROG -ne '
44 # replace session/file specific output with generic placeholders
45 s/token\s+\d+/token TOKEN/g ;
46 s/sequence\s+\d+/sequence SEQ/g ;
47 s/^\s+parent\s+dir\s+\w+/parent dir PARENT_DIR/g ;
48 s/^\s+name\s+.*/name FILE_NAME/g ;
49 s/^\s+mode\s+bits\s+mode\s+\d+:\s+/mode bits mode MODE: /g ;
50 s/perm\s+[\w|-]+\s[\w|-]+\s[\w|-]+/perm PERMISSIONS/g ;
51 s/,\s+type\s+.*/, type FILE_TYPE/g ;
52 s/^\s+object\s+\w+/object OBJECT/g ;
53 s/^\s+new\s+object\s+\w+/new object OBJECT/g ;
54 s/^\s+handle\s+\w+/handle HANDLE/g ;
55
56 # when print_event is killed, the following is output. trim it
57 s/^\s*print_event: Processing any undelivered event messages.*\n//g ;
58 s/^\s*print_event: Shutting down the session.*\n//g ;
59
60 # trim blank lines
61 s/^\s*\n//g ;
62     print ;'
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
73
74 _require_scratch
75 _scratch_mkfs_xfs >/dev/null 2>&1
76 _dmapi_scratch_mount
77
78 qa_file_noattr=$SCRATCH_MNT/dmapi_file_noattr
79 qa_file_withattr=$SCRATCH_MNT/dmapi_file_withattr
80
81 # run dmapi print_event in background to capture events triggered during test
82 ${DMAPI_QASUITE1_DIR}cmd/print_event $SCRATCH_MNT > $tmp.print_event_out 2>&1 &
83 dmapi_print_event_pid=$!
84
85 # give time for print_event to start capturing events
86 sleep 2
87
88 # enable DMAPI set_return_on_destroy for $SCRATCH_MNT
89 ${DMAPI_COMMON_DIR}cmd/set_return_on_destroy -F $SCRATCH_MNT ATTR_NAME_1
90
91 echo "# create file"
92 touch $qa_file_noattr
93 echo "# remove file"
94 rm -f $qa_file_noattr
95
96 echo "# create file"
97 touch $qa_file_withattr
98 echo "# set dmapi attributes on file"
99 ${DMAPI_QASUITE1_DIR}cmd/set_dmattr $qa_file_withattr ATTR_NAME_1 ATTR_VALUE_1
100 echo "# remove file"
101 rm -f $qa_file_withattr
102
103 # kill off background dmapi print_event process
104 kill $dmapi_print_event_pid
105 # give dmapi print_event time to finish writing out any events not yet output
106 wait
107
108 # dmapi destroy events are asyncronous,  don't rely on fixed ordering of events
109 # in print_event output, use sort.
110 echo "# here comes the dmapi print_event filtered and sorted output"
111 cat $tmp.print_event_out | tee -a $here/$seq.full | _filter_dmapi_print_event | LC_COLLATE=POSIX sort
112 rm $tmp.print_event_out
113
114 status=0
115 exit