aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bios-tables-test.c4
-rw-r--r--tests/cpu-plug-test.c18
-rw-r--r--tests/docker/Makefile.include2
-rwxr-xr-xtests/docker/docker.py4
-rwxr-xr-xtests/docker/test-mingw3
-rw-r--r--tests/guest-debug/test-gdbstub.py2
-rwxr-xr-xtests/qemu-iotests/16970
-rw-r--r--tests/qemu-iotests/169.out4
-rwxr-xr-x[-rw-r--r--]tests/qemu-iotests/2180
-rw-r--r--tests/qemu-iotests/common.qemu2
-rw-r--r--tests/qemu-iotests/common.rc4
-rw-r--r--tests/tcg/Makefile.include2
-rw-r--r--tests/tcg/Makefile.probe2
-rw-r--r--tests/tcg/README2
-rw-r--r--tests/tcg/mips/mips64-dsp/subq_s_pw.c2
-rwxr-xr-xtests/vm/basevm.py30
-rwxr-xr-xtests/vm/centos1
-rwxr-xr-xtests/vm/freebsd1
-rwxr-xr-xtests/vm/netbsd1
-rwxr-xr-xtests/vm/openbsd1
-rwxr-xr-xtests/vm/ubuntu.i3861
21 files changed, 119 insertions, 37 deletions
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 4e24930c4b..02e77ec811 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -319,7 +319,7 @@ static bool load_asl(GArray *sdts, AcpiSdtTable *sdt)
ret = g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);
g_assert_no_error(error);
if (ret) {
- ret = g_file_get_contents(sdt->asl_file, (gchar **)&sdt->asl,
+ ret = g_file_get_contents(sdt->asl_file, &sdt->asl,
&sdt->asl_len, &error);
g_assert(ret);
g_assert_no_error(error);
@@ -390,7 +390,7 @@ try_again:
if (g_file_test(aml_file, G_FILE_TEST_EXISTS)) {
exp_sdt.aml_file = aml_file;
} else if (*ext != '\0') {
- /* try fallback to generic (extention less) expected file */
+ /* try fallback to generic (extension less) expected file */
ext = "";
g_free(aml_file);
goto try_again;
diff --git a/tests/cpu-plug-test.c b/tests/cpu-plug-test.c
index 3e93c8e096..f4a677d238 100644
--- a/tests/cpu-plug-test.c
+++ b/tests/cpu-plug-test.c
@@ -32,12 +32,12 @@ static void test_plug_with_cpu_add(gconstpointer data)
unsigned int i;
args = g_strdup_printf("-machine %s -cpu %s "
- "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
+ "-smp 1,sockets=%u,cores=%u,threads=%u,maxcpus=%u",
s->machine, s->cpu_model,
s->sockets, s->cores, s->threads, s->maxcpus);
qtest_start(args);
- for (i = s->sockets * s->cores * s->threads; i < s->maxcpus; i++) {
+ for (i = 1; i < s->maxcpus; i++) {
response = qmp("{ 'execute': 'cpu-add',"
" 'arguments': { 'id': %d } }", i);
g_assert(response);
@@ -56,7 +56,7 @@ static void test_plug_without_cpu_add(gconstpointer data)
QDict *response;
args = g_strdup_printf("-machine %s -cpu %s "
- "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
+ "-smp 1,sockets=%u,cores=%u,threads=%u,maxcpus=%u",
s->machine, s->cpu_model,
s->sockets, s->cores, s->threads, s->maxcpus);
qtest_start(args);
@@ -79,12 +79,12 @@ static void test_plug_with_device_add_x86(gconstpointer data)
unsigned int s, c, t;
args = g_strdup_printf("-machine %s -cpu %s "
- "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
+ "-smp 1,sockets=%u,cores=%u,threads=%u,maxcpus=%u",
td->machine, td->cpu_model,
td->sockets, td->cores, td->threads, td->maxcpus);
qtest_start(args);
- for (s = td->sockets; s < td->maxcpus / td->cores / td->threads; s++) {
+ for (s = 1; s < td->sockets; s++) {
for (c = 0; c < td->cores; c++) {
for (t = 0; t < td->threads; t++) {
char *id = g_strdup_printf("id-%i-%i-%i", s, c, t);
@@ -113,7 +113,7 @@ static void test_plug_with_device_add_coreid(gconstpointer data)
td->sockets, td->cores, td->threads, td->maxcpus);
qtest_start(args);
- for (c = td->cores; c < td->maxcpus / td->sockets / td->threads; c++) {
+ for (c = 1; c < td->cores; c++) {
char *id = g_strdup_printf("id-%i", c);
qtest_qmp_device_add(td->device_model, id, "{'core-id':%u}", c);
g_free(id);
@@ -148,7 +148,7 @@ static void add_pc_test_case(const char *mname)
data->sockets = 1;
data->cores = 3;
data->threads = 2;
- data->maxcpus = data->sockets * data->cores * data->threads * 2;
+ data->maxcpus = data->sockets * data->cores * data->threads;
if (g_str_has_suffix(mname, "-1.4") ||
(strcmp(mname, "pc-1.3") == 0) ||
(strcmp(mname, "pc-1.2") == 0) ||
@@ -203,7 +203,7 @@ static void add_pseries_test_case(const char *mname)
data->sockets = 2;
data->cores = 3;
data->threads = 1;
- data->maxcpus = data->sockets * data->cores * data->threads * 2;
+ data->maxcpus = data->sockets * data->cores * data->threads;
path = g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus=%u",
mname, data->sockets, data->cores,
@@ -229,7 +229,7 @@ static void add_s390x_test_case(const char *mname)
data->sockets = 1;
data->cores = 3;
data->threads = 1;
- data->maxcpus = data->sockets * data->cores * data->threads * 2;
+ data->maxcpus = data->sockets * data->cores * data->threads;
data2 = g_memdup(data, sizeof(PlugTestData));
data2->machine = g_strdup(data->machine);
diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include
index 6e03235ab9..9467e9d088 100644
--- a/tests/docker/Makefile.include
+++ b/tests/docker/Makefile.include
@@ -41,7 +41,7 @@ docker-qemu-src: $(DOCKER_SRC_COPY)
docker-image: ${DOCKER_TARGETS}
# General rule for building docker images. If we are a sub-make
-# invoked with SKIP_DOCKER_BUILD we still check the image is upto date
+# invoked with SKIP_DOCKER_BUILD we still check the image is up to date
# though
ifdef SKIP_DOCKER_BUILD
docker-image-%: $(DOCKER_FILES_DIR)/%.docker
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index 44d5f7493b..02d8a83847 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -97,7 +97,7 @@ def _get_so_libs(executable):
return libs
def _copy_binary_with_libs(src, dest_dir):
- """Copy a binary executable and all its dependant libraries.
+ """Copy a binary executable and all its dependent libraries.
This does rely on the host file-system being fairly multi-arch
aware so the file don't clash with the guests layout."""
@@ -284,7 +284,7 @@ class SubCommand(object):
name = None # Subcommand name
def shared_args(self, parser):
parser.add_argument("--quiet", action="store_true",
- help="Run quietly unless an error occured")
+ help="Run quietly unless an error occurred")
def args(self, parser):
"""Setup argument parser"""
diff --git a/tests/docker/test-mingw b/tests/docker/test-mingw
index 7cca7e16a6..b078f22879 100755
--- a/tests/docker/test-mingw
+++ b/tests/docker/test-mingw
@@ -28,8 +28,7 @@ for prefix in x86_64-w64-mingw32- i686-w64-mingw32-; do
--enable-vnc \
--enable-bzip2 \
--enable-guest-agent \
- --with-sdlabi=2.0 \
- --with-gtkabi=3.0
+ --with-sdlabi=2.0
install_qemu
make clean
diff --git a/tests/guest-debug/test-gdbstub.py b/tests/guest-debug/test-gdbstub.py
index 474d2c5c65..0e4ac01426 100644
--- a/tests/guest-debug/test-gdbstub.py
+++ b/tests/guest-debug/test-gdbstub.py
@@ -122,7 +122,7 @@ class CatchBreakpoint(gdb.Breakpoint):
def run_test():
- "Run throught the tests one by one"
+ "Run through the tests one by one"
print ("Checking we can step the first few instructions")
step_ok = 0
diff --git a/tests/qemu-iotests/169 b/tests/qemu-iotests/169
index f243db9955..69850c4c67 100755
--- a/tests/qemu-iotests/169
+++ b/tests/qemu-iotests/169
@@ -24,6 +24,7 @@ import time
import itertools
import operator
import new
+import re
from iotests import qemu_img
@@ -58,7 +59,6 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
'granularity': granularity}
if persistent:
params['persistent'] = True
- params['autoload'] = True
result = vm.qmp('block-dirty-bitmap-add', **params)
self.assert_qmp(result, 'return', {});
@@ -77,6 +77,58 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
self.assert_qmp(result, 'error/desc',
"Dirty bitmap 'bitmap0' not found");
+ def do_test_migration_resume_source(self, persistent, migrate_bitmaps):
+ granularity = 512
+
+ # regions = ((start, count), ...)
+ regions = ((0, 0x10000),
+ (0xf0000, 0x10000),
+ (0xa0201, 0x1000))
+
+ mig_caps = [{'capability': 'events', 'state': True}]
+ if migrate_bitmaps:
+ mig_caps.append({'capability': 'dirty-bitmaps', 'state': True})
+
+ result = self.vm_a.qmp('migrate-set-capabilities',
+ capabilities=mig_caps)
+ self.assert_qmp(result, 'return', {})
+
+ self.add_bitmap(self.vm_a, granularity, persistent)
+ for r in regions:
+ self.vm_a.hmp_qemu_io('drive0', 'write %d %d' % r)
+ sha256 = self.get_bitmap_hash(self.vm_a)
+
+ result = self.vm_a.qmp('migrate', uri=mig_cmd)
+ while True:
+ event = self.vm_a.event_wait('MIGRATION')
+ if event['data']['status'] == 'completed':
+ break
+
+ # test that bitmap is still here
+ removed = (not migrate_bitmaps) and persistent
+ self.check_bitmap(self.vm_a, False if removed else sha256)
+
+ self.vm_a.qmp('cont')
+
+ # test that bitmap is still here after invalidation
+ self.check_bitmap(self.vm_a, sha256)
+
+ # shutdown and check that invalidation didn't fail
+ self.vm_a.shutdown()
+
+ # catch 'Could not reopen qcow2 layer: Bitmap already exists'
+ # possible error
+ log = self.vm_a.get_log()
+ log = re.sub(r'^\[I \d+\.\d+\] OPENED\n', '', log)
+ log = re.sub(r'^(wrote .* bytes at offset .*\n.*KiB.*ops.*sec.*\n){3}',
+ '', log)
+ log = re.sub(r'\[I \+\d+\.\d+\] CLOSED\n?$', '', log)
+ self.assertEqual(log, '')
+
+ # test that bitmap is still persistent
+ self.vm_a.launch()
+ self.check_bitmap(self.vm_a, sha256 if persistent else False)
+
def do_test_migration(self, persistent, migrate_bitmaps, online,
shared_storage):
granularity = 512
@@ -134,6 +186,14 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
if should_migrate:
self.vm_b.shutdown()
+
+ # catch 'Could not reopen qcow2 layer: Bitmap already exists'
+ # possible error
+ log = self.vm_b.get_log()
+ log = re.sub(r'^\[I \d+\.\d+\] OPENED\n', '', log)
+ log = re.sub(r'\[I \+\d+\.\d+\] CLOSED\n?$', '', log)
+ self.assertEqual(log, '')
+
# recreate vm_b, as we don't want -incoming option (this will lead
# to "cat" process left alive after test finish)
self.vm_b = iotests.VM(path_suffix='b')
@@ -144,7 +204,7 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
def inject_test_case(klass, name, method, *args, **kwargs):
mc = operator.methodcaller(method, *args, **kwargs)
- setattr(klass, 'test_' + name, new.instancemethod(mc, None, klass))
+ setattr(klass, 'test_' + method + name, new.instancemethod(mc, None, klass))
for cmb in list(itertools.product((True, False), repeat=4)):
name = ('_' if cmb[0] else '_not_') + 'persistent_'
@@ -155,6 +215,12 @@ for cmb in list(itertools.product((True, False), repeat=4)):
inject_test_case(TestDirtyBitmapMigration, name, 'do_test_migration',
*list(cmb))
+for cmb in list(itertools.product((True, False), repeat=2)):
+ name = ('_' if cmb[0] else '_not_') + 'persistent_'
+ name += ('_' if cmb[1] else '_not_') + 'migbitmap'
+
+ inject_test_case(TestDirtyBitmapMigration, name,
+ 'do_test_migration_resume_source', *list(cmb))
if __name__ == '__main__':
iotests.main(supported_fmts=['qcow2'])
diff --git a/tests/qemu-iotests/169.out b/tests/qemu-iotests/169.out
index b6f257674e..3a89159833 100644
--- a/tests/qemu-iotests/169.out
+++ b/tests/qemu-iotests/169.out
@@ -1,5 +1,5 @@
-................
+....................
----------------------------------------------------------------------
-Ran 16 tests
+Ran 20 tests
OK
diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218
index 92c331b6fb..92c331b6fb 100644..100755
--- a/tests/qemu-iotests/218
+++ b/tests/qemu-iotests/218
diff --git a/tests/qemu-iotests/common.qemu b/tests/qemu-iotests/common.qemu
index f285484951..dadde2a266 100644
--- a/tests/qemu-iotests/common.qemu
+++ b/tests/qemu-iotests/common.qemu
@@ -257,7 +257,7 @@ function _launch_qemu()
}
-# Silenty kills the QEMU process
+# Silently kills the QEMU process
#
# If $wait is set to anything other than the empty string, the process will not
# be killed but only waited for, and any output will be forwarded to stdout. If
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index 44bee16a5e..70ca65b49b 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -170,7 +170,7 @@ if [ ! -e "$TEST_DIR" ]; then
fi
if [ ! -d "$TEST_DIR" ]; then
- echo "common.config: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
+ echo "common.rc: Error: \$TEST_DIR ($TEST_DIR) is not a directory"
exit 1
fi
@@ -179,7 +179,7 @@ if [ -z "$REMOTE_TEST_DIR" ]; then
fi
if [ ! -d "$SAMPLE_IMG_DIR" ]; then
- echo "common.config: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a directory"
+ echo "common.rc: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a directory"
exit 1
fi
diff --git a/tests/tcg/Makefile.include b/tests/tcg/Makefile.include
index 57470b2a2c..c581bd6ffc 100644
--- a/tests/tcg/Makefile.include
+++ b/tests/tcg/Makefile.include
@@ -2,7 +2,7 @@
#
# TCG tests (per-target rules)
#
-# This Makefile fragement is included from the per-target
+# This Makefile fragment is included from the per-target
# Makefile.target so will be invoked for each linux-user program we
# build. We have two options for compiling, either using a configured
# guest compiler or calling one of our docker images to do it for us.
diff --git a/tests/tcg/Makefile.probe b/tests/tcg/Makefile.probe
index 15c0412657..9dc654663d 100644
--- a/tests/tcg/Makefile.probe
+++ b/tests/tcg/Makefile.probe
@@ -2,7 +2,7 @@
#
# TCG Compiler Probe
#
-# This Makefile fragement is included multiple times in the main make
+# This Makefile fragment is included multiple times in the main make
# script to probe for available compilers. This is used to build up a
# selection of required docker targets before we invoke a sub-make for
# each target.
diff --git a/tests/tcg/README b/tests/tcg/README
index a5643d33e7..2a58f9a058 100644
--- a/tests/tcg/README
+++ b/tests/tcg/README
@@ -10,6 +10,6 @@ with "make test-cris".
LM32
====
-The testsuite for LM32 is in tests/tcg/cris. You can run it
+The testsuite for LM32 is in tests/tcg/lm32. You can run it
with "make test-lm32".
diff --git a/tests/tcg/mips/mips64-dsp/subq_s_pw.c b/tests/tcg/mips/mips64-dsp/subq_s_pw.c
index e8e0b0567e..4c080b785a 100644
--- a/tests/tcg/mips/mips64-dsp/subq_s_pw.c
+++ b/tests/tcg/mips/mips64-dsp/subq_s_pw.c
@@ -24,7 +24,7 @@ int main(void)
rt = 0x123456789ABCDEF1;
rs = 0x123456789ABCDEF2;
result = 0x0000000000000001;
- /* This time we do not set dspctrl, but it setted in pre-action. */
+ /* This time we do not set dspctrl, but set it in pre-action. */
dspresult = 0x1;
__asm
diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index cafbc6b3a5..5caf77d6b8 100755
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -18,7 +18,7 @@ import logging
import time
import datetime
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "scripts"))
-from qemu import QEMUMachine
+from qemu import QEMUMachine, kvm_available
import subprocess
import hashlib
import optparse
@@ -42,6 +42,8 @@ class BaseVM(object):
BUILD_SCRIPT = ""
# The guest name, to be overridden by subclasses
name = "#base"
+ # The guest architecture, to be overridden by subclasses
+ arch = "#arch"
def __init__(self, debug=False, vcpus=None):
self._guest = None
self._tmpdir = os.path.realpath(tempfile.mkdtemp(prefix="vm-test-",
@@ -70,9 +72,9 @@ class BaseVM(object):
"-device", "virtio-net-pci,netdev=vnet",
"-vnc", "127.0.0.1:0,to=20",
"-serial", "file:%s" % os.path.join(self._tmpdir, "serial.out")]
- if vcpus:
+ if vcpus and vcpus > 1:
self._args += ["-smp", str(vcpus)]
- if os.access("/dev/kvm", os.R_OK | os.W_OK):
+ if kvm_available(self.arch):
self._args += ["-enable-kvm"]
else:
logging.info("KVM not available, not using -enable-kvm")
@@ -151,7 +153,7 @@ class BaseVM(object):
"-device", "virtio-blk,drive=drive0,bootindex=0"]
args += self._data_args + extra_args
logging.debug("QEMU args: %s", " ".join(args))
- qemu_bin = os.environ.get("QEMU", "qemu-system-x86_64")
+ qemu_bin = os.environ.get("QEMU", "qemu-system-" + self.arch)
guest = QEMUMachine(binary=qemu_bin, args=args)
try:
guest.launch()
@@ -177,11 +179,14 @@ class BaseVM(object):
def wait_ssh(self, seconds=300):
starttime = datetime.datetime.now()
+ endtime = starttime + datetime.timedelta(seconds=seconds)
guest_up = False
- while (datetime.datetime.now() - starttime).total_seconds() < seconds:
+ while datetime.datetime.now() < endtime:
if self.ssh("exit 0") == 0:
guest_up = True
break
+ seconds = (endtime - datetime.datetime.now()).total_seconds()
+ logging.debug("%ds before timeout", seconds)
time.sleep(1)
if not guest_up:
raise Exception("Timeout while waiting for guest ssh")
@@ -195,7 +200,14 @@ class BaseVM(object):
def qmp(self, *args, **kwargs):
return self._guest.qmp(*args, **kwargs)
-def parse_args(vm_name):
+def parse_args(vmcls):
+
+ def get_default_jobs():
+ if kvm_available(vmcls.arch):
+ return multiprocessing.cpu_count() / 2
+ else:
+ return 1
+
parser = optparse.OptionParser(
description="VM test utility. Exit codes: "
"0 = success, "
@@ -204,11 +216,11 @@ def parse_args(vm_name):
"3 = test command failed")
parser.add_option("--debug", "-D", action="store_true",
help="enable debug output")
- parser.add_option("--image", "-i", default="%s.img" % vm_name,
+ parser.add_option("--image", "-i", default="%s.img" % vmcls.name,
help="image file name")
parser.add_option("--force", "-f", action="store_true",
help="force build image even if image exists")
- parser.add_option("--jobs", type=int, default=multiprocessing.cpu_count() / 2,
+ parser.add_option("--jobs", type=int, default=get_default_jobs(),
help="number of virtual CPUs")
parser.add_option("--verbose", "-V", action="store_true",
help="Pass V=1 to builds within the guest")
@@ -225,7 +237,7 @@ def parse_args(vm_name):
def main(vmcls):
try:
- args, argv = parse_args(vmcls.name)
+ args, argv = parse_args(vmcls)
if not argv and not args.build_qemu and not args.build_image:
print("Nothing to do?")
return 1
diff --git a/tests/vm/centos b/tests/vm/centos
index afd560c564..daa2dbca03 100755
--- a/tests/vm/centos
+++ b/tests/vm/centos
@@ -19,6 +19,7 @@ import time
class CentosVM(basevm.BaseVM):
name = "centos"
+ arch = "x86_64"
BUILD_SCRIPT = """
set -e;
cd $(mktemp -d);
diff --git a/tests/vm/freebsd b/tests/vm/freebsd
index b6983127d0..19a3729172 100755
--- a/tests/vm/freebsd
+++ b/tests/vm/freebsd
@@ -18,6 +18,7 @@ import basevm
class FreeBSDVM(basevm.BaseVM):
name = "freebsd"
+ arch = "x86_64"
BUILD_SCRIPT = """
set -e;
rm -rf /var/tmp/qemu-test.*
diff --git a/tests/vm/netbsd b/tests/vm/netbsd
index a4e25820d5..fac6a7ce51 100755
--- a/tests/vm/netbsd
+++ b/tests/vm/netbsd
@@ -18,6 +18,7 @@ import basevm
class NetBSDVM(basevm.BaseVM):
name = "netbsd"
+ arch = "x86_64"
BUILD_SCRIPT = """
set -e;
rm -rf /var/tmp/qemu-test.*
diff --git a/tests/vm/openbsd b/tests/vm/openbsd
index 52500ee52b..cfe0572c59 100755
--- a/tests/vm/openbsd
+++ b/tests/vm/openbsd
@@ -18,6 +18,7 @@ import basevm
class OpenBSDVM(basevm.BaseVM):
name = "openbsd"
+ arch = "x86_64"
BUILD_SCRIPT = """
set -e;
rm -rf /var/tmp/qemu-test.*
diff --git a/tests/vm/ubuntu.i386 b/tests/vm/ubuntu.i386
index 3f6ed48b74..1b7e1ab8f0 100755
--- a/tests/vm/ubuntu.i386
+++ b/tests/vm/ubuntu.i386
@@ -19,6 +19,7 @@ import time
class UbuntuX86VM(basevm.BaseVM):
name = "ubuntu.i386"
+ arch = "i386"
BUILD_SCRIPT = """
set -e;
cd $(mktemp -d);