summaryrefslogtreecommitdiffstats
path: root/tests/qtest/libqtest.c
diff options
context:
space:
mode:
authorStefan Hajnoczi2022-10-13 19:55:24 +0200
committerStefan Hajnoczi2022-10-13 19:55:24 +0200
commit7a37814aeb0fdf6bfce321f83c111f1ff092ca2f (patch)
tree8eb59026c2a6fa4716a1169cbfb96ef4b26d9a61 /tests/qtest/libqtest.c
parentMerge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (diff)
parenttests/unit/test-image-locking: Fix handling of temporary files (diff)
downloadqemu-7a37814aeb0fdf6bfce321f83c111f1ff092ca2f.tar.gz
qemu-7a37814aeb0fdf6bfce321f83c111f1ff092ca2f.tar.xz
qemu-7a37814aeb0fdf6bfce321f83c111f1ff092ca2f.zip
Merge tag 'pull-request-2022-10-12' of https://gitlab.com/thuth/qemu into staging
* Rework of qtests to support hot plugging tests on q35 * New VNC qtest * Fixes related to temporary file handling in the tests * Use signal() instead of sigaction() since the latter does not work on Windows * Some other small clean-ups # -----BEGIN PGP SIGNATURE----- # # iQJFBAABCAAvFiEEJ7iIR+7gJQEY8+q5LtnXdP5wLbUFAmNGz1URHHRodXRoQHJl # ZGhhdC5jb20ACgkQLtnXdP5wLbXwxxAAoh9CeYKLyPFPe71XGsSWW4mQDkny+4CA # AFBfcEchPSyOoTJwuSHS5cL27KkL1Wy7wTSlWdcQ2Z4LA8hexopfPtCVlizH8vQh # hHVP5KLDY7WA7bsuRznrjUjXtjLL9mExuPm3QZ+YxH/3rNhISvq1GfC9Z5PQ/zNp # GagCW+WiFyEYyhRHJnVVTJfZV0NCbJp9KCCJ6n/Rag80JRQiouGQsKLfRoRhvkGC # 13dWq2NeDq9xE1k1ThUZdIpUxJO4cA+9bh6LzGOIcHX8akfkryh3NGCWuojX3XDF # 2CRyyblfjMIp5HUcKNOrQzY1oGRn8y5537ycUkEsropSMdAccIqNwlcWO7whLEGn # 7nbogrPt8Orezytl5ZM3WopWlge5KA2vxOUURx487LnZC2/g7l2unrCDv0c3PHDb # U2fD5do7ZtPOl9Uz8QkYPo5CzEDnKPmPv1txOMBRcBZsvmXPZMxRWwsYavB/RloG # nI9IvG3ZW6ivKwoPPceJberL8Ndq+pqn7y4CNNAAunHSjJ2H0YS1m1F/HfVWKJYJ # uStXy3IZ5Qo8E+IRbPYyM68yBgrnaShuAvTSax8tWjhHOR8HetrzPABMrWylCrdo # gaeSCEZmqf2zIYHQ2q8c7U/YrHgFNHlLz9yCyM6rZtU9dOAe52PG2TlRQomlGP76 # NKnti3RJWG4= # =4f+b # -----END PGP SIGNATURE----- # gpg: Signature made Wed 12 Oct 2022 10:29:41 EDT # gpg: using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5 # gpg: issuer "thuth@redhat.com" # gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full] # gpg: aka "Thomas Huth <thuth@redhat.com>" [full] # gpg: aka "Thomas Huth <huth@tuxfamily.org>" [full] # gpg: aka "Thomas Huth <th.huth@posteo.de>" [unknown] # Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5 * tag 'pull-request-2022-10-12' of https://gitlab.com/thuth/qemu: tests/unit/test-image-locking: Fix handling of temporary files tests/qtest: libqtest: Install signal handler via signal() tests/qtest: migration-test: Avoid using hardcoded /tmp qtest: start a VNC test tests/avocado: Add missing require_netdev('user') checks tests/x86: Add 'q35' machine type to ivshmem-test tests/x86: Add 'q35' machine type to drive_del-test tests/x86: replace snprint() by g_strdup_printf() in drive_del-test tests/x86: Fix comment typo in drive_del-test tests/x86: Add 'q35' machine type to hotplug hd-geo-test tests/x86: Add 'q35' machine type to override-tests in hd-geo-test tests/x86: Refactor hot unplug hd-geo-test tests/x86: Add subtest with 'q35' machine type to device-plug-test tests/x86: add helper qtest_qmp_device_del_send() tests/migration: remove the unused local variable qtest: "-display none" is set in qtest_init() Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/qtest/libqtest.c')
-rw-r--r--tests/qtest/libqtest.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 4f4b2d6477..b23eb3edc3 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -66,7 +66,7 @@ struct QTestState
};
static GHookList abrt_hooks;
-static struct sigaction sigact_old;
+static void (*sighandler_old)(int);
static int qtest_query_target_endianness(QTestState *s);
@@ -179,20 +179,12 @@ static void sigabrt_handler(int signo)
static void setup_sigabrt_handler(void)
{
- struct sigaction sigact;
-
- /* Catch SIGABRT to clean up on g_assert() failure */
- sigact = (struct sigaction){
- .sa_handler = sigabrt_handler,
- .sa_flags = SA_RESETHAND,
- };
- sigemptyset(&sigact.sa_mask);
- sigaction(SIGABRT, &sigact, &sigact_old);
+ sighandler_old = signal(SIGABRT, sigabrt_handler);
}
static void cleanup_sigabrt_handler(void)
{
- sigaction(SIGABRT, &sigact_old, NULL);
+ signal(SIGABRT, sighandler_old);
}
static bool hook_list_is_empty(GHookList *hook_list)
@@ -1371,15 +1363,19 @@ void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd)
*
* {"return": {}}
*/
-void qtest_qmp_device_del(QTestState *qts, const char *id)
+void qtest_qmp_device_del_send(QTestState *qts, const char *id)
{
- QDict *rsp;
-
- rsp = qtest_qmp(qts, "{'execute': 'device_del', 'arguments': {'id': %s}}",
- id);
-
+ QDict *rsp = qtest_qmp(qts, "{'execute': 'device_del', "
+ "'arguments': {'id': %s}}", id);
+ g_assert(rsp);
g_assert(qdict_haskey(rsp, "return"));
+ g_assert(!qdict_haskey(rsp, "error"));
qobject_unref(rsp);
+}
+
+void qtest_qmp_device_del(QTestState *qts, const char *id)
+{
+ qtest_qmp_device_del_send(qts, id);
qtest_qmp_eventwait(qts, "DEVICE_DELETED");
}