xfstests generic 310: check concurrently of readdir and read on the same directory fd
[xfstests-dev.git] / tests / generic / 310
1 #! /bin/bash
2 # FS QA Test No. 310
3 #
4 #Check if there are two threads,one keeps calling read() or lseek(), and
5 #the other calling readdir(), both on the same directory fd.
6 #
7 # Based on a testcase from Li Zefan <lizefan@huawei.com>.
8 #
9 # http://marc.info/?l=linux-kernel&m=136123703211869&w=2
10 #
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2013 HuaWei. All Rights Reserved.
13 #
14 # This program is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation.
17 #
18 # This program is distributed in the hope that it would be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write the Free Software Foundation,
25 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
26 #-----------------------------------------------------------------------
27 #
28 # creator
29 owner=zhaohongjiang@huawei.com
30
31 seq=`basename $0`
32 echo "QA output created by $seq"
33
34 status=1        # failure is the default!
35
36 _cleanup()
37 {
38         rm -rf $TEST_DIR/tmp
39 }
40 trap "_cleanup; exit \$status" 0 1 2 3 15
41
42 # get standard environment, filters and checks
43 . ./common.rc
44 . ./common.filter
45
46 # real QA test starts here
47 _supported_fs generic
48 _supported_os Linux
49
50 mkdir $TEST_DIR/tmp
51 for n in {1..4096}; do
52         touch $TEST_DIR/tmp/$n
53 done
54
55 _test_read()
56 {
57         src/t_readdir_1 $TEST_DIR/tmp &
58         sleep 100
59         killall src/t_readdir_1
60 }
61
62 _test_lseek()
63 {
64         src/t_readdir_2 $TEST_DIR/tmp &
65         sleep 100
66         killall src/t_readdir_2
67 }
68
69 _test_read
70 _test_lseek
71
72 # success, all done
73 echo "*** done"
74 rm -f $seq.full
75 status=0
76 exit