Add test system 'mallet'.
[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 #
11 # creator
12 owner=ddiss@sgi.com
13
14 seq=`basename $0`
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 rm -f $seq.full
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 _filter_dmapi_print_event() {
29     $PERL_PROG -ne '
30 # replace session/file specific output with generic placeholders
31 s/token\s+\d+/token TOKEN/g ;
32 s/sequence\s+\d+/sequence SEQ/g ;
33 s/^\s+parent\s+dir\s+\w+/parent dir PARENT_DIR/g ;
34 s/^\s+name\s+.*/name FILE_NAME/g ;
35 s/^\s+mode\s+bits\s+mode\s+\d+:\s+/mode bits mode MODE: /g ;
36 s/perm\s+[\w|-]+\s[\w|-]+\s[\w|-]+/perm PERMISSIONS/g ;
37 s/,\s+type\s+.*/, type FILE_TYPE/g ;
38 s/^\s+object\s+\w+/object OBJECT/g ;
39 s/^\s+new\s+object\s+\w+/new object OBJECT/g ;
40 s/^\s+handle\s+\w+/handle HANDLE/g ;
41
42 # when print_event is killed, the following is output. trim it
43 s/^\s*print_event: Processing any undelivered event messages.*\n//g ;
44 s/^\s*print_event: Shutting down the session.*\n//g ;
45
46 # trim blank lines
47 s/^\s*\n//g ;
48     print ;'
49 }
50
51 # get standard environment, filters and checks
52 . ./common.rc
53 . ./common.filter
54 . ./common.dmapi
55
56 # real QA test starts here
57 _supported_fs xfs
58 _supported_os Linux
59
60 _require_scratch
61 _scratch_mkfs_xfs >/dev/null 2>&1
62 _dmapi_scratch_mount
63
64 qa_file_noattr=$SCRATCH_MNT/dmapi_file_noattr
65 qa_file_withattr=$SCRATCH_MNT/dmapi_file_withattr
66
67 # run dmapi print_event in background to capture events triggered during test
68 ${DMAPI_QASUITE1_DIR}cmd/print_event $SCRATCH_MNT > $tmp.print_event_out 2>&1 &
69 dmapi_print_event_pid=$!
70
71 # give time for print_event to start capturing events
72 sleep 2
73
74 # enable DMAPI set_return_on_destroy for $SCRATCH_MNT
75 ${DMAPI_COMMON_DIR}cmd/set_return_on_destroy -F $SCRATCH_MNT ATTR_NAME_1
76
77 echo "# create file"
78 touch $qa_file_noattr
79 echo "# remove file"
80 rm -f $qa_file_noattr
81
82 echo "# create file"
83 touch $qa_file_withattr
84 echo "# set dmapi attributes on file"
85 ${DMAPI_QASUITE1_DIR}cmd/set_dmattr $qa_file_withattr ATTR_NAME_1 ATTR_VALUE_1
86 echo "# remove file"
87 rm -f $qa_file_withattr
88
89 # kill off background dmapi print_event process
90 kill $dmapi_print_event_pid
91 # give dmapi print_event time to finish writing out any events not yet output
92 wait
93
94 # dmapi destroy events are asyncronous,  don't rely on fixed ordering of events
95 # in print_event output, use sort.
96 echo "# here comes the dmapi print_event filtered and sorted output"
97 cat $tmp.print_event_out | tee -a $here/$seq.full | _filter_dmapi_print_event | LC_COLLATE=POSIX sort
98 rm $tmp.print_event_out
99
100 status=0
101 exit