summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/avocado/avocado_qemu/__init__.py17
-rwxr-xr-xtests/qemu-iotests/1085
-rw-r--r--tests/qemu-iotests/223.out4
-rw-r--r--tests/qemu-iotests/307.out4
-rw-r--r--tests/qemu-iotests/mypy.ini2
-rwxr-xr-xtests/qemu-iotests/tests/copy-before-write8
-rw-r--r--tests/tcg/Makefile.target1
-rw-r--r--tests/tcg/aarch64/system/pauth-3.c2
-rw-r--r--tests/tcg/aarch64/system/semiconsole.c2
-rw-r--r--tests/tcg/aarch64/system/semiheap.c2
-rw-r--r--tests/tcg/multiarch/system/memory.c2
-rw-r--r--tests/unit/test-block-iothread.c153
-rw-r--r--tests/unit/test-crypto-block.c38
-rwxr-xr-xtests/vm/fedora1
-rwxr-xr-xtests/vm/freebsd1
-rwxr-xr-xtests/vm/netbsd1
-rwxr-xr-xtests/vm/openbsd1
17 files changed, 190 insertions, 54 deletions
diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado_qemu/__init__.py
index b656a70c55..ed4853c805 100644
--- a/tests/avocado/avocado_qemu/__init__.py
+++ b/tests/avocado/avocado_qemu/__init__.py
@@ -120,14 +120,15 @@ def pick_default_qemu_bin(bin_prefix='qemu-system-', arch=None):
# qemu binary path does not match arch for powerpc, handle it
if 'ppc64le' in arch:
arch = 'ppc64'
- qemu_bin_relative_path = os.path.join(".", bin_prefix + arch)
- if is_readable_executable_file(qemu_bin_relative_path):
- return qemu_bin_relative_path
-
- qemu_bin_from_bld_dir_path = os.path.join(BUILD_DIR,
- qemu_bin_relative_path)
- if is_readable_executable_file(qemu_bin_from_bld_dir_path):
- return qemu_bin_from_bld_dir_path
+ qemu_bin_name = bin_prefix + arch
+ qemu_bin_paths = [
+ os.path.join(".", qemu_bin_name),
+ os.path.join(BUILD_DIR, qemu_bin_name),
+ os.path.join(BUILD_DIR, "build", qemu_bin_name),
+ ]
+ for path in qemu_bin_paths:
+ if is_readable_executable_file(path):
+ return path
return None
diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108
index 9e923d6a59..54e935acf2 100755
--- a/tests/qemu-iotests/108
+++ b/tests/qemu-iotests/108
@@ -60,6 +60,11 @@ if sudo -n losetup &>/dev/null; then
else
loopdev=false
+ # Check for usable FUSE in the host environment:
+ if test ! -c "/dev/fuse"; then
+ _notrun 'No passwordless sudo nor usable /dev/fuse'
+ fi
+
# QSD --export fuse will either yield "Parameter 'id' is missing"
# or "Invalid parameter 'fuse'", depending on whether there is
# FUSE support or not.
diff --git a/tests/qemu-iotests/223.out b/tests/qemu-iotests/223.out
index 0647941531..26fb347c5d 100644
--- a/tests/qemu-iotests/223.out
+++ b/tests/qemu-iotests/223.out
@@ -93,7 +93,7 @@ exports available: 3
export: 'n2'
description: some text
size: 4194304
- flags: 0xced ( flush fua trim zeroes df cache fast-zero )
+ flags: 0xded ( flush fua trim zeroes df multi cache fast-zero )
min block: 1
opt block: 4096
max block: 33554432
@@ -212,7 +212,7 @@ exports available: 3
export: 'n2'
description: some text
size: 4194304
- flags: 0xced ( flush fua trim zeroes df cache fast-zero )
+ flags: 0xded ( flush fua trim zeroes df multi cache fast-zero )
min block: 1
opt block: 4096
max block: 33554432
diff --git a/tests/qemu-iotests/307.out b/tests/qemu-iotests/307.out
index ec8d2be0e0..390f05d1b7 100644
--- a/tests/qemu-iotests/307.out
+++ b/tests/qemu-iotests/307.out
@@ -83,7 +83,7 @@ exports available: 2
export: 'export1'
description: This is the writable second export
size: 67108864
- flags: 0xced ( flush fua trim zeroes df cache fast-zero )
+ flags: 0xded ( flush fua trim zeroes df multi cache fast-zero )
min block: XXX
opt block: XXX
max block: XXX
@@ -109,7 +109,7 @@ exports available: 1
export: 'export1'
description: This is the writable second export
size: 67108864
- flags: 0xced ( flush fua trim zeroes df cache fast-zero )
+ flags: 0xded ( flush fua trim zeroes df multi cache fast-zero )
min block: XXX
opt block: XXX
max block: XXX
diff --git a/tests/qemu-iotests/mypy.ini b/tests/qemu-iotests/mypy.ini
index 4c0339f558..d66ffc2e3c 100644
--- a/tests/qemu-iotests/mypy.ini
+++ b/tests/qemu-iotests/mypy.ini
@@ -9,4 +9,4 @@ no_implicit_optional = True
scripts_are_modules = True
warn_redundant_casts = True
warn_unused_configs = True
-warn_unused_ignores = True
+warn_unused_ignores = False
diff --git a/tests/qemu-iotests/tests/copy-before-write b/tests/qemu-iotests/tests/copy-before-write
index 16efebbf8f..2ffe092b31 100755
--- a/tests/qemu-iotests/tests/copy-before-write
+++ b/tests/qemu-iotests/tests/copy-before-write
@@ -192,6 +192,11 @@ read 1048576/1048576 bytes at offset 0
def test_timeout_break_guest(self):
log = self.do_cbw_timeout('break-guest-write')
+ # macOS and FreeBSD tend to represent ETIMEDOUT as
+ # "Operation timed out", when Linux prefer
+ # "Connection timed out"
+ log = log.replace('Operation timed out',
+ 'Connection timed out')
self.assertEqual(log, """\
wrote 524288/524288 bytes at offset 0
512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -213,4 +218,5 @@ read failed: Permission denied
if __name__ == '__main__':
iotests.main(supported_fmts=['qcow2'],
- supported_protocols=['file'])
+ supported_protocols=['file'],
+ required_fmts=['copy-before-write'])
diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target
index f427a0304e..e68830af15 100644
--- a/tests/tcg/Makefile.target
+++ b/tests/tcg/Makefile.target
@@ -111,6 +111,7 @@ else
# For softmmu targets we include a different Makefile fragement as the
# build options for bare programs are usually pretty different. They
# are expected to provide their own build recipes.
+EXTRA_CFLAGS += -ffreestanding
-include $(SRC_PATH)/tests/tcg/minilib/Makefile.target
-include $(SRC_PATH)/tests/tcg/multiarch/system/Makefile.softmmu-target
-include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.softmmu-target
diff --git a/tests/tcg/aarch64/system/pauth-3.c b/tests/tcg/aarch64/system/pauth-3.c
index 42eff4d5ea..77a467277b 100644
--- a/tests/tcg/aarch64/system/pauth-3.c
+++ b/tests/tcg/aarch64/system/pauth-3.c
@@ -1,4 +1,4 @@
-#include <inttypes.h>
+#include <stdint.h>
#include <minilib.h>
int main()
diff --git a/tests/tcg/aarch64/system/semiconsole.c b/tests/tcg/aarch64/system/semiconsole.c
index bfe7c9e26b..81324c639f 100644
--- a/tests/tcg/aarch64/system/semiconsole.c
+++ b/tests/tcg/aarch64/system/semiconsole.c
@@ -6,7 +6,7 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
-#include <inttypes.h>
+#include <stdint.h>
#include <minilib.h>
#define SYS_READC 0x7
diff --git a/tests/tcg/aarch64/system/semiheap.c b/tests/tcg/aarch64/system/semiheap.c
index 4ed258476d..a254bd8982 100644
--- a/tests/tcg/aarch64/system/semiheap.c
+++ b/tests/tcg/aarch64/system/semiheap.c
@@ -6,7 +6,7 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
-#include <inttypes.h>
+#include <stdint.h>
#include <stddef.h>
#include <minilib.h>
diff --git a/tests/tcg/multiarch/system/memory.c b/tests/tcg/multiarch/system/memory.c
index 41c7f66e2e..214f7d4f54 100644
--- a/tests/tcg/multiarch/system/memory.c
+++ b/tests/tcg/multiarch/system/memory.c
@@ -12,7 +12,7 @@
* - sign extension when loading
*/
-#include <inttypes.h>
+#include <stdint.h>
#include <stdbool.h>
#include <minilib.h>
diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c
index 94718c9319..8b55eccc89 100644
--- a/tests/unit/test-block-iothread.c
+++ b/tests/unit/test-block-iothread.c
@@ -88,11 +88,11 @@ static void test_sync_op_pread(BdrvChild *c)
int ret;
/* Success */
- ret = bdrv_pread(c, 0, buf, sizeof(buf));
- g_assert_cmpint(ret, ==, 512);
+ ret = bdrv_pread(c, 0, sizeof(buf), buf, 0);
+ g_assert_cmpint(ret, ==, 0);
/* Early error: Negative offset */
- ret = bdrv_pread(c, -2, buf, sizeof(buf));
+ ret = bdrv_pread(c, -2, sizeof(buf), buf, 0);
g_assert_cmpint(ret, ==, -EIO);
}
@@ -102,11 +102,11 @@ static void test_sync_op_pwrite(BdrvChild *c)
int ret;
/* Success */
- ret = bdrv_pwrite(c, 0, buf, sizeof(buf));
- g_assert_cmpint(ret, ==, 512);
+ ret = bdrv_pwrite(c, 0, sizeof(buf), buf, 0);
+ g_assert_cmpint(ret, ==, 0);
/* Early error: Negative offset */
- ret = bdrv_pwrite(c, -2, buf, sizeof(buf));
+ ret = bdrv_pwrite(c, -2, sizeof(buf), buf, 0);
g_assert_cmpint(ret, ==, -EIO);
}
@@ -116,11 +116,11 @@ static void test_sync_op_blk_pread(BlockBackend *blk)
int ret;
/* Success */
- ret = blk_pread(blk, 0, buf, sizeof(buf));
- g_assert_cmpint(ret, ==, 512);
+ ret = blk_pread(blk, 0, sizeof(buf), buf, 0);
+ g_assert_cmpint(ret, ==, 0);
/* Early error: Negative offset */
- ret = blk_pread(blk, -2, buf, sizeof(buf));
+ ret = blk_pread(blk, -2, sizeof(buf), buf, 0);
g_assert_cmpint(ret, ==, -EIO);
}
@@ -130,11 +130,98 @@ static void test_sync_op_blk_pwrite(BlockBackend *blk)
int ret;
/* Success */
- ret = blk_pwrite(blk, 0, buf, sizeof(buf), 0);
- g_assert_cmpint(ret, ==, 512);
+ ret = blk_pwrite(blk, 0, sizeof(buf), buf, 0);
+ g_assert_cmpint(ret, ==, 0);
+
+ /* Early error: Negative offset */
+ ret = blk_pwrite(blk, -2, sizeof(buf), buf, 0);
+ g_assert_cmpint(ret, ==, -EIO);
+}
+
+static void test_sync_op_blk_preadv(BlockBackend *blk)
+{
+ uint8_t buf[512];
+ QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, sizeof(buf));
+ int ret;
+
+ /* Success */
+ ret = blk_preadv(blk, 0, sizeof(buf), &qiov, 0);
+ g_assert_cmpint(ret, ==, 0);
/* Early error: Negative offset */
- ret = blk_pwrite(blk, -2, buf, sizeof(buf), 0);
+ ret = blk_preadv(blk, -2, sizeof(buf), &qiov, 0);
+ g_assert_cmpint(ret, ==, -EIO);
+}
+
+static void test_sync_op_blk_pwritev(BlockBackend *blk)
+{
+ uint8_t buf[512] = { 0 };
+ QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, sizeof(buf));
+ int ret;
+
+ /* Success */
+ ret = blk_pwritev(blk, 0, sizeof(buf), &qiov, 0);
+ g_assert_cmpint(ret, ==, 0);
+
+ /* Early error: Negative offset */
+ ret = blk_pwritev(blk, -2, sizeof(buf), &qiov, 0);
+ g_assert_cmpint(ret, ==, -EIO);
+}
+
+static void test_sync_op_blk_preadv_part(BlockBackend *blk)
+{
+ uint8_t buf[512];
+ QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, sizeof(buf));
+ int ret;
+
+ /* Success */
+ ret = blk_preadv_part(blk, 0, sizeof(buf), &qiov, 0, 0);
+ g_assert_cmpint(ret, ==, 0);
+
+ /* Early error: Negative offset */
+ ret = blk_preadv_part(blk, -2, sizeof(buf), &qiov, 0, 0);
+ g_assert_cmpint(ret, ==, -EIO);
+}
+
+static void test_sync_op_blk_pwritev_part(BlockBackend *blk)
+{
+ uint8_t buf[512] = { 0 };
+ QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, sizeof(buf));
+ int ret;
+
+ /* Success */
+ ret = blk_pwritev_part(blk, 0, sizeof(buf), &qiov, 0, 0);
+ g_assert_cmpint(ret, ==, 0);
+
+ /* Early error: Negative offset */
+ ret = blk_pwritev_part(blk, -2, sizeof(buf), &qiov, 0, 0);
+ g_assert_cmpint(ret, ==, -EIO);
+}
+
+static void test_sync_op_blk_pwrite_compressed(BlockBackend *blk)
+{
+ uint8_t buf[512] = { 0 };
+ int ret;
+
+ /* Late error: Not supported */
+ ret = blk_pwrite_compressed(blk, 0, sizeof(buf), buf);
+ g_assert_cmpint(ret, ==, -ENOTSUP);
+
+ /* Early error: Negative offset */
+ ret = blk_pwrite_compressed(blk, -2, sizeof(buf), buf);
+ g_assert_cmpint(ret, ==, -EIO);
+}
+
+static void test_sync_op_blk_pwrite_zeroes(BlockBackend *blk)
+{
+ int ret;
+
+ /* Success */
+ ret = blk_pwrite_zeroes(blk, 0, 512, 0);
+ g_assert_cmpint(ret, ==, 0);
+
+ /* Early error: Negative offset */
+ ret = blk_pwrite_zeroes(blk, -2, 512, 0);
g_assert_cmpint(ret, ==, -EIO);
}
@@ -211,6 +298,19 @@ static void test_sync_op_truncate(BdrvChild *c)
c->bs->open_flags |= BDRV_O_RDWR;
}
+static void test_sync_op_blk_truncate(BlockBackend *blk)
+{
+ int ret;
+
+ /* Normal success path */
+ ret = blk_truncate(blk, 65536, false, PREALLOC_MODE_OFF, 0, NULL);
+ g_assert_cmpint(ret, ==, 0);
+
+ /* Early error: Negative offset */
+ ret = blk_truncate(blk, -2, false, PREALLOC_MODE_OFF, 0, NULL);
+ g_assert_cmpint(ret, ==, -EINVAL);
+}
+
static void test_sync_op_block_status(BdrvChild *c)
{
int ret;
@@ -302,6 +402,30 @@ const SyncOpTest sync_op_tests[] = {
.fn = test_sync_op_pwrite,
.blkfn = test_sync_op_blk_pwrite,
}, {
+ .name = "/sync-op/preadv",
+ .fn = NULL,
+ .blkfn = test_sync_op_blk_preadv,
+ }, {
+ .name = "/sync-op/pwritev",
+ .fn = NULL,
+ .blkfn = test_sync_op_blk_pwritev,
+ }, {
+ .name = "/sync-op/preadv_part",
+ .fn = NULL,
+ .blkfn = test_sync_op_blk_preadv_part,
+ }, {
+ .name = "/sync-op/pwritev_part",
+ .fn = NULL,
+ .blkfn = test_sync_op_blk_pwritev_part,
+ }, {
+ .name = "/sync-op/pwrite_compressed",
+ .fn = NULL,
+ .blkfn = test_sync_op_blk_pwrite_compressed,
+ }, {
+ .name = "/sync-op/pwrite_zeroes",
+ .fn = NULL,
+ .blkfn = test_sync_op_blk_pwrite_zeroes,
+ }, {
.name = "/sync-op/load_vmstate",
.fn = test_sync_op_load_vmstate,
}, {
@@ -314,6 +438,7 @@ const SyncOpTest sync_op_tests[] = {
}, {
.name = "/sync-op/truncate",
.fn = test_sync_op_truncate,
+ .blkfn = test_sync_op_blk_truncate,
}, {
.name = "/sync-op/block_status",
.fn = test_sync_op_block_status,
@@ -349,7 +474,9 @@ static void test_sync_op(const void *opaque)
blk_set_aio_context(blk, ctx, &error_abort);
aio_context_acquire(ctx);
- t->fn(c);
+ if (t->fn) {
+ t->fn(c);
+ }
if (t->blkfn) {
t->blkfn(blk);
}
diff --git a/tests/unit/test-crypto-block.c b/tests/unit/test-crypto-block.c
index 3b1f0d509f..3417b67be5 100644
--- a/tests/unit/test-crypto-block.c
+++ b/tests/unit/test-crypto-block.c
@@ -188,12 +188,12 @@ static struct QCryptoBlockTestData {
};
-static ssize_t test_block_read_func(QCryptoBlock *block,
- size_t offset,
- uint8_t *buf,
- size_t buflen,
- void *opaque,
- Error **errp)
+static int test_block_read_func(QCryptoBlock *block,
+ size_t offset,
+ uint8_t *buf,
+ size_t buflen,
+ void *opaque,
+ Error **errp)
{
Buffer *header = opaque;
@@ -201,14 +201,14 @@ static ssize_t test_block_read_func(QCryptoBlock *block,
memcpy(buf, header->buffer + offset, buflen);
- return buflen;
+ return 0;
}
-static ssize_t test_block_init_func(QCryptoBlock *block,
- size_t headerlen,
- void *opaque,
- Error **errp)
+static int test_block_init_func(QCryptoBlock *block,
+ size_t headerlen,
+ void *opaque,
+ Error **errp)
{
Buffer *header = opaque;
@@ -216,16 +216,16 @@ static ssize_t test_block_init_func(QCryptoBlock *block,
buffer_reserve(header, headerlen);
- return headerlen;
+ return 0;
}
-static ssize_t test_block_write_func(QCryptoBlock *block,
- size_t offset,
- const uint8_t *buf,
- size_t buflen,
- void *opaque,
- Error **errp)
+static int test_block_write_func(QCryptoBlock *block,
+ size_t offset,
+ const uint8_t *buf,
+ size_t buflen,
+ void *opaque,
+ Error **errp)
{
Buffer *header = opaque;
@@ -234,7 +234,7 @@ static ssize_t test_block_write_func(QCryptoBlock *block,
memcpy(header->buffer + offset, buf, buflen);
header->offset = offset + buflen;
- return buflen;
+ return 0;
}
diff --git a/tests/vm/fedora b/tests/vm/fedora
index 92b78d6e2c..12eca919a0 100755
--- a/tests/vm/fedora
+++ b/tests/vm/fedora
@@ -79,7 +79,6 @@ class FedoraVM(basevm.BaseVM):
self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
- "-bios", "pc-bios/bios-256k.bin",
"-machine", "graphics=off",
"-device", "VGA",
"-cdrom", iso
diff --git a/tests/vm/freebsd b/tests/vm/freebsd
index 805db759d6..cd1fabde52 100755
--- a/tests/vm/freebsd
+++ b/tests/vm/freebsd
@@ -95,7 +95,6 @@ class FreeBSDVM(basevm.BaseVM):
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
- "-bios", "pc-bios/bios-256k.bin",
"-machine", "graphics=off",
"-device", "VGA",
"-cdrom", iso
diff --git a/tests/vm/netbsd b/tests/vm/netbsd
index 45aa9a7fda..aa883ec23c 100755
--- a/tests/vm/netbsd
+++ b/tests/vm/netbsd
@@ -86,7 +86,6 @@ class NetBSDVM(basevm.BaseVM):
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
- "-bios", "pc-bios/bios-256k.bin",
"-machine", "graphics=off",
"-cdrom", iso
])
diff --git a/tests/vm/openbsd b/tests/vm/openbsd
index 13c8254214..6f1b6f5b98 100755
--- a/tests/vm/openbsd
+++ b/tests/vm/openbsd
@@ -82,7 +82,6 @@ class OpenBSDVM(basevm.BaseVM):
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
- "-bios", "pc-bios/bios-256k.bin",
"-machine", "graphics=off",
"-device", "VGA",
"-cdrom", iso