summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-07-18 14:46:53 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-07-18 14:46:53 +0100
commit50a2c45da92383138e0d3f22952f3813814e18b3 (patch)
treef9ec964cc6ccba53aa0c372a2ffd9f44d6811c66 /tests
parente0097ea371a647651f6c89c3091c4962fdde26fd (diff)
parentfa666c10f2f3e15685ff88abd3bc433ddce012d6 (diff)
downloadqemu-50a2c45da92383138e0d3f22952f3813814e18b3.tar.gz
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
Andreas's fixes to --enable-modules, two 2.1 regression fixes, and a new qtest. Michael sent a pull request of his own, so I dropped the vhost changes. # gpg: Signature made Fri 18 Jul 2014 14:30:34 BST using RSA key ID 9B4D86F2 # gpg: Can't check signature: public key not found * remotes/bonzini/tags/for-upstream: Revert "kvmclock: Ensure time in migration never goes backward" Revert "kvmclock: Ensure proper env->tsc value for kvmclock_current_nsec calculation" module: Don't complain when a module is absent module: Simplify module_load() qtest: new test for wdt_ib700 target-i386: Allow execute from user mode when SMEP is enabled. Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile3
-rw-r--r--tests/wdt_ib700-test.c134
2 files changed, 137 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile
index fa25c70712..4b2e1bbea9 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -141,6 +141,8 @@ check-qtest-i386-y += tests/i440fx-test$(EXESUF)
check-qtest-i386-y += tests/fw_cfg-test$(EXESUF)
check-qtest-i386-y += tests/blockdev-test$(EXESUF)
check-qtest-i386-y += tests/qdev-monitor-test$(EXESUF)
+check-qtest-i386-y += tests/wdt_ib700-test$(EXESUF)
+gcov-files-i386-y += hw/watchdog/watchdog.c hw/watchdog/wdt_ib700.c
check-qtest-i386-y += $(check-qtest-pci-y)
gcov-files-i386-y += $(gcov-files-pci-y)
check-qtest-i386-y += tests/vmxnet3-test$(EXESUF)
@@ -311,6 +313,7 @@ tests/pcnet-test$(EXESUF): tests/pcnet-test.o
tests/eepro100-test$(EXESUF): tests/eepro100-test.o
tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o
tests/ne2000-test$(EXESUF): tests/ne2000-test.o
+tests/wdt_ib700-test$(EXESUF): tests/wdt_ib700-test.o
tests/virtio-balloon-test$(EXESUF): tests/virtio-balloon-test.o
tests/virtio-blk-test$(EXESUF): tests/virtio-blk-test.o
tests/virtio-net-test$(EXESUF): tests/virtio-net-test.o
diff --git a/tests/wdt_ib700-test.c b/tests/wdt_ib700-test.c
new file mode 100644
index 0000000000..513a533852
--- /dev/null
+++ b/tests/wdt_ib700-test.c
@@ -0,0 +1,134 @@
+/*
+ * QTest testcase for the IB700 watchdog
+ *
+ * Copyright (c) 2014 Red Hat, Inc.
+ *
+ * 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 <glib.h>
+#include <string.h>
+#include "libqtest.h"
+#include "qemu/osdep.h"
+
+#define NS_PER_SEC 1000000000ULL
+
+static void qmp_check_no_event(void)
+{
+ QDict *resp = qmp("{'execute':'query-status'}");
+ g_assert(qdict_haskey(resp, "return"));
+ QDECREF(resp);
+}
+
+static QDict *qmp_get_event(const char *name)
+{
+ QDict *event = qmp("");
+ QDict *data;
+ g_assert(qdict_haskey(event, "event"));
+ g_assert(!strcmp(qdict_get_str(event, "event"), name));
+
+ if (qdict_haskey(event, "data")) {
+ data = qdict_get_qdict(event, "data");
+ QINCREF(data);
+ } else {
+ data = NULL;
+ }
+
+ QDECREF(event);
+ return data;
+}
+
+static QDict *ib700_program_and_wait(QTestState *s)
+{
+ clock_step(NS_PER_SEC * 40);
+ qmp_check_no_event();
+
+ /* 2 second limit */
+ outb(0x443, 14);
+
+ /* Ping */
+ clock_step(NS_PER_SEC);
+ qmp_check_no_event();
+ outb(0x443, 14);
+
+ /* Disable */
+ clock_step(NS_PER_SEC);
+ qmp_check_no_event();
+ outb(0x441, 1);
+ clock_step(3 * NS_PER_SEC);
+ qmp_check_no_event();
+
+ /* Enable and let it fire */
+ outb(0x443, 13);
+ clock_step(3 * NS_PER_SEC);
+ qmp_check_no_event();
+ clock_step(2 * NS_PER_SEC);
+ return qmp_get_event("WATCHDOG");
+}
+
+
+static void ib700_pause(void)
+{
+ QDict *d;
+ QTestState *s = qtest_start("-watchdog-action pause -device ib700");
+ qtest_irq_intercept_in(s, "ioapic");
+ d = ib700_program_and_wait(s);
+ g_assert(!strcmp(qdict_get_str(d, "action"), "pause"));
+ QDECREF(d);
+ d = qmp_get_event("STOP");
+ QDECREF(d);
+ qtest_end();
+}
+
+static void ib700_reset(void)
+{
+ QDict *d;
+ QTestState *s = qtest_start("-watchdog-action reset -device ib700");
+ qtest_irq_intercept_in(s, "ioapic");
+ d = ib700_program_and_wait(s);
+ g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
+ QDECREF(d);
+ d = qmp_get_event("RESET");
+ QDECREF(d);
+ qtest_end();
+}
+
+static void ib700_shutdown(void)
+{
+ QDict *d;
+ QTestState *s = qtest_start("-watchdog-action reset -no-reboot -device ib700");
+ qtest_irq_intercept_in(s, "ioapic");
+ d = ib700_program_and_wait(s);
+ g_assert(!strcmp(qdict_get_str(d, "action"), "reset"));
+ QDECREF(d);
+ d = qmp_get_event("SHUTDOWN");
+ QDECREF(d);
+ qtest_end();
+}
+
+static void ib700_none(void)
+{
+ QDict *d;
+ QTestState *s = qtest_start("-watchdog-action none -device ib700");
+ qtest_irq_intercept_in(s, "ioapic");
+ d = ib700_program_and_wait(s);
+ g_assert(!strcmp(qdict_get_str(d, "action"), "none"));
+ QDECREF(d);
+ qtest_end();
+}
+
+int main(int argc, char **argv)
+{
+ int ret;
+
+ g_test_init(&argc, &argv, NULL);
+ qtest_add_func("/wdt_ib700/pause", ib700_pause);
+ qtest_add_func("/wdt_ib700/reset", ib700_reset);
+ qtest_add_func("/wdt_ib700/shutdown", ib700_shutdown);
+ qtest_add_func("/wdt_ib700/none", ib700_none);
+
+ ret = g_test_run();
+
+ return ret;
+}