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