qemu-iotests: Initial import into the public repository.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Christoph Hellwig 2009-06-22 18:29:05 +02:00 committed by Kevin Wolf
commit 6bf19c94a0
39 changed files with 110986 additions and 0 deletions

7
tests/qemu-iotests/.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
check.log
check.time
*.out.bad
*.notrun
# ignore everything in the scratch directory
scratch/

66
tests/qemu-iotests/001 Executable file
View File

@ -0,0 +1,66 @@
#!/bin/sh
#
# Test simple read/write using plain bdrv_read/bdrv_write
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=hch@lst.de
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
_supported_fmt generic
_supported_os Linux
size=128M
_make_test_img $size
echo
echo "== reading whole image =="
$QEMU_IO -c "read 0 $size" $TEST_IMG | _filter_qemu_io
echo
echo "== rewriting whole image =="
$QEMU_IO -c "write -P 0xa 0 $size" $TEST_IMG | _filter_qemu_io
echo
echo "== verify pattern =="
$QEMU_IO -c "read -P 0xa 0 $size" $TEST_IMG | _filter_qemu_io
# success, all done
echo "*** done"
rm -f $seq.full
status=0

View File

@ -0,0 +1,15 @@
QA output created by 001
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
== reading whole image ==
read 134217728/134217728 bytes at offset 0
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
== rewriting whole image ==
wrote 134217728/134217728 bytes at offset 0
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
== verify pattern ==
read 134217728/134217728 bytes at offset 0
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
*** done

73
tests/qemu-iotests/002 Executable file
View File

@ -0,0 +1,73 @@
#!/bin/sh
#
# Test simple read/write using plain bdrv_pread/bdrv_pwrite
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=hch@lst.de
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
_supported_fmt generic
_supported_os Linux
size=128M
_make_test_img $size
echo
echo "== reading whole image =="
$QEMU_IO -c "read -p 0 $size" $TEST_IMG | _filter_qemu_io
echo
echo "== rewriting whole image =="
$QEMU_IO -c "write -pP 0xa 0 $size" $TEST_IMG | _filter_qemu_io
echo
echo "== verify pattern =="
$QEMU_IO -c "read -pP 0xa 0 $size" $TEST_IMG | _filter_qemu_io
echo
echo "unaligned pwrite"
$QEMU_IO -c 'write -pP 0axb 66 42' $TEST_IMG | _filter_qemu_io
echo
echo "verify pattern"
$QEMU_IO -c 'read -pP 0xab 66 42' $TEST_IMG | _filter_qemu_io
# success, all done
echo "*** done"
rm -f $seq.full
status=0

View File

@ -0,0 +1,23 @@
QA output created by 002
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
== reading whole image ==
read 134217728/134217728 bytes at offset 0
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
== rewriting whole image ==
wrote 134217728/134217728 bytes at offset 0
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
== verify pattern ==
read 134217728/134217728 bytes at offset 0
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
unaligned pwrite
wrote 42/42 bytes at offset 66
42.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
verify pattern
read 42/42 bytes at offset 66
42.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
*** done

79
tests/qemu-iotests/003 Executable file
View File

@ -0,0 +1,79 @@
#!/bin/sh
#
# Test simple read/write using bdrv_aio_readv/bdrv_aio_writev
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=hch@lst.de
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
_supported_fmt generic
_supported_os Linux
size=128M
offset=67M
chunksize=8k
_make_test_img $size
echo
echo "== reading whole image =="
$QEMU_IO -c "readv 0 $size" $TEST_IMG | _filter_qemu_io
echo
echo "== rewriting whole image =="
$QEMU_IO -c "writev -P 0xa 0 $size" $TEST_IMG | _filter_qemu_io
echo
echo "== verify pattern =="
$QEMU_IO -c "readv -P 0xa 0 $size" $TEST_IMG | _filter_qemu_io
echo
echo "== vectored write =="
$QEMU_IO -c "writev -P 0xb $offset $chunksize $chunksize \
$chunksize $chunksize $chunksize $chunksize $chunksize" \
$TEST_IMG | _filter_qemu_io
echo
echo "== verify pattern =="
$QEMU_IO -c "readv -P 0xb $offset $chunksize $chunksize \
$chunksize $chunksize $chunksize $chunksize $chunksize" \
$TEST_IMG | _filter_qemu_io
# success, all done
echo "*** done"
rm -f $seq.full
status=0

View File

@ -0,0 +1,23 @@
QA output created by 003
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
== reading whole image ==
read 134217728/134217728 bytes at offset 0
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
== rewriting whole image ==
wrote 134217728/134217728 bytes at offset 0
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
== verify pattern ==
read 134217728/134217728 bytes at offset 0
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
== vectored write ==
wrote 57344/57344 bytes at offset 70254592
56 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
== verify pattern ==
read 57344/57344 bytes at offset 70254592
56 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
*** done

105
tests/qemu-iotests/004 Executable file
View File

@ -0,0 +1,105 @@
#!/bin/sh
#
# Make sure we can't read and write outside of the image size.
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=hch@lst.de
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
_supported_fmt generic
_supported_os Linux
size=128M
pre_offset=127M
past_offset=140M
_make_test_img $size
echo
echo "write before image boundary"
$QEMU_IO -c "write $pre_offset 1M" $TEST_IMG | _filter_qemu_io
echo
echo "write into image boundary"
$QEMU_IO -c "write $pre_offset 4M" $TEST_IMG
echo
echo "write at image boundary"
$QEMU_IO -c "write $size 4096" $TEST_IMG
echo
echo "write past image boundary"
$QEMU_IO -c "write $past_offset 4096" $TEST_IMG
echo
echo "pwrite past image boundary"
$QEMU_IO -c "write -p $past_offset 4096" $TEST_IMG
echo
echo "writev past image boundary"
$QEMU_IO -c "writev $past_offset 4096" $TEST_IMG
echo
echo "read before image boundary"
$QEMU_IO -c "read $pre_offset 1M" $TEST_IMG | _filter_qemu_io
echo
echo "read into image boundary"
$QEMU_IO -c "read $pre_offset 4M" $TEST_IMG
echo
echo "read at image boundary"
$QEMU_IO -c "read $size 4096" $TEST_IMG
echo
echo "read past image boundary"
$QEMU_IO -c "read $past_offset 4096" $TEST_IMG
echo
echo "pread past image boundary"
$QEMU_IO -c "read -p $past_offset 4096" $TEST_IMG
echo
echo "readv past image boundary"
$QEMU_IO -c "readv $past_offset 4096" $TEST_IMG
# success, all done
echo "*** done"
rm -f $seq.full
status=0

View File

@ -0,0 +1,41 @@
QA output created by 004
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
write before image boundary
wrote 1048576/1048576 bytes at offset 133169152
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
write into image boundary
write failed: Input/output error
write at image boundary
write failed: Input/output error
write past image boundary
write failed: Input/output error
pwrite past image boundary
write failed: Input/output error
writev past image boundary
writev failed: Input/output error
read before image boundary
read 1048576/1048576 bytes at offset 133169152
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
read into image boundary
read failed: Input/output error
read at image boundary
read failed: Input/output error
read past image boundary
read failed: Input/output error
pread past image boundary
read failed: Input/output error
readv past image boundary
readv failed: Input/output error
*** done

66
tests/qemu-iotests/005 Executable file
View File

@ -0,0 +1,66 @@
#!/bin/sh
#
# Make sure qemu-img can create 5TB images
#
# Based on a testcase from Chris Wright,
# https://bugzilla.redhat.com/show_bug.cgi?id=491943
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=hch@lst.de
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
# vpc is limited to 127GB, so we can't test it here
_supported_fmt generic
_supported_os Linux
echo
echo "creating large image"
_make_test_img 5000G
echo
echo "small read"
$QEMU_IO -c "read 1024 4096" $TEST_IMG | _filter_qemu_io
echo
echo "small write"
$QEMU_IO -c "read 8192 4096" $TEST_IMG | _filter_qemu_io
# success, all done
echo "*** done"
rm -f $seq.full
status=0

View File

@ -0,0 +1,13 @@
QA output created by 005
creating large image
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=5368709120000
small read
read 4096/4096 bytes at offset 1024
4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
small write
read 4096/4096 bytes at offset 8192
4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
*** done

55
tests/qemu-iotests/006 Executable file
View File

@ -0,0 +1,55 @@
#!/bin/sh
#
# Make sure qemu-img rejects > 127GB images for the vpc format as the format
# doesn't support this.
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=hch@lst.de
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
_supported_fmt vpc
_supported_os Linux
echo
echo "creating 128GB image"
_make_test_img 128G
# success, all done
echo "*** done"
rm -f $seq.full
status=0

View File

@ -0,0 +1,6 @@
QA output created by 006
creating 128GB image
qemu-img: The image size is too large for file format 'vpc'
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=137438953472
*** done

68
tests/qemu-iotests/007 Executable file
View File

@ -0,0 +1,68 @@
#!/bin/sh
#
# Check for one possible case of qcow2 refcount corruption.
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=kwolf@redhat.com
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
# _cleanup_test_img
true
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
# currently only qcow2 allows for consistency checks using qemu-img
_supported_fmt qcow2
_supported_os Linux
echo
echo "creating image"
_make_test_img 1M
for i in `seq 1 10`; do
echo "savevm $i"
# XXX(hch): adding -nographic would be good, but hangs the test
$QEMU -hda $TEST_IMG -monitor stdio >/dev/null 2>&1 <<EOF
savevm test-$i
quit
EOF
done
echo
echo "checking image for errors"
_check_test_img
# success, all done
echo "*** done"
rm -f $seq.full
status=0

View File

@ -0,0 +1,18 @@
QA output created by 007
creating image
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
savevm 1
savevm 2
savevm 3
savevm 4
savevm 5
savevm 6
savevm 7
savevm 8
savevm 9
savevm 10
checking image for errors
No errors were found on the image.
*** done

66
tests/qemu-iotests/008 Executable file
View File

@ -0,0 +1,66 @@
#!/bin/sh
#
# Test simple asynchronous read/write operations.
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=hch@lst.de
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
_supported_fmt generic
_supported_os Linux
size=128M
_make_test_img $size
echo
echo "== reading whole image =="
$QEMU_IO -c "aio_read 0 $size" $TEST_IMG | _filter_qemu_io
echo
echo "== rewriting whole image =="
$QEMU_IO -c "aio_write -P 0xa 0 $size" $TEST_IMG | _filter_qemu_io
echo
echo "== verify pattern =="
$QEMU_IO -c "aio_read -P 0xa 0 $size" $TEST_IMG | _filter_qemu_io
# success, all done
echo "*** done"
rm -f $seq.full
status=0

View File

@ -0,0 +1,15 @@
QA output created by 008
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
== reading whole image ==
read 134217728/134217728 bytes at offset 0
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
== rewriting whole image ==
wrote 134217728/134217728 bytes at offset 0
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
== verify pattern ==
read 134217728/134217728 bytes at offset 0
128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
*** done

70
tests/qemu-iotests/009 Executable file
View File

@ -0,0 +1,70 @@
#!/bin/sh
#
# Nolan I qcow2 corruption - incorrectly reports free clusters
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=kwolf@redhat.com
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
_supported_fmt qcow2
_supported_os Linux
size=6G
echo
echo "creating image"
_make_test_img $size
echo
echo "creating pattern"
$QEMU_IO \
-c "write 2048k 4k -P 65" \
-c "write 4k 4k" \
-c "write 9M 4k" \
-c "read 2044k 8k -P 65 -s 4k -l 4k" \
$TEST_IMG | _filter_qemu_io
echo
echo "checking image for errors"
_check_test_img
# success, all done
echo "*** done"
rm -f $seq.full
status=0

View File

@ -0,0 +1,18 @@
QA output created by 009
creating image
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944
creating pattern
wrote 4096/4096 bytes at offset 2097152
4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 4096/4096 bytes at offset 4096
4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 4096/4096 bytes at offset 9437184
4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
read 8192/8192 bytes at offset 2093056
8 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
checking image for errors
No errors were found on the image.
*** done

72
tests/qemu-iotests/010 Executable file
View File

@ -0,0 +1,72 @@
#!/bin/sh
#
# Nolan II qcow2 corruption - wrong used cluster
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=kwolf@redhat.com
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
_supported_fmt qcow2
_supported_os Linux
size=6G
echo
echo "creating image"
_make_test_img $size
echo
echo "creating pattern"
$QEMU_IO \
-c "write 2048k 4k -P 165" \
-c "write 64k 4k" \
-c "write 9M 4k" \
-c "write 2044k 4k -P 165" \
-c "write 8M 4k -P 99" \
-c "read -P 165 2044k 8k" \
$TEST_IMG | _filter_qemu_io
echo
echo "checking image for errors"
_check_test_img
# success, all done
echo "*** done"
rm -f $seq.full
status=0

View File

@ -0,0 +1,22 @@
QA output created by 010
creating image
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944
creating pattern
wrote 4096/4096 bytes at offset 2097152
4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 4096/4096 bytes at offset 65536
4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 4096/4096 bytes at offset 9437184
4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 4096/4096 bytes at offset 2093056
4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 4096/4096 bytes at offset 8388608
4 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
read 8192/8192 bytes at offset 2093056
8 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
checking image for errors
No errors were found on the image.
*** done

76
tests/qemu-iotests/011 Executable file
View File

@ -0,0 +1,76 @@
#!/bin/sh
#
# Test for AIO allocation on the same cluster
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=kwolf@redhat.com
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
_supported_fmt qcow2
_supported_os Linux
size=6G
echo
echo "creating image"
_make_test_img $size
echo
echo "overlapping I/O"
for i in `seq 1 10`; do
let mb=1024*1024
let off1=$i*$mb
let off2=$off1+512
# Note that we filter away the actual offset. That's because qemu
# may re-order the two aio requests. We only want to make sure the
# filesystem isn't corrupted afterwards anyway.
$QEMU_IO $TEST_IMG -c "aio_write $off1 1M" -c "aio_write $off2 1M" | \
_filter_qemu_io | \
sed -e 's/bytes at offset [0-9]*/bytes at offset XXX/g'
done
echo
echo "checking image for errors"
_check_test_img
# success, all done
echo "*** done"
rm -f $seq.full
status=0

View File

@ -0,0 +1,50 @@
QA output created by 011
creating image
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944
overlapping I/O
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
wrote 1048576/1048576 bytes at offset XXX
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
checking image for errors
No errors were found on the image.
*** done

63
tests/qemu-iotests/012 Executable file
View File

@ -0,0 +1,63 @@
#!/bin/sh
#
# Make sure we can open read-only images
#
# Regression fixed by commit 11a1feb6552e3a4709e454faea5e3be5ca8d9e6a.
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=hch@lst.de
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
_supported_fmt generic
_supported_os Linux
size=128M
_make_test_img $size
echo
echo "== mark image read-only"
chmod a-w $TEST_IMG
echo
echo "== read from read-only image"
$QEMU_IO -r -c "read 0 512" $TEST_IMG | _filter_qemu_io
# success, all done
echo "*** done"
rm -f $seq.full
status=0

View File

@ -0,0 +1,9 @@
QA output created by 012
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
== mark image read-only
== read from read-only image
read 512/512 bytes at offset 0
512.000000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
*** done

98
tests/qemu-iotests/013 Executable file
View File

@ -0,0 +1,98 @@
#!/bin/sh
#
# qcow2 pattern test, empty and compressed image
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=kwolf@redhat.com
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
. ./common.pattern
# much of this could be generic for any format supporting compression.
_supported_fmt qcow2
_supported_os Linux
TEST_OFFSETS="0 4294967296"
TEST_OPS="writev read write readv"
_make_test_img 6G
echo "Testing empty image"
echo
for offset in $TEST_OFFSETS; do
echo "At offset $offset:"
for op in $TEST_OPS; do
io_test $op $offset
done
_check_test_img
done
echo "Compressing image"
echo
mv $TEST_IMG $TEST_IMG.orig
$QEMU_IMG convert -f qcow2 -O qcow2 -c $TEST_IMG.orig $TEST_IMG
echo "Testing compressed image"
echo
for offset in $TEST_OFFSETS; do
echo "With offset $offset:"
for op in read readv; do
io_test $op $offset
done
_check_test_img
done
echo "Testing compressed image with odd offsets"
echo
for offset in $TEST_OFFSETS; do
# Some odd offset (1 sector), so tests will write to areas occupied partly
# by old (compressed) data and empty clusters
offset=$((offset + 512))
echo "With offset $offset:"
for op in $TEST_OPS; do
io_test $op $offset
done
_check_test_img
done
# success, all done
echo "*** done"
rm -f $seq.full
status=0

43983
tests/qemu-iotests/013.out Normal file

File diff suppressed because it is too large Load Diff

76
tests/qemu-iotests/014 Executable file
View File

@ -0,0 +1,76 @@
#!/bin/sh
#
# qcow2 pattern test, complex patterns including compression and snapshots
#
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
# creator
owner=kwolf@redhat.com
seq=`basename $0`
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
{
_cleanup_test_img
}
trap "_cleanup; exit \$status" 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
. ./common.pattern
# much of this could be generic for any format supporting compression.
_supported_fmt qcow2
_supported_os Linux
TEST_OFFSETS="0 4294967296"
TEST_OPS="writev read write readv"
_make_test_img 6G
echo "Testing empty image:"
for offset in $TEST_OFFSETS; do
echo test2: With offset $offset
io_test2 $offset
_check_test_img
done
# With snapshots
for i in `seq 1 3`; do
$QEMU_IMG snapshot -c test$i $TEST_IMG
for offset in $TEST_OFFSETS; do
echo With snapshot test$i, offset $offset
for op in $TEST_OPS; do
io_test $op $offset
done
_check_test_img
done
done
# success, all done
echo "*** done"
rm -f $seq.full
status=0

64074
tests/qemu-iotests/014.out Normal file

File diff suppressed because it is too large Load Diff

339
tests/qemu-iotests/COPYING Normal file
View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@ -0,0 +1,9 @@
CLEANFILES= *.out.bad *.notrun check.log check.time
# no default target
default:
clean:
rm -f $(CLEANFILES)

20
tests/qemu-iotests/README Normal file
View File

@ -0,0 +1,20 @@
=== This is the QEMU I/O test suite ===
* Intro
This package contains a simple test suite for the I/O layer of qemu.
It does not requite a guest, but only the qemu, qemu-img and qemu-io
binaries. This does limit it to exercise the low-level I/O path only
but no actual block drivers like ide, scsi or virtio.
* Usage
Just run ./check to run all tests for the raw image format, or ./check
-qcow2 to test the qcow2 image format. The output of ./check -h explains
additional options to test further image formats or I/O methods.
* Feedback and patches
Please send improvements to the test suite, general feedback or just
reports of failing tests cases to qemu-devel@savannah.nongnu.org.

277
tests/qemu-iotests/check Executable file
View File

@ -0,0 +1,277 @@
#!/bin/sh
#
# Copyright (C) 2009 Red Hat, Inc.
# Copyright (c) 2000-2002,2006 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#
# Control script for QA
#
tmp=/tmp/$$
status=0
needwrap=true
try=0
n_bad=0
bad=""
notrun=""
interrupt=true
# by default don't output timestamps
timestamp=${TIMESTAMP:=false}
# generic initialization
iam=check
# we need common.config
if ! . ./common.config
then
echo "$iam: failed to source common.config"
exit 1
fi
# we need common
. ./common
# we need common.rc
if ! . ./common.rc
then
echo "check: failed to source common.rc"
exit 1
fi
#if [ `id -u` -ne 0 ]
#then
# echo "check: QA must be run as root"
# exit 1
#fi
_wallclock()
{
date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
}
_timestamp()
{
now=`date "+%T"`
echo -n " [$now]"
}
_wrapup()
{
# for hangcheck ...
# remove files that were used by hangcheck
#
[ -f /tmp/check.pid ] && rm -rf /tmp/check.pid
[ -f /tmp/check.sts ] && rm -rf /tmp/check.sts
if $showme
then
:
elif $needwrap
then
if [ -f check.time -a -f $tmp.time ]
then
cat check.time $tmp.time \
| $AWK_PROG '
{ t[$1] = $2 }
END { if (NR > 0) {
for (i in t) print i " " t[i]
}
}' \
| sort -n >$tmp.out
mv $tmp.out check.time
fi
if [ -f $tmp.expunged ]
then
notrun=`wc -l <$tmp.expunged | sed -e 's/ *//g'`
try=`expr $try - $notrun`
list=`echo "$list" | sed -f $tmp.expunged`
fi
echo "" >>check.log
date >>check.log
echo $list | fmt | sed -e 's/^/ /' >>check.log
$interrupt && echo "Interrupted!" >>check.log
if [ ! -z "$notrun" ]
then
echo "Not run:$notrun"
echo "Not run:$notrun" >>check.log
fi
if [ ! -z "$n_bad" -a $n_bad != 0 ]
then
echo "Failures:$bad"
echo "Failed $n_bad of $try tests"
echo "Failures:$bad" | fmt >>check.log
echo "Failed $n_bad of $try tests" >>check.log
else
echo "Passed all $try tests"
echo "Passed all $try tests" >>check.log
fi
needwrap=false
fi
rm -f /tmp/*.out /tmp/*.err /tmp/*.time
rm -f /tmp/check.pid /tmp/check.sts
rm -f $tmp.*
}
trap "_wrapup; exit \$status" 0 1 2 3 15
# for hangcheck ...
# Save pid of check in a well known place, so that hangcheck can be sure it
# has the right pid (getting the pid from ps output is not reliable enough).
#
rm -rf /tmp/check.pid
echo $$ >/tmp/check.pid
# for hangcheck ...
# Save the status of check in a well known place, so that hangcheck can be
# sure to know where check is up to (getting test number from ps output is
# not reliable enough since the trace stuff has been introduced).
#
rm -rf /tmp/check.sts
echo "preamble" >/tmp/check.sts
# don't leave old full output behind on a clean run
rm -f check.full
[ -f check.time ] || touch check.time
FULL_IMGFMT_DETAILS=`_full_imgfmt_details`
FULL_HOST_DETAILS=`_full_platform_details`
#FULL_MKFS_OPTIONS=`_scratch_mkfs_options`
#FULL_MOUNT_OPTIONS=`_scratch_mount_options`
cat <<EOF
IMGFMT -- $FULL_IMGFMT_DETAILS
PLATFORM -- $FULL_HOST_DETAILS
EOF
#MKFS_OPTIONS -- $FULL_MKFS_OPTIONS
#MOUNT_OPTIONS -- $FULL_MOUNT_OPTIONS
seq="check"
[ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG
for seq in $list
do
err=false
echo -n "$seq"
if [ -n "$TESTS_REMAINING_LOG" ] ; then
sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
sync
fi
if $showme
then
echo
continue
elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null
then
echo " - expunged"
rm -f $seq.out.bad
echo "/^$seq\$/d" >>$tmp.expunged
elif [ ! -f $seq ]
then
echo " - no such test?"
echo "/^$seq\$/d" >>$tmp.expunged
else
# really going to try and run this one
#
rm -f $seq.out.bad
lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time`
if [ "X$lasttime" != X ]; then
echo -n " ${lasttime}s ..."
else
echo -n " " # prettier output with timestamps.
fi
rm -f core $seq.notrun
# for hangcheck ...
echo "$seq" >/tmp/check.sts
start=`_wallclock`
$timestamp && echo -n " ["`date "+%T"`"]"
[ ! -x $seq ] && chmod u+x $seq # ensure we can run it
./$seq >$tmp.out 2>&1
sts=$?
$timestamp && _timestamp
stop=`_wallclock`
if [ -f core ]
then
echo -n " [dumped core]"
mv core $seq.core
err=true
fi
if [ -f $seq.notrun ]
then
$timestamp || echo -n " [not run] "
$timestamp && echo " [not run]" && echo -n " $seq -- "
cat $seq.notrun
notrun="$notrun $seq"
else
if [ $sts -ne 0 ]
then
echo -n " [failed, exit status $sts]"
err=true
fi
if [ ! -f $seq.out ]
then
echo " - no qualified output"
err=true
else
if diff $seq.out $tmp.out >/dev/null 2>&1
then
echo ""
if $err
then
:
else
echo "$seq `expr $stop - $start`" >>$tmp.time
fi
else
echo " - output mismatch (see $seq.out.bad)"
mv $tmp.out $seq.out.bad
$diff $seq.out $seq.out.bad
err=true
fi
fi
fi
fi
# come here for each test, except when $showme is true
#
if $err
then
bad="$bad $seq"
n_bad=`expr $n_bad + 1`
quick=false
fi
[ -f $seq.notrun ] || try=`expr $try + 1`
seq="after_$seq"
done
interrupt=false
status=`expr $n_bad`
exit

306
tests/qemu-iotests/common Normal file
View File

@ -0,0 +1,306 @@
#!/bin/sh
#
# Copyright (C) 2009 Red Hat, Inc.
# Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#
# common procedures for QA scripts
#
_setenvironment()
{
MSGVERB="text:action"
export MSGVERB
}
here=`pwd`
rm -f $here/$iam.out
_setenvironment
check=${check-true}
diff="diff -u"
verbose=false
group=false
xgroup=false
showme=false
sortme=false
expunge=true
have_test_arg=false
randomize=false
rm -f $tmp.list $tmp.tmp $tmp.sed
export IMGFMT=raw
export QEMU_IO_OPTIONS=""
for r
do
if $group
then
# arg after -g
group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
s/ .*//p
}'`
if [ -z "$group_list" ]
then
echo "Group \"$r\" is empty or not defined?"
exit 1
fi
[ ! -s $tmp.list ] && touch $tmp.list
for t in $group_list
do
if grep -s "^$t\$" $tmp.list >/dev/null
then
:
else
echo "$t" >>$tmp.list
fi
done
group=false
continue
elif $xgroup
then
# arg after -x
[ ! -s $tmp.list ] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list 2>/dev/null
group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
s/ .*//p
}'`
if [ -z "$group_list" ]
then
echo "Group \"$r\" is empty or not defined?"
exit 1
fi
numsed=0
rm -f $tmp.sed
for t in $group_list
do
if [ $numsed -gt 100 ]
then
sed -f $tmp.sed <$tmp.list >$tmp.tmp
mv $tmp.tmp $tmp.list
numsed=0
rm -f $tmp.sed
fi
echo "/^$t\$/d" >>$tmp.sed
numsed=`expr $numsed + 1`
done
sed -f $tmp.sed <$tmp.list >$tmp.tmp
mv $tmp.tmp $tmp.list
xgroup=false
continue
fi
xpand=true
case "$r"
in
-\? | -h | --help) # usage
echo "Usage: $0 [options] [testlist]"'
common options
-v verbose
check options
-raw test raw (default)
-cow test cow
-qcow test qcow
-qcow2 test qcow2
-vpc test vpc
-vmdk test vmdk
-xdiff graphical mode diff
-nocache use O_DIRECT on backing file
-misalign misalign memory allocations
-n show me, do not run tests
-T output timestamps
-r randomize test order
testlist options
-g group[,group...] include tests from these groups
-x group[,group...] exclude tests from these groups
NNN include test NNN
NNN-NNN include test range (eg. 012-021)
'
exit 0
;;
-raw)
IMGFMT=raw
xpand=false
;;
-cow)
IMGFMT=cow
xpand=false
;;
-qcow)
IMGFMT=qcow
xpand=false
;;
-qcow2)
IMGFMT=qcow2
xpand=false
;;
-vmdk)
IMGFMT=vmdk
xpand=false
;;
-vpc)
IMGFMT=vpc
xpand=false
;;
-nocache)
QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --nocache"
xpand=false
;;
-misalign)
QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --misalign"
xpand=false
;;
-g) # -g group ... pick from group file
group=true
xpand=false
;;
-xdiff) # graphical diff mode
xpand=false
if [ ! -z "$DISPLAY" ]
then
which xdiff >/dev/null 2>&1 && diff=xdiff
which gdiff >/dev/null 2>&1 && diff=gdiff
which tkdiff >/dev/null 2>&1 && diff=tkdiff
which xxdiff >/dev/null 2>&1 && diff=xxdiff
fi
;;
-n) # show me, don't do it
showme=true
xpand=false
;;
-r) # randomize test order
randomize=true
xpand=false
;;
-T) # turn on timestamp output
timestamp=true
xpand=false
;;
-v)
verbose=true
xpand=false
;;
-x) # -x group ... exclude from group file
xgroup=true
xpand=false
;;
'[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
echo "No tests?"
status=1
exit $status
;;
[0-9]*-[0-9]*)
eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
;;
[0-9]*-)
eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
end=`echo [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] | sed -e 's/\[0-9]//g' -e 's/ *$//' -e 's/.* //'`
if [ -z "$end" ]
then
echo "No tests in range \"$r\"?"
status=1
exit $status
fi
;;
*)
start=$r
end=$r
;;
esac
# get rid of leading 0s as can be interpreted as octal
start=`echo $start | sed 's/^0*//'`
end=`echo $end | sed 's/^0*//'`
if $xpand
then
have_test_arg=true
$AWK_PROG </dev/null '
BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
| while read id
do
if grep -s "^$id " group >/dev/null
then
# in group file ... OK
echo $id >>$tmp.list
else
if [ -f expunged ] && $expunge && egrep "^$id([ ]|\$)" expunged >/dev/null
then
# expunged ... will be reported, but not run, later
echo $id >>$tmp.list
else
# oops
echo "$id - unknown test, ignored"
fi
fi
done
fi
done
if [ -s $tmp.list ]
then
# found some valid test numbers ... this is good
:
else
if $have_test_arg
then
# had test numbers, but none in group file ... do nothing
touch $tmp.list
else
# no test numbers, do everything from group file
sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list
fi
fi
# should be sort -n, but this did not work for Linux when this
# was ported from IRIX
#
list=`sort $tmp.list`
rm -f $tmp.list $tmp.tmp $tmp.sed
if $randomize
then
list=`echo $list | awk -f randomize.awk`
fi
[ "$QEMU" = "" ] && _fatal "qemu not found"
[ "$QEMU_IMG" = "" ] && _fatal "qemu-img not found"
[ "$QEMU_IO" = "" ] && _fatal "qemu-img not found"

View File

@ -0,0 +1,134 @@
#!/bin/sh
#
# Copyright (C) 2009 Red Hat, Inc.
# Copyright (c) 2000-2003,2006 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#
# setup and check for config parameters, and in particular
#
# EMAIL - email of the script runner.
# TEST_DIR - scratch test directory
#
# - These can be added to $HOST_CONFIG_DIR (witch default to ./config)
# below or a separate local configuration file can be used (using
# the HOST_OPTIONS variable).
# - This script is shared by the stress test system and the auto-qa
# system (includes both regression test and benchmark components).
# - this script shouldn't make any assertions about filesystem
# validity or mountedness.
#
# all tests should use a common language setting to prevent golden
# output mismatches.
export LANG=C
PATH=".:$PATH"
HOST=`hostname -s`
HOSTOS=`uname -s`
EMAIL=root@localhost # where auto-qa will send its status messages
export HOST_OPTIONS=${HOST_OPTIONS:=local.config}
export CHECK_OPTIONS=${CHECK_OPTIONS:="-g auto"}
export PWD=`pwd`
# $1 = prog to look for, $2* = default pathnames if not found in $PATH
set_prog_path()
{
p=`which $1 2> /dev/null`
if [ -n "$p" -a -x "$p" ]; then
echo $p
return 0
fi
p=$1
shift
for f; do
if [ -x $f ]; then
echo $f
return 0
fi
done
echo ""
return 1
}
_fatal()
{
echo "$*"
status=1
exit 1
}
export PERL_PROG="`set_prog_path perl`"
[ "$PERL_PROG" = "" ] && _fatal "perl not found"
export AWK_PROG="`set_prog_path awk`"
[ "$AWK_PROG" = "" ] && _fatal "awk not found"
export SED_PROG="`set_prog_path sed`"
[ "$SED_PROG" = "" ] && _fatal "sed not found"
export BC_PROG="`set_prog_path bc`"
[ "$BC_PROG" = "" ] && _fatal "bc not found"
export PS_ALL_FLAGS="-ef"
export QEMU_PROG="`set_prog_path qemu`"
[ "$QEMU_PROG" = "" ] && _fatal "qemu not found"
export QEMU_IMG_PROG="`set_prog_path qemu-img`"
[ "$QEMU_IMG_PROG" = "" ] && _fatal "qemu-img not found"
export QEMU_IO_PROG="`set_prog_path qemu-io`"
[ "$QEMU_IO_PROG" = "" ] && _fatal "qemu-io not found"
export QEMU=$QEMU_PROG
export QEMU_IMG=$QEMU_IMG_PROG
export QEMU_IO="$QEMU_IO_PROG $QEMU_IO_OPTIONS"
[ -f /etc/qemu-iotest.config ] && . /etc/qemu-iotest.config
if [ ! -e "$TEST_DIR" ]; then
TEST_DIR=`pwd`/scratch
fi
if [ ! -d "$TEST_DIR" ]; then
echo "common.config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
exit 1
fi
_readlink()
{
if [ $# -ne 1 ]; then
echo "Usage: _readlink filename" 1>&2
exit 1
fi
perl -e "\$in=\"$1\";" -e '
$lnk = readlink($in);
if ($lnk =~ m!^/.*!) {
print "$lnk\n";
}
else {
chomp($dir = `dirname $in`);
print "$dir/$lnk\n";
}'
}
# make sure this script returns success
/bin/true

View File

@ -0,0 +1,145 @@
#!/bin/sh
#
# Copyright (C) 2009 Red Hat, Inc.
# Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#
# standard filters
#
# Checks that given_value is in range of correct_value +/- tolerance.
# Tolerance can be an absolute value or a percentage of the correct value
# (see examples with tolerances below).
# Outputs suitable message to stdout if it's not in range.
#
# A verbose option, -v, may be used as the LAST argument
#
# e.g.
# foo: 0.0298 = 0.03 +/- 5%
# _within_tolerance "foo" 0.0298 0.03 5%
#
# foo: 0.0298 = 0.03 +/- 0.01
# _within_tolerance "foo" 0.0298 0.03 0.01
#
# foo: 0.0298 = 0.03 -0.01 +0.002
# _within_tolerance "foo" 0.0298 0.03 0.01 0.002
#
# foo: verbose output of 0.0298 = 0.03 +/- 5%
# _within_tolerance "foo" 0.0298 0.03 5% -v
_within_tolerance()
{
_name=$1
_given_val=$2
_correct_val=$3
_mintol=$4
_maxtol=$_mintol
_verbose=0
_debug=false
# maxtol arg is optional
# verbose arg is optional
if [ $# -ge 5 ]
then
if [ "$5" = "-v" ]
then
_verbose=1
else
_maxtol=$5
fi
fi
if [ $# -ge 6 ]
then
[ "$6" = "-v" ] && _verbose=1
fi
# find min with or without %
_mintolerance=`echo $_mintol | sed -e 's/%//'`
if [ $_mintol = $_mintolerance ]
then
_min=`echo "scale=5; $_correct_val-$_mintolerance" | bc`
else
_min=`echo "scale=5; $_correct_val-$_mintolerance*0.01*$_correct_val" | bc`
fi
# find max with or without %
_maxtolerance=`echo $_maxtol | sed -e 's/%//'`
if [ $_maxtol = $_maxtolerance ]
then
_max=`echo "scale=5; $_correct_val+$_maxtolerance" | bc`
else
_max=`echo "scale=5; $_correct_val+$_maxtolerance*0.01*$_correct_val" | bc`
fi
$_debug && echo "min = $_min"
$_debug && echo "max = $_max"
cat <<EOF >$tmp.bc.1
scale=5;
if ($_min <= $_given_val) 1;
if ($_min > $_given_val) 0;
EOF
cat <<EOF >$tmp.bc.2
scale=5;
if ($_given_val <= $_max) 1;
if ($_given_val > $_max) 0;
EOF
_above_min=`bc <$tmp.bc.1`
_below_max=`bc <$tmp.bc.2`
rm -f $tmp.bc.[12]
_in_range=`expr $_above_min \& $_below_max`
# fix up min, max precision for output
# can vary for 5.3, 6.2
_min=`echo $_min | sed -e 's/0*$//'` # get rid of trailling zeroes
_max=`echo $_max | sed -e 's/0*$//'` # get rid of trailling zeroes
if [ $_in_range -eq 1 ]
then
[ $_verbose -eq 1 ] && echo $_name is in range
return 0
else
[ $_verbose -eq 1 ] && echo $_name has value of $_given_val
[ $_verbose -eq 1 ] && echo $_name is NOT in range $_min .. $_max
return 1
fi
}
# ctime(3) dates
#
_filter_date()
{
sed \
-e 's/[A-Z][a-z][a-z] [A-z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]$/DATE/'
}
# replace occurances of the actual TEST_DIR value with TEST_DIR
_filter_testdir()
{
sed -e "s#$TEST_DIR#TEST_DIR#g"
}
# sanitize qemu-io output
_filter_qemu_io()
{
sed -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.]* [GMKiBbytes]*\/sec and [0-9/.]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/"
}
# make sure this script returns success
/bin/true

View File

@ -0,0 +1,118 @@
#!/bin/sh
#
# Copyright (C) 2009 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
function do_io() {
local op=$1
local start=$2
local size=$3
local step=$4
local count=$5
local pattern=$6
echo === IO: pattern $pattern >&2
for i in `seq 1 $count`; do
echo $op -P $pattern $(( start + i * step )) $size
done
}
function io_pattern() {
do_io $@ | $QEMU_IO $TEST_IMG | _filter_qemu_io
}
function io() {
local start=$2
local pattern=$(( (start >> 9) % 256 ))
do_io $@ $pattern | $QEMU_IO $TEST_IMG | _filter_qemu_io
}
function io_zero() {
do_io $@ 0 | $QEMU_IO $TEST_IMG | _filter_qemu_io
}
function io_test() {
local op=$1
local offset=$2
# Complete clusters (size = 4k)
io $op $offset 4096 4096 256
offset=$((offset + 256 * 4096))
# From somewhere in the middle to the end of a cluster
io $op $((offset + 2048)) 2048 4096 256
offset=$((offset + 256 * 4096))
# From the start to somewhere in the middle of a cluster
io $op $offset 2048 4096 256
offset=$((offset + 256 * 4096))
# Completely misaligned (and small)
io $op $((offset + 1024)) 2048 4096 256
offset=$((offset + 256 * 4096))
# Spanning multiple clusters
io $op $((offset + 2048)) 8192 12288 64
offset=$((offset + 64 * 12288))
# Spanning multiple L2 tables
# L2 table size: 512 clusters of 4k = 2M
io $op $((offset + 2048)) 4194304 4999680 8
offset=$((offset + 8 * 4999680))
if false; then
true
fi
}
function io_test2() {
local orig_offset=$1
# Pattern (repeat after 9 clusters):
# used - used - free - used - compressed - compressed - free - free - compressed
# Write the clusters to be compressed
echo === Clusters to be compressed [1]
io_pattern writev $((offset + 4 * 4096)) 4096 $((9 * 4096)) 256 165
echo === Clusters to be compressed [2]
io_pattern writev $((offset + 5 * 4096)) 4096 $((9 * 4096)) 256 165
echo === Clusters to be compressed [3]
io_pattern writev $((offset + 8 * 4096)) 4096 $((9 * 4096)) 256 165
mv $TEST_IMG $TEST_IMG.orig
$QEMU_IMG convert -f qcow2 -O qcow2 -c $TEST_IMG.orig $TEST_IMG
# Write the used clusters
echo === Used clusters [1]
io_pattern writev $((offset + 0 * 4096)) 4096 $((9 * 4096)) 256 165
echo === Used clusters [2]
io_pattern writev $((offset + 1 * 4096)) 4096 $((9 * 4096)) 256 165
echo === Used clusters [3]
io_pattern writev $((offset + 3 * 4096)) 4096 $((9 * 4096)) 256 165
# Read them
echo === Read used/compressed clusters
io_pattern readv $((offset + 0 * 4096)) $((2 * 4096)) $((9 * 4096)) 256 165
io_pattern readv $((offset + 3 * 4096)) $((3 * 4096)) $((9 * 4096)) 256 165
io_pattern readv $((offset + 8 * 4096)) $((1 * 4096)) $((9 * 4096)) 256 165
echo === Read zeros
io_zero readv $((offset + 2 * 4096)) $((1 * 4096)) $((9 * 4096)) 256
io_zero readv $((offset + 6 * 4096)) $((2 * 4096)) $((9 * 4096)) 256
}

View File

@ -0,0 +1,265 @@
#!/bin/sh
#
# Copyright (C) 2009 Red Hat, Inc.
# Copyright (c) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
dd()
{
if [ "$HOSTOS" == "Linux" ]
then
command dd --help | grep noxfer > /dev/null 2>&1
if [ "$?" -eq 0 ]
then
command dd status=noxfer $@
else
command dd $@
fi
else
command dd $@
fi
}
# we need common.config
if [ "$iam" != "check" ]
then
if ! . ./common.config
then
echo "$iam: failed to source common.config"
exit 1
fi
fi
# make sure we have a standard umask
umask 022
TEST_IMG=$TEST_DIR/t.$IMGFMT
_make_test_img()
{
# extra qemu-img options can be added by tests
# at least one argument (the image size) needs to be added
local extra_img_options=$*
# XXX(hch): have global image options?
$QEMU_IMG create -f $IMGFMT $TEST_IMG $extra_img_options | \
sed -e "s#$TEST_DIR#TEST_DIR#g" | \
sed -e "s#$IMGFMT#IMGFMT#g" | \
sed -e "s# encryption=off##g" | \
sed -e "s# cluster_size=0##g" | \
sed -e "s# compat6=off##g"
}
_cleanup_test_img()
{
rm -f $TEST_DIR/t.$IMGFMT
rm -f $TEST_DIR/t.$IMGFMT.orig
}
_check_test_img()
{
$QEMU_IMG check -f $IMGFMT $TEST_IMG
}
_get_pids_by_name()
{
if [ $# -ne 1 ]
then
echo "Usage: _get_pids_by_name process-name" 1>&2
exit 1
fi
# Algorithm ... all ps(1) variants have a time of the form MM:SS or
# HH:MM:SS before the psargs field, use this as the search anchor.
#
# Matches with $1 (process-name) occur if the first psarg is $1
# or ends in /$1 ... the matching uses sed's regular expressions,
# so passing a regex into $1 will work.
ps $PS_ALL_FLAGS \
| sed -n \
-e 's/$/ /' \
-e 's/[ ][ ]*/ /g' \
-e 's/^ //' \
-e 's/^[^ ]* //' \
-e "/[0-9]:[0-9][0-9] *[^ ]*\/$1 /s/ .*//p" \
-e "/[0-9]:[0-9][0-9] *$1 /s/ .*//p"
}
# fqdn for localhost
#
_get_fqdn()
{
host=`hostname`
$NSLOOKUP_PROG $host | $AWK_PROG '{ if ($1 == "Name:") print $2 }'
}
# check if run as root
#
_need_to_be_root()
{
id=`id | $SED_PROG -e 's/(.*//' -e 's/.*=//'`
if [ "$id" -ne 0 ]
then
echo "Arrgh ... you need to be root (not uid=$id) to run this test"
exit 1
fi
}
# Do a command, log it to $seq.full, optionally test return status
# and die if command fails. If called with one argument _do executes the
# command, logs it, and returns its exit status. With two arguments _do
# first prints the message passed in the first argument, and then "done"
# or "fail" depending on the return status of the command passed in the
# second argument. If the command fails and the variable _do_die_on_error
# is set to "always" or the two argument form is used and _do_die_on_error
# is set to "message_only" _do will print an error message to
# $seq.out and exit.
_do()
{
if [ $# -eq 1 ]; then
_cmd=$1
elif [ $# -eq 2 ]; then
_note=$1
_cmd=$2
echo -n "$_note... "
else
echo "Usage: _do [note] cmd" 1>&2
status=1; exit
fi
(eval "echo '---' \"$_cmd\"") >>$here/$seq.full
(eval "$_cmd") >$tmp._out 2>&1; ret=$?
cat $tmp._out >>$here/$seq.full
if [ $# -eq 2 ]; then
if [ $ret -eq 0 ]; then
echo "done"
else
echo "fail"
fi
fi
if [ $ret -ne 0 ] \
&& [ "$_do_die_on_error" = "always" \
-o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
then
[ $# -ne 2 ] && echo
eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full"
status=1; exit
fi
return $ret
}
# bail out, setting up .notrun file
#
_notrun()
{
echo "$*" >$seq.notrun
echo "$seq not run: $*"
status=0
exit
}
# just plain bail out
#
_fail()
{
echo "$*" | tee -a $here/$seq.full
echo "(see $seq.full for details)"
status=1
exit 1
}
# tests whether $IMGFMT is one of the supported image formats for a test
#
_supported_fmt()
{
for f; do
if [ "$f" = "$IMGFMT" -o "$f" = "generic" ]; then
return
fi
done
_notrun "not suitable for this image format: $IMGFMT"
}
# tests whether the host OS is one of the supported OSes for a test
#
_supported_os()
{
for h
do
if [ "$h" = "$HOSTOS" ]
then
return
fi
done
_notrun "not suitable for this OS: $HOSTOS"
}
# this test requires that a specified command (executable) exists
#
_require_command()
{
[ -x "$1" ] || _notrun "$1 utility required, skipped this test"
}
_full_imgfmt_details()
{
echo "$IMGFMT"
}
_full_platform_details()
{
os=`uname -s`
host=`hostname -s`
kernel=`uname -r`
platform=`uname -m`
echo "$os/$platform $host $kernel"
}
_link_out_file()
{
if [ -z "$1" ]; then
echo Error must pass \$seq.
exit
fi
rm -f $1
if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
ln -s $1.irix $1
elif [ "`uname`" == "Linux" ]; then
ln -s $1.linux $1
else
echo Error test $seq does not run on the operating system: `uname`
exit
fi
}
_die()
{
echo $@
exit 1
}
# make sure this script returns success
/bin/true

23
tests/qemu-iotests/group Normal file
View File

@ -0,0 +1,23 @@
#
# QA groups control file
# Defines test groups
# - do not start group names with a digit
#
#
# test-group association ... one line per test
#
001 rw auto
002 rw auto
003 rw auto
004 rw auto
005 img auto
006 img auto
007 snapshot auto
008 rw auto
009 rw auto
010 rw auto
011 rw auto
012 auto
013 rw auto
014 rw auto