Debian Codegraph @

tests/blockwise-compat-test

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 # set _FORCE_LOCAL environment variable to run blockwise unit tests even on local
4 # nfs. Some tests will fail because nfs is eager to write for example 4095 bytes
5 # in O_DIRECT mode.
6
7 BW_UNIT=./unit-utils-io
8 STRACE=strace
9 MNT_DIR=./mnt_bwunit
10 LOCAL_FILE=./blockwise_localfile
11
12 # $1 path to scsi debug bdev
13 scsi_debug_teardownscip-shell shell shell-project 0.0.0 scsi_debug_teardown().() {
14 local _tries=15;
15
16 while [scip-shell system . . `[`. -b "$1" -a $_tries -gt 0 ]; do
17 rmmod scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
18 if [scip-shell system . . `[`. -b "$1" ]; then
19 sleepscip-shell system . . sleep. .1
20 _tries=$((_tries-1))
21 fi
22 done
23
24 testscip-shell system . . test. ! -b "$1" || rmmod scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
25 }
26
27 cleanupscip-shell shell shell-project 0.0.0 cleanup().() {
28 if [scip-shell system . . `[`. -d "$MNT_DIR" ] ; then
29 umountscip-shell system . . umount. -f $MNT_DIR 2>/dev/nullscip-shell filesystem . . `/dev/null`.
30 rmdirscip-shell system . . rmdir. $MNT_DIR 2>/dev/nullscip-shell filesystem . . `/dev/null`.
31 fi
32 rmscip-shell system . . rm. -f $LOCAL_FILE 2> /dev/nullscip-shell filesystem . . `/dev/null`.
33 scsi_debug_teardownscip-shell shell shell-project 0.0.0 scsi_debug_teardown(). "$DEV" || exit 100
34 }
35
36 failscip-shell shell shell-project 0.0.0 fail().()
37 {
38 if [scip-shell system . . `[`. -n "$1" ] ; then echoscip-shell system . . echo. "FAIL $1" ; else echoscip-shell system . . echo. "FAIL" ; fi
39 cleanupscip-shell shell shell-project 0.0.0 cleanup().
40 exit 100
41 }
42
43 _sigchldscip-shell shell shell-project 0.0.0 _sigchld().() { local c=$?; [scip-shell system . . `[`. $c -eq 139 ] && failscip-shell shell shell-project 0.0.0 fail(). "Segfault"; [scip-shell system . . `[`. $c -eq 134 ] && failscip-shell shell shell-project 0.0.0 fail(). "Aborted"; }
44 trap _sigchld CHLD
45
46 fail_countscip-shell shell shell-project 0.0.0 fail_count().()
47 {
48 echoscip-shell system . . echo. "$MSG[FAIL]"
49 FAILS=$((FAILS+1))
50 }
51
52 warn_countscip-shell shell shell-project 0.0.0 warn_count().()
53 {
54 echoscip-shell system . . echo. "$MSG[WARNING]"
55 WARNS=$((WARNS+1))
56 }
57
58 skipscip-shell shell shell-project 0.0.0 skip().()
59 {
60 echoscip-shell system . . echo. "TEST SKIPPED: $1"
61 cleanupscip-shell shell shell-project 0.0.0 cleanup().
62 exit 77
63 }
64
65 add_devicescip-shell shell shell-project 0.0.0 add_device().() {
66 rmmod scsi_debug >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
67 if [scip-shell system . . `[`. -d /sys/module/scsi_debugscip-shell filesystem . . `/sys/module/scsi_debug`. ] ; then
68 skipscip-shell shell shell-project 0.0.0 skip(). "Cannot use scsi_debug module (in use or compiled-in)."
69 fi
70 modprobe scsi_debug $@ delay=0 >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
71 if [scip-shell system . . `[`. $? -ne 0 ] ; then
72 skipscip-shell shell shell-project 0.0.0 skip(). "This kernel seems to not support proper scsi_debug module."
73 fi
74 sleepscip-shell system . . sleep. 1
75 DEV=$(grepscip-shell system . . grep. -l -e scsi_debug /sys/block/*/device/model | cutscip-shell system . . cut. -f4 -d /scip-shell filesystem . . `/`.)
76 DEV="/dev/$DEV"
77 [scip-shell system . . `[`. -b $DEV ] || failscip-shell shell shell-project 0.0.0 fail(). "Cannot find $DEV."
78 }
79
80 fallocscip-shell shell shell-project 0.0.0 falloc().() {
81 ddscip-shell system . . dd. if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$2 bs=1M count=$1 2> /dev/nullscip-shell filesystem . . `/dev/null`.
82 }
83
84 run_all_in_fsscip-shell shell shell-project 0.0.0 run_all_in_fs().() {
85 for file in $(lsscip-shell system . . ls. img_fs_*.img.xz) ; do
86 echoscip-shell system . . echo. -n "Run tests in $file put on top block device. "
87 xzscip-shell system . . xz. -d -c $file | ddscip-shell system . . dd. of=$DEV bs=1M 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). "bad image"
88 [scip-shell system . . `[`. ! -d $MNT_DIR ] && mkdirscip-shell system . . mkdir. $MNT_DIR
89 mountscip-shell system . . mount. $DEV $MNT_DIR 2>/dev/nullscip-shell filesystem . . `/dev/null`.
90 if [scip-shell system . . `[`. $? -ne 0 ]; then
91 echoscip-shell system . . echo. "[N/A]"
92 continue;
93 fi
94 rmscip-shell system . . rm. -rf $MNT_DIR/* 2>/dev/nullscip-shell filesystem . . `/dev/null`.
95 local tfile=$MNT_DIR/bwunit_tstfile
96 fallocscip-shell shell shell-project 0.0.0 falloc(). $DEVSIZEMB $tfile || failscip-shell shell shell-project 0.0.0 fail(). "enospc?"
97 local iobsize=$(statscip-shell system . . stat. -c "%o" $tfile)
98 testscip-shell system . . test. -n "$iobsize" -a $iobsize -gt 0 || failscip-shell shell shell-project 0.0.0 fail().
99 local oldbsize=$BSIZE
100 BSIZE=$iobsize
101 run_allscip-shell shell shell-project 0.0.0 run_all(). $tfile
102 BSIZE=$oldbsize
103 umountscip-shell system . . umount. $MNT_DIR || failscip-shell shell shell-project 0.0.0 fail().
104 echoscip-shell system . . echo. "[OK]"
105 done
106 }
107
108 trunc_filescip-shell shell shell-project 0.0.0 trunc_file().() {
109 testscip-shell system . . test. $1 -eq 0 || truncatescip-shell system . . truncate. -c -s $1 $2 2>/dev/nullscip-shell filesystem . . `/dev/null`. || ddscip-shell system . . dd. if=/dev/zeroscip-shell filesystem . . `/dev/zero`. of=$2 bs=$1 count=1 2>/dev/nullscip-shell filesystem . . `/dev/null`. || failscip-shell shell shell-project 0.0.0 fail(). "Failed to truncate test file $2."
110 }
111
112 RUNscip-shell shell shell-project 0.0.0 RUN().() {
113 local _res=$1
114 shift
115 local _dev=$1
116 shift
117 local _fn=$1
118 shift
119 local _type="bdev"
120 local _fsize=0
121
122 testscip-shell system . . test. -b $_dev || {
123 _type="file"
124 _fsize=$(statscip-shell system . . stat. -c "%s" $_dev)
125 }
126
127 case "$_res" in
128 P)
129 MSG="Testing $_fn on $_type with params $@ [expecting TRUE]..."
130 $BW_UNIT $_dev $_fn $@
131 if [scip-shell system . . `[`. $? -ne 0 ]; then
132 if [scip-shell system . . `[`. $_type = "file" ]; then
133 warn_countscip-shell shell shell-project 0.0.0 warn_count().
134 else
135 fail_countscip-shell shell shell-project 0.0.0 fail_count().
136 fi
137 trunc_filescip-shell shell shell-project 0.0.0 trunc_file(). $_fsize $_dev
138 testscip-shell system . . test. -z "$STRACE" || $STRACE -o ./$BW_UNIT-fail-$FAILS-should-pass.log $BW_UNIT $_dev $_fn $@ 2> /dev/nullscip-shell filesystem . . `/dev/null`.
139 else
140 MSG="$MSG[OK]"
141 fi
142 ;;
143 F)
144 MSG="Testing $_fn on $_type with params $@ [expecting FALSE]..."
145 $BW_UNIT $_dev $_fn $@ 2> /dev/nullscip-shell filesystem . . `/dev/null`.
146 if [scip-shell system . . `[`. $? -eq 0 ]; then
147 if [scip-shell system . . `[`. $_type = "file" ]; then
148 warn_countscip-shell shell shell-project 0.0.0 warn_count().
149 else
150 fail_countscip-shell shell shell-project 0.0.0 fail_count().
151 fi
152 trunc_filescip-shell shell shell-project 0.0.0 trunc_file(). $_fsize $_dev
153 testscip-shell system . . test. -z "$STRACE" || $STRACE -o ./$BW_UNIT-fail-$FAILS-should-fail.log $BW_UNIT $_dev $_fn $@ 2> /dev/nullscip-shell filesystem . . `/dev/null`.
154 else
155 MSG="$MSG[OK]"
156 fi
157 ;;
158 *)
159 failscip-shell shell shell-project 0.0.0 fail(). "Internal test error"
160 ;;
161 esac
162
163 trunc_filescip-shell shell shell-project 0.0.0 trunc_file(). $_fsize $_dev
164 }
165
166 run_allscip-shell shell shell-project 0.0.0 run_all().() {
167 if [scip-shell system . . `[`. -b "$1" ]; then
168 BD_FAIL="F"
169 else
170 BD_FAIL="P"
171 fi
172
173 # buffer io support only blocksize aligned ios
174 # device/file fn_name length
175 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_buffer $BSIZE
176 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_buffer $((2*BSIZE))
177 RUNscip-shell shell shell-project 0.0.0 RUN(). "F" $1 read_buffer $((BSIZE-1))
178 RUNscip-shell shell shell-project 0.0.0 RUN(). "F" $1 read_buffer $((BSIZE+1))
179 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_buffer 0
180
181 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_buffer $BSIZE
182 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_buffer $((2*BSIZE))
183
184 RUNscip-shell shell shell-project 0.0.0 RUN(). "F" $1 write_buffer $((BSIZE-1))
185 RUNscip-shell shell shell-project 0.0.0 RUN(). "F" $1 write_buffer $((BSIZE+1))
186 RUNscip-shell shell shell-project 0.0.0 RUN(). "F" $1 write_buffer 0
187
188 # basic blockwise functions
189 # device/file fn_name length bsize
190 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_blockwise 0 $BSIZE
191 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_blockwise $((BSIZE)) $BSIZE
192 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_blockwise $((BSIZE-1)) $BSIZE
193 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_blockwise $((BSIZE+1)) $BSIZE
194 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_blockwise $((DEVSIZE)) $BSIZE
195 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_blockwise $((DEVSIZE-1)) $BSIZE
196 RUNscip-shell shell shell-project 0.0.0 RUN(). "F" $1 read_blockwise $((DEVSIZE+1)) $BSIZE
197
198 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_blockwise 0 $BSIZE
199 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_blockwise $((BSIZE)) $BSIZE
200 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_blockwise $((BSIZE-1)) $BSIZE
201 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_blockwise $((BSIZE+1)) $BSIZE
202 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_blockwise $((DEVSIZE)) $BSIZE
203 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_blockwise $((DEVSIZE-1)) $BSIZE
204 RUNscip-shell shell shell-project 0.0.0 RUN(). "$BD_FAIL" $1 write_blockwise $((DEVSIZE+1)) $BSIZE
205
206 # seek variant blockwise functions
207 # device/file fn_name length bsize offset
208 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 0 $BSIZE 0
209 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 0 $BSIZE 1
210 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 0 $BSIZE $((DEVSIZE))
211 # length = 0 is significant here
212 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 0 $BSIZE $((DEVSIZE+1))
213
214 # beginning of device
215 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 1 $BSIZE 0
216 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 1 $BSIZE 1
217 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 1 $BSIZE $((BSIZE-1))
218 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 1 $BSIZE $((BSIZE/2))
219
220 # somewhere in the 'middle'
221 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 1 $BSIZE $BSIZE
222 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 1 $BSIZE $((BSIZE+1))
223 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 1 $BSIZE $((2*BSIZE-1))
224 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 1 $BSIZE $((BSIZE+BSIZE/2-1))
225
226 # cross-sector tests
227 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 2 $BSIZE $((BSIZE-1))
228 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((BSIZE+1)) $BSIZE $((BSIZE-1))
229 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((BSIZE+2)) $BSIZE $((BSIZE-1))
230 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 2 $BSIZE $((2*BSIZE-1))
231 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((BSIZE+1)) $BSIZE $((2*BSIZE-1))
232 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((BSIZE+2)) $BSIZE $((2*BSIZE-1))
233
234 # including one whole sector
235 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((BSIZE+2)) $BSIZE $((BSIZE))
236 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((2*BSIZE)) $BSIZE $((BSIZE+1))
237 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((2*BSIZE)) $BSIZE $((BSIZE-1))
238 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((BSIZE+2)) $BSIZE $((BSIZE-1))
239 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((2*BSIZE)) $BSIZE $((BSIZE+1))
240 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((3*BSIZE-2)) $BSIZE $((BSIZE+1))
241
242 # hitting exactly the sector boundary
243 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((BSIZE-1)) $BSIZE 1
244 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((BSIZE-1)) $BSIZE $((BSIZE+1))
245 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((BSIZE+1)) $BSIZE $((BSIZE-1))
246 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((BSIZE+1)) $BSIZE $((2*BSIZE-1))
247
248 # device end
249 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise 1 $BSIZE $((DEVSIZE-1))
250 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((BSIZE-1)) $BSIZE $((DEVSIZE-BSIZE+1))
251 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((BSIZE)) $BSIZE $((DEVSIZE-BSIZE))
252 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 read_lseek_blockwise $((BSIZE+1)) $BSIZE $((DEVSIZE-BSIZE-1))
253
254 # this must fail on both device and file
255 RUNscip-shell shell shell-project 0.0.0 RUN(). "F" $1 read_lseek_blockwise 1 $BSIZE $((DEVSIZE))
256 RUNscip-shell shell shell-project 0.0.0 RUN(). "F" $1 read_lseek_blockwise $((BSIZE-1)) $BSIZE $((DEVSIZE-BSIZE+2))
257 RUNscip-shell shell shell-project 0.0.0 RUN(). "F" $1 read_lseek_blockwise $((BSIZE)) $BSIZE $((DEVSIZE-BSIZE+1))
258 RUNscip-shell shell shell-project 0.0.0 RUN(). "F" $1 read_lseek_blockwise $((BSIZE+1)) $BSIZE $((DEVSIZE-BSIZE))
259
260 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 0 $BSIZE 0
261 # TODO: this may pass but must not write a byte (write(0) is undefined).
262 # Test it with underlying dm-error or phony read/write syscalls.
263 # Skipping read is optimization.
264 # HINT: currently it performs useless write and read as well
265 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 0 $BSIZE 1
266 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 0 $BSIZE $BSIZE
267
268 # beginning of device
269 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 1 $BSIZE 0
270 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 1 $BSIZE 1
271 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 1 $BSIZE $((BSIZE-1))
272 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 1 $BSIZE $((BSIZE/2))
273
274 # somewhere in the 'middle'
275 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 1 $BSIZE $BSIZE
276 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 1 $BSIZE $((BSIZE+1))
277 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 1 $BSIZE $((2*BSIZE-1))
278 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 1 $BSIZE $((BSIZE+BSIZE/2-1))
279
280 # cross-sector tests
281 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 2 $BSIZE $((BSIZE-1))
282 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((BSIZE+1)) $BSIZE $((BSIZE-1))
283 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((BSIZE+2)) $BSIZE $((BSIZE-1))
284 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 2 $BSIZE $((2*BSIZE-1))
285 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((BSIZE+1)) $BSIZE $((2*BSIZE-1))
286 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((BSIZE+2)) $BSIZE $((2*BSIZE-1))
287
288 # including one whole sector
289 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((BSIZE+2)) $BSIZE $((BSIZE))
290 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((2*BSIZE)) $BSIZE $((BSIZE+1))
291 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((2*BSIZE)) $BSIZE $((BSIZE-1))
292 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((BSIZE+2)) $BSIZE $((BSIZE-1))
293 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((2*BSIZE)) $BSIZE $((BSIZE+1))
294 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((3*BSIZE-2)) $BSIZE $((BSIZE+1))
295
296 # hitting exactly the sector boundary
297 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((BSIZE-1)) $BSIZE 1
298 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((BSIZE-1)) $BSIZE $((BSIZE+1))
299 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((BSIZE+1)) $BSIZE $((BSIZE-1))
300 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((BSIZE+1)) $BSIZE $((2*BSIZE-1))
301
302 # device end
303 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise 1 $BSIZE $((DEVSIZE-1))
304 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((BSIZE-1)) $BSIZE $((DEVSIZE-BSIZE+1))
305 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((BSIZE)) $BSIZE $((DEVSIZE-BSIZE))
306 RUNscip-shell shell shell-project 0.0.0 RUN(). "P" $1 write_lseek_blockwise $((BSIZE+1)) $BSIZE $((DEVSIZE-BSIZE-1))
307
308 # this must fail on device, but pass on file (which is unfortunate and maybe design mistake)
309 RUNscip-shell shell shell-project 0.0.0 RUN(). "$BD_FAIL" $1 write_lseek_blockwise 1 $BSIZE $((DEVSIZE))
310 RUNscip-shell shell shell-project 0.0.0 RUN(). "$BD_FAIL" $1 write_lseek_blockwise $((BSIZE-1)) $BSIZE $((DEVSIZE-BSIZE+2))
311 RUNscip-shell shell shell-project 0.0.0 RUN(). "$BD_FAIL" $1 write_lseek_blockwise $((BSIZE)) $BSIZE $((DEVSIZE-BSIZE+1))
312 RUNscip-shell shell shell-project 0.0.0 RUN(). "$BD_FAIL" $1 write_lseek_blockwise $((BSIZE+1)) $BSIZE $((DEVSIZE-BSIZE))
313 }
314
315 command -v $STRACE >/dev/nullscip-shell filesystem . . `/dev/null`. || unset STRACE
316 testscip-shell system . . test. -x $BW_UNIT || skipscip-shell shell shell-project 0.0.0 skip(). "Run \"make `basenamescip-shell system . . basename. $BW_UNIT`\" first"
317
318 FAILS=0
319 WARNS=0
320 DEVSIZEMB=2
321 DEVSIZE=$((DEVSIZEMB*1024*1024))
322
323 PAGE_SIZE=$(getconfscip-shell system . . getconf. PAGE_SIZE)
324 echoscip-shell system . . echo. "System PAGE_SIZE=$PAGE_SIZE"
325
326 echoscip-shell system . . echo. "Run tests in local filesystem"
327 fallocscip-shell shell shell-project 0.0.0 falloc(). $DEVSIZEMB $LOCAL_FILE || failscip-shell shell shell-project 0.0.0 fail(). "Failed to create file in local filesystem."
328 BSIZE=$(statscip-shell system . . stat. -c "%o" $LOCAL_FILE)
329 if [scip-shell system . . `[`. $BSIZE -gt $((512*1024)) ]; then
330 echoscip-shell system . . echo. "Detected file block size: $BSIZE bytes"
331 echoscip-shell system . . echo. "Tuning it down to system page size ($PAGE_SIZE bytes)"
332 BSIZE=$PAGE_SIZE
333 fi
334 run_allscip-shell shell shell-project 0.0.0 run_all(). $LOCAL_FILE
335
336 [scip-shell system . . `[`. $(idscip-shell system . . id. -u) -eq 0 ] || {
337 echoscip-shell system . . echo. "WARNING: You must be root to run remaining tests."
338 testscip-shell system . . test. $FAILS -eq 0 || failscip-shell shell shell-project 0.0.0 fail(). "($FAILS wrong result(s) in total)"
339 cleanupscip-shell shell shell-project 0.0.0 cleanup().
340 exit 0
341 }
342
343 DEVBSIZE=512
344 BSIZE=$DEVBSIZE
345 EXP=0
346 DEVSIZEMBIMG=32
347
348 echoscip-shell system . . echo. "# Create classic 512B drive"
349 echoscip-shell system . . echo. "# (logical_block_size=$DEVBSIZE, physical_block_size=$((DEVBSIZE*(1<<EXP))))"
350 add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=$DEVSIZEMB sector_size=$DEVBSIZE physblk_exp=$EXP num_tgts=1
351 run_allscip-shell shell shell-project 0.0.0 run_all(). $DEV
352 cleanupscip-shell shell shell-project 0.0.0 cleanup().
353 add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=$DEVSIZEMBIMG sector_size=$DEVBSIZE physblk_exp=$EXP num_tgts=1
354 run_all_in_fsscip-shell shell shell-project 0.0.0 run_all_in_fs().
355 cleanupscip-shell shell shell-project 0.0.0 cleanup().
356
357 EXP=3
358 echoscip-shell system . . echo. "# Create desktop-class 4K drive"
359 echoscip-shell system . . echo. "# (logical_block_size=$DEVBSIZE, physical_block_size=$((DEVBSIZE*(1<<EXP))))"
360 add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=$DEVSIZEMB physblk_exp=$EXP sector_size=$DEVBSIZE num_tgts=1
361 run_allscip-shell shell shell-project 0.0.0 run_all(). $DEV
362 BSIZE=$((DEVBSIZE*(1<<EXP)))
363 run_allscip-shell shell shell-project 0.0.0 run_all(). $DEV
364 cleanupscip-shell shell shell-project 0.0.0 cleanup().
365
366 add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=$DEVSIZEMBIMG physblk_exp=$EXP sector_size=$DEVBSIZE num_tgts=1
367 run_all_in_fsscip-shell shell shell-project 0.0.0 run_all_in_fs().
368 cleanupscip-shell shell shell-project 0.0.0 cleanup().
369
370 DEVBSIZE=4096
371 BSIZE=$DEVBSIZE
372 EXP=0
373 echoscip-shell system . . echo. "# Create enterprise-class 4K drive"
374 echoscip-shell system . . echo. "# (logical_block_size=$DEVBSIZE, physical_block_size=$((DEVBSIZE*(1<<EXP))))"
375 add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=$DEVSIZEMB physblk_exp=$EXP sector_size=$DEVBSIZE num_tgts=1
376 run_allscip-shell shell shell-project 0.0.0 run_all(). $DEV
377 cleanupscip-shell shell shell-project 0.0.0 cleanup().
378 add_devicescip-shell shell shell-project 0.0.0 add_device(). dev_size_mb=$DEVSIZEMBIMG sector_size=$DEVBSIZE physblk_exp=$EXP num_tgts=1
379 run_all_in_fsscip-shell shell shell-project 0.0.0 run_all_in_fs().
380 cleanupscip-shell shell shell-project 0.0.0 cleanup().
381
382 testscip-shell system . . test. $WARNS -eq 0 || echoscip-shell system . . echo. "(WARNING: $WARNS suspicious result(s) in total)"
383 testscip-shell system . . test. $FAILS -eq 0 || failscip-shell shell shell-project 0.0.0 fail(). "($FAILS wrong result(s) in total)"