qemu-iotests: Use zero-based offsets for IO patterns

The io_pattern style functions have the following loop:

  for i in `seq 1 $count`; do
      echo ... $(( start + i * step )) ...
  done

Offsets are 1-based so start=1024, step=512, count=4 yields:
1536, 2048, 2560, 3072

Normally we expect:
1024, 1536, 2048, 2560

Most tests ignore this detail, which means that they perform I/O to a
slightly different range than expected by the test author.

Later on things got less innocent and tests started trying to compensate
for the 1-based indexing.  This included negative start values in test
024 and my own attempt with count-1 in test 028!

The end result is that tests that use io_pattern are hard to reason
about and don't work the way you'd expect.  It's time to clean this mess
up.

This patch switches io_pattern to 0-based offsets.  This requires
adjusting the golden outputs since I/O ranges are now shifted and output
differs.

Verifying these output diffs is easy, however.  Each diff hunk moves one
I/O from beyond the end of the pattern range to the beginning.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Stefan Hajnoczi 2011-02-04 12:55:02 +00:00 committed by Kevin Wolf
parent 9cdfa1b34e
commit dd0c35d69b
12 changed files with 1879 additions and 1869 deletions

View file

@ -3,6 +3,8 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=3221227008
Filling base image
=== IO: pattern 195
qemu-io> wrote 512/512 bytes at offset 3221194240
512.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-io> wrote 512/512 bytes at offset 3221195264
512.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-io> wrote 512/512 bytes at offset 3221196288
@ -72,6 +74,8 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294968832 backing_file='TEST_DI
Filling test image
=== IO: pattern 196
qemu-io> wrote 512/512 bytes at offset 3221194752
512.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-io> wrote 512/512 bytes at offset 3221195776
512.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-io> wrote 512/512 bytes at offset 3221196800
@ -202,6 +206,8 @@ qemu-io> No errors were found on the image.
Reading
=== IO: pattern 195
qemu-io> read 512/512 bytes at offset 3221194240
512.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-io> read 512/512 bytes at offset 3221195264
512.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-io> read 512/512 bytes at offset 3221196288
@ -265,6 +271,8 @@ qemu-io> read 512/512 bytes at offset 3221224960
qemu-io> read 512/512 bytes at offset 3221225984
512.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-io> === IO: pattern 196
qemu-io> read 512/512 bytes at offset 3221194752
512.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-io> read 512/512 bytes at offset 3221195776
512.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-io> read 512/512 bytes at offset 3221196800
@ -392,6 +400,8 @@ qemu-io> read 512/512 bytes at offset 3221258240
qemu-io> read 512/512 bytes at offset 3221259264
512.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-io> === IO: pattern 0
qemu-io> read 512/512 bytes at offset 3221227008
512.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-io> read 512/512 bytes at offset 3221228032
512.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
qemu-io> read 512/512 bytes at offset 3221229056