2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2007 Silicon Graphics, Inc. All Rights Reserved.
7 # Check for DMAPI destroy events when removing files without attributes
8 # See PV960928 for details
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "exit \$status" 0 1 2 3 15
20 _filter_dmapi_print_event() {
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 ;
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 ;
43 # get standard environment, filters and checks
48 # real QA test starts here
52 _scratch_mkfs_xfs >/dev/null 2>&1
55 qa_file_noattr=$SCRATCH_MNT/dmapi_file_noattr
56 qa_file_withattr=$SCRATCH_MNT/dmapi_file_withattr
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=$!
62 # give time for print_event to start capturing events
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
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
78 rm -f $qa_file_withattr
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
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