Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
iotests: Add test for data_off check
Write a pattern to the first cluster. Corrupt the data_off field and check
if the field was repaired on image opening and the pattern has not changed.

Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Denis V. Lunev <den@openvz.org>
  • Loading branch information
AlexanderIvanov-Virtuozzo authored and Denis V. Lunev committed Sep 6, 2023
1 parent e3820d5 commit 06fca74
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/qemu-iotests/tests/parallels-checks
Expand Up @@ -44,6 +44,7 @@ _supported_os Linux
SIZE=$((4 * 1024 * 1024))
IMGFMT=parallels
CLUSTER_SIZE_OFFSET=28
DATA_OFF_OFFSET=48
BAT_OFFSET=64

_make_test_img $SIZE
Expand Down Expand Up @@ -124,6 +125,20 @@ printf "content: 0x%02x\n" `peek_file_le $TEST_IMG $(($CLUSTER_SIZE)) 1`
echo "== check second cluster on host =="
printf "content: 0x%02x\n" `peek_file_le $TEST_IMG $(($CLUSTER_SIZE)) 1`

# Clear image
_make_test_img $SIZE

echo "== TEST DATA_OFF CHECK =="

echo "== write pattern to first cluster =="
{ $QEMU_IO -c "write -P 0x55 0 $CLUSTER_SIZE" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir

echo "== spoil data_off field =="
poke_file "$TEST_IMG" "$DATA_OFF_OFFSET" "\xff\xff\xff\xff"

echo "== check first cluster =="
{ $QEMU_IO -c "read -P 0x55 0 $CLUSTER_SIZE" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir

# success, all done
echo "*** done"
rm -f $seq.full
Expand Down
10 changes: 10 additions & 0 deletions tests/qemu-iotests/tests/parallels-checks.out
Expand Up @@ -62,4 +62,14 @@ read 1048576/1048576 bytes at offset 1048576
content: 0x11
== check second cluster on host ==
content: 0x11
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4194304
== TEST DATA_OFF CHECK ==
== write pattern to first cluster ==
wrote 1048576/1048576 bytes at offset 0
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
== spoil data_off field ==
== check first cluster ==
Repairing data_off field has incorrect value
read 1048576/1048576 bytes at offset 0
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
*** done

0 comments on commit 06fca74

Please sign in to comment.