From: Roman Penyaev <r.peniaev@gmail.com>
Cc: "Roman Penyaev" <r.peniaev@gmail.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
qemu-devel@nongnu.org
Subject: [PATCH v2 8/8] tests/unit/test-char: implement a few mux remove test cases
Date: Mon, 14 Oct 2024 17:24:08 +0200 [thread overview]
Message-ID: <20241014152408.427700-9-r.peniaev@gmail.com> (raw)
In-Reply-To: <20241014152408.427700-1-r.peniaev@gmail.com>
This patch tests:
1. feasibility of removing mux which does not have frontends attached
or frontends were prior detached.
2. inability to remove mux which has frontends attached (mux is "busy")
Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org
---
tests/unit/test-char.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/tests/unit/test-char.c b/tests/unit/test-char.c
index f273ce522612..2837dbb863a8 100644
--- a/tests/unit/test-char.c
+++ b/tests/unit/test-char.c
@@ -1,6 +1,7 @@
#include "qemu/osdep.h"
#include <glib/gstdio.h>
+#include "qapi/error.h"
#include "qemu/config-file.h"
#include "qemu/module.h"
#include "qemu/option.h"
@@ -184,6 +185,21 @@ static void char_mux_test(void)
char *data;
FeHandler h1 = { 0, false, 0, false, }, h2 = { 0, false, 0, false, };
CharBackend chr_be1, chr_be2;
+ Error *error = NULL;
+
+ /* Create mux and chardev to be immediately removed */
+ opts = qemu_opts_create(qemu_find_opts("chardev"), "mux-label",
+ 1, &error_abort);
+ qemu_opt_set(opts, "backend", "ringbuf", &error_abort);
+ qemu_opt_set(opts, "size", "128", &error_abort);
+ qemu_opt_set(opts, "mux", "on", &error_abort);
+ chr = qemu_chr_new_from_opts(opts, NULL, &error_abort);
+ g_assert_nonnull(chr);
+ qemu_opts_del(opts);
+
+ /* Remove just created mux and chardev */
+ qmp_chardev_remove("mux-label", &error_abort);
+ qmp_chardev_remove("mux-label-base", &error_abort);
opts = qemu_opts_create(qemu_find_opts("chardev"), "mux-label",
1, &error_abort);
@@ -334,7 +350,13 @@ static void char_mux_test(void)
g_free(data);
qemu_chr_fe_deinit(&chr_be1, false);
- qemu_chr_fe_deinit(&chr_be2, true);
+
+ error = NULL;
+ qmp_chardev_remove("mux-label", &error);
+ g_assert_cmpstr(error_get_pretty(error), ==, "Chardev 'mux-label' is busy");
+
+ qemu_chr_fe_deinit(&chr_be2, false);
+ qmp_chardev_remove("mux-label", &error_abort);
}
--
2.34.1
next prev parent reply other threads:[~2024-10-14 15:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-14 15:24 [PATCH v2 0/8] chardev/mux: implement frontend detach Roman Penyaev
2024-10-14 15:24 ` [PATCH v2 1/8] chardev/char: fix qemu_chr_is_busy() check Roman Penyaev
2024-10-14 15:24 ` [PATCH v2 2/8] chardev/chardev-internal: remove unused `max_size` struct member Roman Penyaev
2024-10-22 5:21 ` CLEMENT MATHIEU--DRIF
2024-10-14 15:24 ` [PATCH v2 3/8] chardev/mux: use bool type for `linestart` and `term_got_escape` Roman Penyaev
2024-10-22 5:21 ` CLEMENT MATHIEU--DRIF
2024-10-14 15:24 ` [PATCH v2 4/8] chardev/mux: convert size members to unsigned int Roman Penyaev
2024-10-14 15:24 ` [PATCH v2 5/8] chardev/mux: introduce `mux_chr_attach_frontend() call Roman Penyaev
2024-10-14 15:24 ` [PATCH v2 6/8] chardev/mux: switch mux frontends management to bitset Roman Penyaev
2024-10-14 15:24 ` [PATCH v2 7/8] chardev/mux: implement detach of frontends from mux Roman Penyaev
2024-10-22 5:20 ` CLEMENT MATHIEU--DRIF
2024-11-02 11:19 ` Roman Penyaev
2024-10-14 15:24 ` Roman Penyaev [this message]
2024-10-15 8:50 ` [PATCH v2 8/8] tests/unit/test-char: implement a few mux remove test cases Marc-André Lureau
2024-10-15 16:51 ` Roman Penyaev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241014152408.427700-9-r.peniaev@gmail.com \
--to=r.peniaev@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).