Fio 3.15
[fio.git] / t / readonly.sh
1 #!/bin/bash
2 #
3 # Do some basic test of the --readonly parameter
4 #
5 # DUT should be a device that accepts read, write, and trim operations
6 #
7 # Example usage:
8 #
9 # DUT=/dev/fioa t/readonly.sh
10 #
11 TESTNUM=1
12
13 #
14 # The first parameter is the return code
15 # The second parameter is 0        if the return code should be 0
16 #                         positive if the return code should be positive
17 #
18 check () {
19         echo "********************"
20
21         if [ $2 -gt 0 ]; then
22                 if [ $1 -eq 0 ]; then
23                         echo "Test $TESTNUM failed"
24                         echo "********************"
25                         exit 1
26                 else
27                         echo "Test $TESTNUM passed"
28                 fi
29         else
30                 if [ $1 -gt 0 ]; then
31                         echo "Test $TESTNUM failed"
32                         echo "********************"
33                         exit 1
34                 else
35                         echo "Test $TESTNUM passed"
36                 fi
37         fi
38
39         echo "********************"
40         echo
41         TESTNUM=$((TESTNUM+1))
42 }
43
44 ./fio --name=test --filename=$DUT --rw=randread  --readonly --time_based --runtime=1s &> /dev/null
45 check $? 0
46 ./fio --name=test --filename=$DUT --rw=randwrite --readonly --time_based --runtime=1s &> /dev/null
47 check $? 1
48 ./fio --name=test --filename=$DUT --rw=randtrim  --readonly --time_based --runtime=1s &> /dev/null
49 check $? 1
50
51 ./fio --name=test --filename=$DUT --readonly --rw=randread  --time_based --runtime=1s &> /dev/null
52 check $? 0
53 ./fio --name=test --filename=$DUT --readonly --rw=randwrite --time_based --runtime=1s &> /dev/null
54 check $? 1
55 ./fio --name=test --filename=$DUT --readonly --rw=randtrim  --time_based --runtime=1s &> /dev/null
56 check $? 1
57
58 ./fio --name=test --filename=$DUT --rw=randread  --time_based --runtime=1s &> /dev/null
59 check $? 0
60 ./fio --name=test --filename=$DUT --rw=randwrite --time_based --runtime=1s &> /dev/null
61 check $? 0
62 ./fio --name=test --filename=$DUT --rw=randtrim  --time_based --runtime=1s &> /dev/null
63 check $? 0
64
65 ./fio t/jobs/readonly-r.fio --readonly &> /dev/null
66 check $? 0
67 ./fio t/jobs/readonly-w.fio --readonly &> /dev/null
68 check $? 1
69 ./fio t/jobs/readonly-t.fio --readonly &> /dev/null
70 check $? 1
71
72 ./fio --readonly t/jobs/readonly-r.fio &> /dev/null
73 check $? 0
74 ./fio --readonly t/jobs/readonly-w.fio &> /dev/null
75 check $? 1
76 ./fio --readonly t/jobs/readonly-t.fio &> /dev/null
77 check $? 1
78
79 ./fio t/jobs/readonly-r.fio &> /dev/null
80 check $? 0
81 ./fio t/jobs/readonly-w.fio &> /dev/null
82 check $? 0
83 ./fio t/jobs/readonly-t.fio &> /dev/null
84 check $? 0