aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-01-23 10:15:09 +0000
committerPeter Maydell <peter.maydell@linaro.org>2018-01-23 10:15:09 +0000
commit52483b067cce4a88ffbf8fbeea26de7549d2ad23 (patch)
treec8f9427d96d10d0c123866ce2e2ea943660e9a1d /tests
parentee86981bda9ecd40c8daf81b7307b1d2aff68174 (diff)
parent1081ed2c4b71b5fe8bd31f6de8cdaa630c8acfd3 (diff)
Merge remote-tracking branch 'remotes/huth/tags/pull-request-2018-01-22' into staging
Pull request for various patches that have been reviewed and laying on the mailing list for a while, but apparently no maintainer feels really responsible for picking up. # gpg: Signature made Mon 22 Jan 2018 11:10:16 GMT # gpg: using RSA key 0x2ED9D774FE702DB5 # gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" # gpg: aka "Thomas Huth <thuth@redhat.com>" # gpg: aka "Thomas Huth <huth@tuxfamily.org>" # gpg: aka "Thomas Huth <th.huth@posteo.de>" # Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5 * remotes/huth/tags/pull-request-2018-01-22: hw/isa: Replace fprintf(stderr, "*\n" with error_report() hw/ipmi: Replace fprintf(stderr, "*\n" with error_report() hw/bt: Replace fprintf(stderr, "*\n" with error_report() Fixes after renaming __FUNCTION__ to __func__ Replace all occurances of __FUNCTION__ with __func__ tests/cpu-plug-test: Test CPU hot-plugging on s390x tests/cpu-plug-test: Check CPU hot-plugging on ppc64, too tests/cpu-plug-test: Check the CPU hot-plugging with device_add, too tests: Rename pc-cpu-test.c to cpu-plug-test.c Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.include6
-rw-r--r--tests/cpu-plug-test.c267
-rw-r--r--tests/pc-cpu-test.c135
3 files changed, 271 insertions, 137 deletions
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 8883274ae1..851aafe9d1 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -278,7 +278,7 @@ gcov-files-i386-y += hw/usb/dev-hid.c
gcov-files-i386-y += hw/usb/dev-storage.c
check-qtest-i386-y += tests/usb-hcd-xhci-test$(EXESUF)
gcov-files-i386-y += hw/usb/hcd-xhci.c
-check-qtest-i386-y += tests/pc-cpu-test$(EXESUF)
+check-qtest-i386-y += tests/cpu-plug-test$(EXESUF)
check-qtest-i386-y += tests/q35-test$(EXESUF)
check-qtest-i386-y += tests/vmgenid-test$(EXESUF)
gcov-files-i386-y += hw/pci-host/q35.c
@@ -340,6 +340,7 @@ check-qtest-ppc64-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
check-qtest-ppc64-y += tests/display-vga-test$(EXESUF)
check-qtest-ppc64-y += tests/numa-test$(EXESUF)
check-qtest-ppc64-$(CONFIG_IVSHMEM) += tests/ivshmem-test$(EXESUF)
+check-qtest-ppc64-y += tests/cpu-plug-test$(EXESUF)
check-qtest-sh4-y = tests/endianness-test$(EXESUF)
@@ -379,6 +380,7 @@ check-qtest-s390x-y += tests/drive_del-test$(EXESUF)
check-qtest-s390x-y += tests/virtio-balloon-test$(EXESUF)
check-qtest-s390x-y += tests/virtio-console-test$(EXESUF)
check-qtest-s390x-y += tests/virtio-serial-test$(EXESUF)
+check-qtest-s390x-y += tests/cpu-plug-test$(EXESUF)
check-qtest-generic-y += tests/qom-test$(EXESUF)
check-qtest-generic-y += tests/test-hmp$(EXESUF)
@@ -795,7 +797,7 @@ tests/usb-hcd-ohci-test$(EXESUF): tests/usb-hcd-ohci-test.o $(libqos-usb-obj-y)
tests/usb-hcd-uhci-test$(EXESUF): tests/usb-hcd-uhci-test.o $(libqos-usb-obj-y)
tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-usb-obj-y)
tests/usb-hcd-xhci-test$(EXESUF): tests/usb-hcd-xhci-test.o $(libqos-usb-obj-y)
-tests/pc-cpu-test$(EXESUF): tests/pc-cpu-test.o
+tests/cpu-plug-test$(EXESUF): tests/cpu-plug-test.o
tests/migration-test$(EXESUF): tests/migration-test.o
tests/vhost-user-test$(EXESUF): tests/vhost-user-test.o $(test-util-obj-y) \
$(qtest-obj-y) $(test-io-obj-y) $(libqos-virtio-obj-y) $(libqos-pc-obj-y) \
diff --git a/tests/cpu-plug-test.c b/tests/cpu-plug-test.c
new file mode 100644
index 0000000000..05d82f76c4
--- /dev/null
+++ b/tests/cpu-plug-test.c
@@ -0,0 +1,267 @@
+/*
+ * QTest testcase for CPU plugging
+ *
+ * Copyright (c) 2015 SUSE Linux GmbH
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+
+#include "qemu-common.h"
+#include "libqtest.h"
+#include "qapi/qmp/types.h"
+
+struct PlugTestData {
+ char *machine;
+ const char *cpu_model;
+ char *device_model;
+ unsigned sockets;
+ unsigned cores;
+ unsigned threads;
+ unsigned maxcpus;
+};
+typedef struct PlugTestData PlugTestData;
+
+static void test_plug_with_cpu_add(gconstpointer data)
+{
+ const PlugTestData *s = data;
+ char *args;
+ QDict *response;
+ unsigned int i;
+
+ args = g_strdup_printf("-machine %s -cpu %s "
+ "-smp 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++) {
+ response = qmp("{ 'execute': 'cpu-add',"
+ " 'arguments': { 'id': %d } }", i);
+ g_assert(response);
+ g_assert(!qdict_haskey(response, "error"));
+ QDECREF(response);
+ }
+
+ qtest_end();
+ g_free(args);
+}
+
+static void test_plug_without_cpu_add(gconstpointer data)
+{
+ const PlugTestData *s = data;
+ char *args;
+ QDict *response;
+
+ args = g_strdup_printf("-machine %s -cpu %s "
+ "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
+ s->machine, s->cpu_model,
+ s->sockets, s->cores, s->threads, s->maxcpus);
+ qtest_start(args);
+
+ response = qmp("{ 'execute': 'cpu-add',"
+ " 'arguments': { 'id': %d } }",
+ s->sockets * s->cores * s->threads);
+ g_assert(response);
+ g_assert(qdict_haskey(response, "error"));
+ QDECREF(response);
+
+ qtest_end();
+ g_free(args);
+}
+
+static void test_plug_with_device_add_x86(gconstpointer data)
+{
+ const PlugTestData *td = data;
+ char *args;
+ unsigned int s, c, t;
+
+ args = g_strdup_printf("-machine %s -cpu %s "
+ "-smp 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 (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);
+ qtest_qmp_device_add(td->device_model, id, "'socket-id':'%i', "
+ "'core-id':'%i', 'thread-id':'%i'",
+ s, c, t);
+ g_free(id);
+ }
+ }
+ }
+
+ qtest_end();
+ g_free(args);
+}
+
+static void test_plug_with_device_add_coreid(gconstpointer data)
+{
+ const PlugTestData *td = data;
+ char *args;
+ unsigned int c;
+
+ args = g_strdup_printf("-machine %s -cpu %s "
+ "-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 (c = td->cores; c < td->maxcpus / td->sockets / td->threads; c++) {
+ char *id = g_strdup_printf("id-%i", c);
+ qtest_qmp_device_add(td->device_model, id, "'core-id':'%i'", c);
+ g_free(id);
+ }
+
+ qtest_end();
+ g_free(args);
+}
+
+static void test_data_free(gpointer data)
+{
+ PlugTestData *pc = data;
+
+ g_free(pc->machine);
+ g_free(pc->device_model);
+ g_free(pc);
+}
+
+static void add_pc_test_case(const char *mname)
+{
+ char *path;
+ PlugTestData *data;
+
+ if (!g_str_has_prefix(mname, "pc-")) {
+ return;
+ }
+ data = g_new(PlugTestData, 1);
+ data->machine = g_strdup(mname);
+ data->cpu_model = "Haswell"; /* 1.3+ theoretically */
+ data->device_model = g_strdup_printf("%s-%s-cpu", data->cpu_model,
+ qtest_get_arch());
+ data->sockets = 1;
+ data->cores = 3;
+ data->threads = 2;
+ data->maxcpus = data->sockets * data->cores * data->threads * 2;
+ if (g_str_has_suffix(mname, "-1.4") ||
+ (strcmp(mname, "pc-1.3") == 0) ||
+ (strcmp(mname, "pc-1.2") == 0) ||
+ (strcmp(mname, "pc-1.1") == 0) ||
+ (strcmp(mname, "pc-1.0") == 0) ||
+ (strcmp(mname, "pc-0.15") == 0) ||
+ (strcmp(mname, "pc-0.14") == 0) ||
+ (strcmp(mname, "pc-0.13") == 0) ||
+ (strcmp(mname, "pc-0.12") == 0) ||
+ (strcmp(mname, "pc-0.11") == 0) ||
+ (strcmp(mname, "pc-0.10") == 0)) {
+ path = g_strdup_printf("cpu-plug/%s/init/%ux%ux%u&maxcpus=%u",
+ mname, data->sockets, data->cores,
+ data->threads, data->maxcpus);
+ qtest_add_data_func_full(path, data, test_plug_without_cpu_add,
+ test_data_free);
+ g_free(path);
+ } else {
+ PlugTestData *data2 = g_memdup(data, sizeof(PlugTestData));
+
+ data2->machine = g_strdup(data->machine);
+ data2->device_model = g_strdup(data->device_model);
+
+ path = g_strdup_printf("cpu-plug/%s/cpu-add/%ux%ux%u&maxcpus=%u",
+ mname, data->sockets, data->cores,
+ data->threads, data->maxcpus);
+ qtest_add_data_func_full(path, data, test_plug_with_cpu_add,
+ test_data_free);
+ g_free(path);
+ path = g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus=%u",
+ mname, data2->sockets, data2->cores,
+ data2->threads, data2->maxcpus);
+ qtest_add_data_func_full(path, data2, test_plug_with_device_add_x86,
+ test_data_free);
+ g_free(path);
+ }
+}
+
+static void add_pseries_test_case(const char *mname)
+{
+ char *path;
+ PlugTestData *data;
+
+ if (!g_str_has_prefix(mname, "pseries-") ||
+ (g_str_has_prefix(mname, "pseries-2.") && atoi(&mname[10]) < 7)) {
+ return;
+ }
+ data = g_new(PlugTestData, 1);
+ data->machine = g_strdup(mname);
+ data->cpu_model = "power8_v2.0";
+ data->device_model = g_strdup("power8_v2.0-spapr-cpu-core");
+ data->sockets = 2;
+ data->cores = 3;
+ data->threads = 1;
+ data->maxcpus = data->sockets * data->cores * data->threads * 2;
+
+ path = g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus=%u",
+ mname, data->sockets, data->cores,
+ data->threads, data->maxcpus);
+ qtest_add_data_func_full(path, data, test_plug_with_device_add_coreid,
+ test_data_free);
+ g_free(path);
+}
+
+static void add_s390x_test_case(const char *mname)
+{
+ char *path;
+ PlugTestData *data, *data2;
+
+ if (!g_str_has_prefix(mname, "s390-ccw-virtio-")) {
+ return;
+ }
+
+ data = g_new(PlugTestData, 1);
+ data->machine = g_strdup(mname);
+ data->cpu_model = "qemu";
+ data->device_model = g_strdup("qemu-s390x-cpu");
+ data->sockets = 1;
+ data->cores = 3;
+ data->threads = 1;
+ data->maxcpus = data->sockets * data->cores * data->threads * 2;
+
+ data2 = g_memdup(data, sizeof(PlugTestData));
+ data2->machine = g_strdup(data->machine);
+ data2->device_model = g_strdup(data->device_model);
+
+ path = g_strdup_printf("cpu-plug/%s/cpu-add/%ux%ux%u&maxcpus=%u",
+ mname, data->sockets, data->cores,
+ data->threads, data->maxcpus);
+ qtest_add_data_func_full(path, data, test_plug_with_cpu_add,
+ test_data_free);
+ g_free(path);
+
+ path = g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus=%u",
+ mname, data2->sockets, data2->cores,
+ data2->threads, data2->maxcpus);
+ qtest_add_data_func_full(path, data2, test_plug_with_device_add_coreid,
+ test_data_free);
+ g_free(path);
+}
+
+int main(int argc, char **argv)
+{
+ const char *arch = qtest_get_arch();
+
+ g_test_init(&argc, &argv, NULL);
+
+ if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+ qtest_cb_for_every_machine(add_pc_test_case);
+ } else if (g_str_equal(arch, "ppc64")) {
+ qtest_cb_for_every_machine(add_pseries_test_case);
+ } else if (g_str_equal(arch, "s390x")) {
+ qtest_cb_for_every_machine(add_s390x_test_case);
+ }
+
+ return g_test_run();
+}
diff --git a/tests/pc-cpu-test.c b/tests/pc-cpu-test.c
deleted file mode 100644
index 11d3e810ef..0000000000
--- a/tests/pc-cpu-test.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * QTest testcase for PC CPUs
- *
- * Copyright (c) 2015 SUSE Linux GmbH
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#include "qemu/osdep.h"
-
-#include "qemu-common.h"
-#include "libqtest.h"
-#include "qapi/qmp/types.h"
-
-struct PCTestData {
- char *machine;
- const char *cpu_model;
- unsigned sockets;
- unsigned cores;
- unsigned threads;
- unsigned maxcpus;
-};
-typedef struct PCTestData PCTestData;
-
-static void test_pc_with_cpu_add(gconstpointer data)
-{
- const PCTestData *s = data;
- char *args;
- QDict *response;
- unsigned int i;
-
- args = g_strdup_printf("-machine %s -cpu %s "
- "-smp 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++) {
- response = qmp("{ 'execute': 'cpu-add',"
- " 'arguments': { 'id': %d } }", i);
- g_assert(response);
- g_assert(!qdict_haskey(response, "error"));
- QDECREF(response);
- }
-
- qtest_end();
- g_free(args);
-}
-
-static void test_pc_without_cpu_add(gconstpointer data)
-{
- const PCTestData *s = data;
- char *args;
- QDict *response;
-
- args = g_strdup_printf("-machine %s -cpu %s "
- "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u",
- s->machine, s->cpu_model,
- s->sockets, s->cores, s->threads, s->maxcpus);
- qtest_start(args);
-
- response = qmp("{ 'execute': 'cpu-add',"
- " 'arguments': { 'id': %d } }",
- s->sockets * s->cores * s->threads);
- g_assert(response);
- g_assert(qdict_haskey(response, "error"));
- QDECREF(response);
-
- qtest_end();
- g_free(args);
-}
-
-static void test_data_free(gpointer data)
-{
- PCTestData *pc = data;
-
- g_free(pc->machine);
- g_free(pc);
-}
-
-static void add_pc_test_case(const char *mname)
-{
- char *path;
- PCTestData *data;
-
- if (!g_str_has_prefix(mname, "pc-")) {
- return;
- }
- data = g_new(PCTestData, 1);
- data->machine = g_strdup(mname);
- data->cpu_model = "Haswell"; /* 1.3+ theoretically */
- data->sockets = 1;
- data->cores = 3;
- data->threads = 2;
- data->maxcpus = data->sockets * data->cores * data->threads * 2;
- if (g_str_has_suffix(mname, "-1.4") ||
- (strcmp(mname, "pc-1.3") == 0) ||
- (strcmp(mname, "pc-1.2") == 0) ||
- (strcmp(mname, "pc-1.1") == 0) ||
- (strcmp(mname, "pc-1.0") == 0) ||
- (strcmp(mname, "pc-0.15") == 0) ||
- (strcmp(mname, "pc-0.14") == 0) ||
- (strcmp(mname, "pc-0.13") == 0) ||
- (strcmp(mname, "pc-0.12") == 0) ||
- (strcmp(mname, "pc-0.11") == 0) ||
- (strcmp(mname, "pc-0.10") == 0)) {
- path = g_strdup_printf("cpu/%s/init/%ux%ux%u&maxcpus=%u",
- mname, data->sockets, data->cores,
- data->threads, data->maxcpus);
- qtest_add_data_func_full(path, data, test_pc_without_cpu_add,
- test_data_free);
- g_free(path);
- } else {
- path = g_strdup_printf("cpu/%s/add/%ux%ux%u&maxcpus=%u",
- mname, data->sockets, data->cores,
- data->threads, data->maxcpus);
- qtest_add_data_func_full(path, data, test_pc_with_cpu_add,
- test_data_free);
- g_free(path);
- }
-}
-
-int main(int argc, char **argv)
-{
- const char *arch = qtest_get_arch();
-
- g_test_init(&argc, &argv, NULL);
-
- if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
- qtest_cb_for_every_machine(add_pc_test_case);
- }
-
- return g_test_run();
-}