xfs: test fallocate ops when rt extent size is and isn't a power of 2
[xfstests-dev.git] / tests / xfs / 168
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2007 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 168
6 #
7 # Check for DMAPI destroy events when removing files without attributes
8 # See PV960928 for details
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 rm -f $seqres.full
17 status=1    # failure is the default!
18 trap "exit \$status" 0 1 2 3 15
19
20 _filter_dmapi_print_event() {
21     $PERL_PROG -ne '
22 # replace session/file specific output with generic placeholders
23 s/token\s+\d+/token TOKEN/g ;
24 s/sequence\s+\d+/sequence SEQ/g ;
25 s/^\s+parent\s+dir\s+\w+/parent dir PARENT_DIR/g ;
26 s/^\s+name\s+.*/name FILE_NAME/g ;
27 s/^\s+mode\s+bits\s+mode\s+\d+:\s+/mode bits mode MODE: /g ;
28 s/perm\s+[\w|-]+\s[\w|-]+\s[\w|-]+/perm PERMISSIONS/g ;
29 s/,\s+type\s+.*/, type FILE_TYPE/g ;
30 s/^\s+object\s+\w+/object OBJECT/g ;
31 s/^\s+new\s+object\s+\w+/new object OBJECT/g ;
32 s/^\s+handle\s+\w+/handle HANDLE/g ;
33
34 # when print_event is killed, the following is output. trim it
35 s/^\s*print_event: Processing any undelivered event messages.*\n//g ;
36 s/^\s*print_event: Shutting down the session.*\n//g ;
37
38 # trim blank lines
39 s/^\s*\n//g ;
40     print ;'
41 }
42
43 # get standard environment, filters and checks
44 . ./common/rc
45 . ./common/filter
46 . ./common/dmapi
47
48 # real QA test starts here
49 _supported_fs xfs
50
51 _require_scratch
52 _scratch_mkfs_xfs >/dev/null 2>&1
53 _dmapi_scratch_mount
54
55 qa_file_noattr=$SCRATCH_MNT/dmapi_file_noattr
56 qa_file_withattr=$SCRATCH_MNT/dmapi_file_withattr
57
58 # run dmapi print_event in background to capture events triggered during test
59 ${DMAPI_QASUITE1_DIR}cmd/print_event $SCRATCH_MNT > $tmp.print_event_out 2>&1 &
60 dmapi_print_event_pid=$!
61
62 # give time for print_event to start capturing events
63 sleep 2
64
65 # enable DMAPI set_return_on_destroy for $SCRATCH_MNT
66 ${DMAPI_COMMON_DIR}cmd/set_return_on_destroy -F $SCRATCH_MNT ATTR_NAME_1
67
68 echo "# create file"
69 touch $qa_file_noattr
70 echo "# remove file"
71 rm -f $qa_file_noattr
72
73 echo "# create file"
74 touch $qa_file_withattr
75 echo "# set dmapi attributes on file"
76 ${DMAPI_QASUITE1_DIR}cmd/set_dmattr $qa_file_withattr ATTR_NAME_1 ATTR_VALUE_1
77 echo "# remove file"
78 rm -f $qa_file_withattr
79
80 # kill off background dmapi print_event process
81 kill $dmapi_print_event_pid
82 # give dmapi print_event time to finish writing out any events not yet output
83 wait
84
85 # dmapi destroy events are asyncronous,  don't rely on fixed ordering of events
86 # in print_event output, use sort.
87 echo "# here comes the dmapi print_event filtered and sorted output"
88 cat $tmp.print_event_out | tee -a $seqres.full | _filter_dmapi_print_event | LC_COLLATE=POSIX sort
89 rm $tmp.print_event_out
90
91 status=0
92 exit