diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.include | 8 | ||||
-rw-r--r-- | tests/boot-serial-test.c | 1 | ||||
-rw-r--r-- | tests/docker/dockerfiles/fedora.docker | 3 | ||||
-rw-r--r-- | tests/migration-test.c | 144 | ||||
-rw-r--r-- | tests/qapi-schema/test-qapi.py | 43 |
5 files changed, 120 insertions, 79 deletions
diff --git a/tests/Makefile.include b/tests/Makefile.include index ca82e0c..f41da23 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -299,6 +299,8 @@ gcov-files-x86_64-y = $(subst i386-softmmu/,x86_64-softmmu/,$(gcov-files-i386-y) check-qtest-alpha-y = tests/boot-serial-test$(EXESUF) +check-qtest-hppa-y = tests/boot-serial-test$(EXESUF) + check-qtest-m68k-y = tests/boot-serial-test$(EXESUF) check-qtest-microblaze-y = tests/boot-serial-test$(EXESUF) @@ -917,10 +919,10 @@ $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json $^ >$*.test.out 2>$*.test.err; \ echo $$? >$*.test.exit, \ "TEST","$*.out") - @diff -q $(SRC_PATH)/$*.out $*.test.out + @diff $(SRC_PATH)/$*.out $*.test.out @# Sanitize error messages (make them independent of build directory) - @perl -p -e 's|\Q$(SRC_PATH)\E/||g' $*.test.err | diff -q $(SRC_PATH)/$*.err - - @diff -q $(SRC_PATH)/$*.exit $*.test.exit + @perl -p -e 's|\Q$(SRC_PATH)\E/||g' $*.test.err | diff $(SRC_PATH)/$*.err - + @diff $(SRC_PATH)/$*.exit $*.test.exit .PHONY: check-tests/qapi-schema/doc-good.texi check-tests/qapi-schema/doc-good.texi: tests/qapi-schema/doc-good.test.texi diff --git a/tests/boot-serial-test.c b/tests/boot-serial-test.c index 418c5b9..ea87a80 100644 --- a/tests/boot-serial-test.c +++ b/tests/boot-serial-test.c @@ -87,6 +87,7 @@ static testdef_t tests[] = { sizeof(kernel_plml605), kernel_plml605 }, { "moxie", "moxiesim", "", "TT", sizeof(bios_moxiesim), 0, bios_moxiesim }, { "arm", "raspi2", "", "TT", sizeof(bios_raspi2), 0, bios_raspi2 }, + { "hppa", "hppa", "", "SeaBIOS wants SYSTEM HALT" }, { NULL } }; diff --git a/tests/docker/dockerfiles/fedora.docker b/tests/docker/dockerfiles/fedora.docker index 32de731..26ede4f 100644 --- a/tests/docker/dockerfiles/fedora.docker +++ b/tests/docker/dockerfiles/fedora.docker @@ -1,6 +1,6 @@ FROM fedora:latest ENV PACKAGES \ - ccache gettext git tar PyYAML sparse flex bison python2 bzip2 hostname \ + ccache gettext git tar PyYAML sparse flex bison python3 bzip2 hostname \ glib2-devel pixman-devel zlib-devel SDL-devel libfdt-devel \ gcc gcc-c++ clang make perl which bc findutils libaio-devel \ nettle-devel libasan libubsan \ @@ -12,6 +12,7 @@ ENV PACKAGES \ mingw64-gtk2 mingw64-gtk3 mingw64-gnutls mingw64-nettle mingw64-libtasn1 \ mingw64-libjpeg-turbo mingw64-libpng mingw64-curl mingw64-libssh2 \ mingw64-bzip2 +ENV QEMU_CONFIGURE_OPTS --python=/usr/bin/python3 RUN dnf install -y $PACKAGES RUN rpm -q $PACKAGES | sort > /packages.txt diff --git a/tests/migration-test.c b/tests/migration-test.c index 799e24e..9efad95 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -268,10 +268,9 @@ static uint64_t get_migration_pass(QTestState *who) static void wait_for_migration_complete(QTestState *who) { - QDict *rsp, *rsp_return; - bool completed; - - do { + while (true) { + QDict *rsp, *rsp_return; + bool completed; const char *status; rsp = wait_command(who, "{ 'execute': 'query-migrate' }"); @@ -280,8 +279,11 @@ static void wait_for_migration_complete(QTestState *who) completed = strcmp(status, "completed") == 0; g_assert_cmpstr(status, !=, "failed"); QDECREF(rsp); - usleep(1000 * 100); - } while (!completed); + if (completed) { + return; + } + usleep(1000); + } } static void wait_for_migration_pass(QTestState *who) @@ -290,16 +292,13 @@ static void wait_for_migration_pass(QTestState *who) uint64_t pass; /* Wait for the 1st sync */ - do { + while (!got_stop && !initial_pass) { + usleep(1000); initial_pass = get_migration_pass(who); - if (got_stop || initial_pass) { - break; - } - usleep(1000 * 100); - } while (true); + } do { - usleep(1000 * 100); + usleep(1000); pass = get_migration_pass(who); } while (pass == initial_pass && !got_stop); } @@ -369,37 +368,20 @@ static void migrate_check_parameter(QTestState *who, const char *parameter, QDECREF(rsp); } -static void migrate_set_downtime(QTestState *who, const double value) +static void migrate_set_parameter(QTestState *who, const char *parameter, + const char *value) { QDict *rsp; gchar *cmd; - char *expected; - int64_t result_int; - cmd = g_strdup_printf("{ 'execute': 'migrate_set_downtime'," - "'arguments': { 'value': %g } }", value); + cmd = g_strdup_printf("{ 'execute': 'migrate-set-parameters'," + "'arguments': { '%s': %s } }", + parameter, value); rsp = qtest_qmp(who, cmd); g_free(cmd); g_assert(qdict_haskey(rsp, "return")); QDECREF(rsp); - result_int = value * 1000L; - expected = g_strdup_printf("%" PRId64, result_int); - migrate_check_parameter(who, "downtime-limit", expected); - g_free(expected); -} - -static void migrate_set_speed(QTestState *who, const char *value) -{ - QDict *rsp; - gchar *cmd; - - cmd = g_strdup_printf("{ 'execute': 'migrate_set_speed'," - "'arguments': { 'value': %s } }", value); - rsp = qtest_qmp(who, cmd); - g_free(cmd); - g_assert(qdict_haskey(rsp, "return")); - QDECREF(rsp); - migrate_check_parameter(who, "max-bandwidth", value); + migrate_check_parameter(who, parameter, value); } static void migrate_set_capability(QTestState *who, const char *capability, @@ -433,41 +415,52 @@ static void migrate(QTestState *who, const char *uri) QDECREF(rsp); } +static void migrate_start_postcopy(QTestState *who) +{ + QDict *rsp; + + rsp = wait_command(who, "{ 'execute': 'migrate-start-postcopy' }"); + g_assert(qdict_haskey(rsp, "return")); + QDECREF(rsp); +} + static void test_migrate_start(QTestState **from, QTestState **to, const char *uri) { gchar *cmd_src, *cmd_dst; char *bootpath = g_strdup_printf("%s/bootsect", tmpfs); const char *arch = qtest_get_arch(); + const char *accel = "kvm:tcg"; got_stop = false; if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { init_bootfile_x86(bootpath); - cmd_src = g_strdup_printf("-machine accel=kvm:tcg -m 150M" - " -name pcsource,debug-threads=on" + cmd_src = g_strdup_printf("-machine accel=%s -m 150M" + " -name source,debug-threads=on" " -serial file:%s/src_serial" " -drive file=%s,format=raw", - tmpfs, bootpath); - cmd_dst = g_strdup_printf("-machine accel=kvm:tcg -m 150M" - " -name pcdest,debug-threads=on" + accel, tmpfs, bootpath); + cmd_dst = g_strdup_printf("-machine accel=%s -m 150M" + " -name target,debug-threads=on" " -serial file:%s/dest_serial" " -drive file=%s,format=raw" " -incoming %s", - tmpfs, bootpath, uri); + accel, tmpfs, bootpath, uri); } else if (strcmp(arch, "ppc64") == 0) { - const char *accel; /* On ppc64, the test only works with kvm-hv, but not with kvm-pr */ - accel = access("/sys/module/kvm_hv", F_OK) ? "tcg" : "kvm:tcg"; + if (access("/sys/module/kvm_hv", F_OK)) { + accel = "tcg"; + } init_bootfile_ppc(bootpath); cmd_src = g_strdup_printf("-machine accel=%s -m 256M" - " -name pcsource,debug-threads=on" + " -name source,debug-threads=on" " -serial file:%s/src_serial" " -drive file=%s,if=pflash,format=raw", accel, tmpfs, bootpath); cmd_dst = g_strdup_printf("-machine accel=%s -m 256M" - " -name pcdest,debug-threads=on" + " -name target,debug-threads=on" " -serial file:%s/dest_serial" " -incoming %s", accel, tmpfs, uri); @@ -495,13 +488,13 @@ static void test_migrate_end(QTestState *from, QTestState *to) /* Destination still running, wait for a byte to change */ do { qtest_memread(to, start_address, &dest_byte_b, 1); - usleep(10 * 1000); + usleep(1000 * 10); } while (dest_byte_a == dest_byte_b); qtest_qmp_discard_response(to, "{ 'execute' : 'stop'}"); /* With it stopped, check nothing changes */ qtest_memread(to, start_address, &dest_byte_c, 1); - sleep(1); + usleep(1000 * 200); qtest_memread(to, start_address, &dest_byte_d, 1); g_assert_cmpint(dest_byte_c, ==, dest_byte_d); @@ -515,11 +508,55 @@ static void test_migrate_end(QTestState *from, QTestState *to) cleanup("dest_serial"); } +static void deprecated_set_downtime(QTestState *who, const double value) +{ + QDict *rsp; + gchar *cmd; + char *expected; + int64_t result_int; + + cmd = g_strdup_printf("{ 'execute': 'migrate_set_downtime'," + "'arguments': { 'value': %g } }", value); + rsp = qtest_qmp(who, cmd); + g_free(cmd); + g_assert(qdict_haskey(rsp, "return")); + QDECREF(rsp); + result_int = value * 1000L; + expected = g_strdup_printf("%" PRId64, result_int); + migrate_check_parameter(who, "downtime-limit", expected); + g_free(expected); +} + +static void deprecated_set_speed(QTestState *who, const char *value) +{ + QDict *rsp; + gchar *cmd; + + cmd = g_strdup_printf("{ 'execute': 'migrate_set_speed'," + "'arguments': { 'value': %s } }", value); + rsp = qtest_qmp(who, cmd); + g_free(cmd); + g_assert(qdict_haskey(rsp, "return")); + QDECREF(rsp); + migrate_check_parameter(who, "max-bandwidth", value); +} + +static void test_deprecated(void) +{ + QTestState *from; + + from = qtest_start(""); + + deprecated_set_downtime(from, 0.12345); + deprecated_set_speed(from, "12345"); + + qtest_quit(from); +} + static void test_migrate(void) { char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; - QDict *rsp; test_migrate_start(&from, &to, uri); @@ -530,8 +567,8 @@ static void test_migrate(void) * quickly, but that it doesn't complete precopy even on a slow * machine, so also set the downtime. */ - migrate_set_speed(from, "100000000"); - migrate_set_downtime(from, 0.001); + migrate_set_parameter(from, "max-bandwidth", "100000000"); + migrate_set_parameter(from, "downtime-limit", "1"); /* Wait for the first serial output from the source */ wait_for_serial("src_serial"); @@ -540,9 +577,7 @@ static void test_migrate(void) wait_for_migration_pass(from); - rsp = wait_command(from, "{ 'execute': 'migrate-start-postcopy' }"); - g_assert(qdict_haskey(rsp, "return")); - QDECREF(rsp); + migrate_start_postcopy(from); if (!got_stop) { qtest_qmp_eventwait(from, "STOP"); @@ -578,6 +613,7 @@ int main(int argc, char **argv) module_call_init(MODULE_INIT_QOM); qtest_add_func("/migration/postcopy/unix", test_migrate); + qtest_add_func("/migration/deprecated", test_deprecated); ret = g_test_run(); diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py index fe0ca08..ac43d34 100644 --- a/tests/qapi-schema/test-qapi.py +++ b/tests/qapi-schema/test-qapi.py @@ -10,6 +10,7 @@ # See the COPYING file in the top-level directory. # +from __future__ import print_function from qapi import * from pprint import pprint import os @@ -18,51 +19,51 @@ import sys class QAPISchemaTestVisitor(QAPISchemaVisitor): def visit_enum_type(self, name, info, values, prefix): - print 'enum %s %s' % (name, values) + print('enum %s %s' % (name, values)) if prefix: - print ' prefix %s' % prefix + print(' prefix %s' % prefix) def visit_object_type(self, name, info, base, members, variants): - print 'object %s' % name + print('object %s' % name) if base: - print ' base %s' % base.name + print(' base %s' % base.name) for m in members: - print ' member %s: %s optional=%s' % \ - (m.name, m.type.name, m.optional) + print(' member %s: %s optional=%s' % \ + (m.name, m.type.name, m.optional)) self._print_variants(variants) def visit_alternate_type(self, name, info, variants): - print 'alternate %s' % name + print('alternate %s' % name) self._print_variants(variants) def visit_command(self, name, info, arg_type, ret_type, gen, success_response, boxed): - print 'command %s %s -> %s' % \ - (name, arg_type and arg_type.name, ret_type and ret_type.name) - print ' gen=%s success_response=%s boxed=%s' % \ - (gen, success_response, boxed) + print('command %s %s -> %s' % \ + (name, arg_type and arg_type.name, ret_type and ret_type.name)) + print(' gen=%s success_response=%s boxed=%s' % \ + (gen, success_response, boxed)) def visit_event(self, name, info, arg_type, boxed): - print 'event %s %s' % (name, arg_type and arg_type.name) - print ' boxed=%s' % boxed + print('event %s %s' % (name, arg_type and arg_type.name)) + print(' boxed=%s' % boxed) @staticmethod def _print_variants(variants): if variants: - print ' tag %s' % variants.tag_member.name + print(' tag %s' % variants.tag_member.name) for v in variants.variants: - print ' case %s: %s' % (v.name, v.type.name) + print(' case %s: %s' % (v.name, v.type.name)) schema = QAPISchema(sys.argv[1]) schema.visit(QAPISchemaTestVisitor()) for doc in schema.docs: if doc.symbol: - print 'doc symbol=%s' % doc.symbol + print('doc symbol=%s' % doc.symbol) else: - print 'doc freeform' - print ' body=\n%s' % doc.body.text - for arg, section in doc.args.iteritems(): - print ' arg=%s\n%s' % (arg, section.text) + print('doc freeform') + print(' body=\n%s' % doc.body.text) + for arg, section in doc.args.items(): + print(' arg=%s\n%s' % (arg, section.text)) for section in doc.sections: - print ' section=%s\n%s' % (section.name, section.text) + print(' section=%s\n%s' % (section.name, section.text)) |