fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 418
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test 418
6 #
7 # Test pagecache invalidation in buffer/direct write/read combination.
8 #
9 # Fork N children, each child writes to and reads from its own region of the
10 # same test file, and check if what it reads is what it writes. The test region
11 # is determined by N * blksz. Write and read operation can be either direct or
12 # buffered.
13 #
14 # Regression test for commit c771c14baa33 ("iomap: invalidate page caches
15 # should be after iomap_dio_complete() in direct write")
16 #
17 . ./common/preamble
18 _begin_fstest auto rw
19
20 # Import common functions.
21 . ./common/filter
22
23 # real QA test starts here
24 _supported_fs generic
25 _require_test
26 _require_odirect
27 _require_block_device $TEST_DEV
28 _require_test_program "dio-invalidate-cache"
29 _require_test_program "feature"
30
31 diotest=$here/src/dio-invalidate-cache
32 testfile=$TEST_DIR/$seq-diotest
33 sectorsize=`blockdev --getss $TEST_DEV`
34 pagesize=`$here/src/feature -s`
35
36 # test case array, test different write/read combinations
37 # -r: use direct read
38 # -w: use direct write
39 # -t: truncate file to final size before test, i.e. write to hole
40 # -p: fallocate whole file before test, i.e. write to allocated but unwritten extents
41 # -F: fulfill whole file before test, i.e. write to allocated & written extents
42 t_cases=(
43         "-w"
44         "-wt"
45         "-wp"
46         "-wF"
47         "-r"
48         "-rt"
49         "-rp"
50         "-rF"
51         "-rw"
52         "-rwt"
53         "-rwp"
54         "-rwF"
55 )
56
57 runtest()
58 {
59         local i=0
60         local tc=""
61         local loop=$1
62         shift
63
64         for tc in ${t_cases[*]}; do
65                 echo "diotest $tc $*" >> $seqres.full
66                 i=0
67                 while [ $i -lt $loop ]; do
68                         $diotest $tc $* -f $testfile
69                         if [ $? -ne 0 ]; then
70                                 echo "diotest $tc $* failed at loop $i" | \
71                                         tee -a $seqres.full
72                                 break
73                         fi
74                         let i=i+1
75                 done
76         done
77 }
78
79 while [ $sectorsize -le $((pagesize * 2)) ]; do
80         # reproducer for the original bug
81         runtest $((10 * LOAD_FACTOR)) -b $sectorsize -n 3 -i 1
82         # try more processes and iterations
83         runtest $((5 * LOAD_FACTOR))  -b $sectorsize -n 8 -i 4
84         sectorsize=$((sectorsize * 2))
85 done
86 echo "Silence is golden"
87
88 # success, all done
89 status=0
90 exit