Merge remote-tracking branch 'qemu-project/master'
[qemu/ar7.git] / tests / qemu-iotests / tests / zoned
blob3d23ce9cc1fa258895c7efd94cd40d6cfc756358
1 #!/usr/bin/env bash
3 # Test zone management operations.
6 seq="$(basename $0)"
7 echo "QA output created by $seq"
8 status=1 # failure is the default!
10 _cleanup()
12 _cleanup_test_img
13 sudo -n rmmod null_blk
15 trap "_cleanup; exit \$status" 0 1 2 3 15
17 # get standard environment, filters and checks
18 . ../common.rc
19 . ../common.filter
20 . ../common.qemu
22 # This test only runs on Linux hosts with raw image files.
23 _supported_fmt raw
24 _supported_proto file
25 _supported_os Linux
27 sudo -n true || \
28 _notrun 'Password-less sudo required'
30 IMG="--image-opts -n driver=host_device,filename=/dev/nullb0"
31 QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT
33 echo "Testing a null_blk device:"
34 echo "case 1: if the operations work"
35 sudo -n modprobe null_blk nr_devices=1 zoned=1
36 sudo -n chmod 0666 /dev/nullb0
38 echo "(1) report the first zone:"
39 $QEMU_IO $IMG -c "zrp 0 1"
40 echo
41 echo "report the first 10 zones"
42 $QEMU_IO $IMG -c "zrp 0 10"
43 echo
44 echo "report the last zone:"
45 $QEMU_IO $IMG -c "zrp 0x3e70000000 2" # 0x3e70000000 / 512 = 0x1f380000
46 echo
47 echo
48 echo "(2) opening the first zone"
49 $QEMU_IO $IMG -c "zo 0 268435456" # 268435456 / 512 = 524288
50 echo "report after:"
51 $QEMU_IO $IMG -c "zrp 0 1"
52 echo
53 echo "opening the second zone"
54 $QEMU_IO $IMG -c "zo 268435456 268435456" #
55 echo "report after:"
56 $QEMU_IO $IMG -c "zrp 268435456 1"
57 echo
58 echo "opening the last zone"
59 $QEMU_IO $IMG -c "zo 0x3e70000000 268435456"
60 echo "report after:"
61 $QEMU_IO $IMG -c "zrp 0x3e70000000 2"
62 echo
63 echo
64 echo "(3) closing the first zone"
65 $QEMU_IO $IMG -c "zc 0 268435456"
66 echo "report after:"
67 $QEMU_IO $IMG -c "zrp 0 1"
68 echo
69 echo "closing the last zone"
70 $QEMU_IO $IMG -c "zc 0x3e70000000 268435456"
71 echo "report after:"
72 $QEMU_IO $IMG -c "zrp 0x3e70000000 2"
73 echo
74 echo
75 echo "(4) finishing the second zone"
76 $QEMU_IO $IMG -c "zf 268435456 268435456"
77 echo "After finishing a zone:"
78 $QEMU_IO $IMG -c "zrp 268435456 1"
79 echo
80 echo
81 echo "(5) resetting the second zone"
82 $QEMU_IO $IMG -c "zrs 268435456 268435456"
83 echo "After resetting a zone:"
84 $QEMU_IO $IMG -c "zrp 268435456 1"
85 echo
86 echo
87 echo "(6) append write" # the physical block size of the device is 4096
88 $QEMU_IO $IMG -c "zrp 0 1"
89 $QEMU_IO $IMG -c "zap -p 0 0x1000 0x2000"
90 echo "After appending the first zone firstly:"
91 $QEMU_IO $IMG -c "zrp 0 1"
92 $QEMU_IO $IMG -c "zap -p 0 0x1000 0x2000"
93 echo "After appending the first zone secondly:"
94 $QEMU_IO $IMG -c "zrp 0 1"
95 $QEMU_IO $IMG -c "zap -p 268435456 0x1000 0x2000"
96 echo "After appending the second zone firstly:"
97 $QEMU_IO $IMG -c "zrp 268435456 1"
98 $QEMU_IO $IMG -c "zap -p 268435456 0x1000 0x2000"
99 echo "After appending the second zone secondly:"
100 $QEMU_IO $IMG -c "zrp 268435456 1"
102 # success, all done
103 echo "*** done"
104 rm -f $seq.full
105 status=0