From: Julia Suvorova <jusual@mail.ru>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Joel Stanley" <joel@jms.id.au>,
"Jim Mussared" <jim@groklearning.com>,
"Steffen Görtz" <contrib@steffen-goertz.de>,
"Julia Suvorova" <jusual@mail.ru>
Subject: [Qemu-devel] [PATCH v4 1/3] tests/libqtest: Introduce qtest_init_with_serial()
Date: Thu, 17 Jan 2019 19:16:38 +0300 [thread overview]
Message-ID: <20190117161640.5496-2-jusual@mail.ru> (raw)
In-Reply-To: <20190117161640.5496-1-jusual@mail.ru>
Run qtest with a socket that connects QEMU chardev and test code.
Signed-off-by: Julia Suvorova <jusual@mail.ru>
---
tests/libqtest.c | 26 ++++++++++++++++++++++++++
tests/libqtest.h | 11 +++++++++++
2 files changed, 37 insertions(+)
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 55750dd68d..3a015cfe13 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -315,6 +315,32 @@ QTestState *qtest_initf(const char *fmt, ...)
return s;
}
+QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd)
+{
+ int sock_fd_init;
+ char *sock_path, sock_dir[] = "/tmp/qtest-serial-XXXXXX";
+ QTestState *qts;
+
+ g_assert(mkdtemp(sock_dir));
+ sock_path = g_strdup_printf("%s/sock", sock_dir);
+
+ sock_fd_init = init_socket(sock_path);
+
+ qts = qtest_initf("-chardev socket,id=s0,path=%s,nowait "
+ "-serial chardev:s0 %s",
+ sock_path, extra_args);
+
+ *sock_fd = socket_accept(sock_fd_init);
+
+ unlink(sock_path);
+ g_free(sock_path);
+ rmdir(sock_dir);
+
+ g_assert(*sock_fd >= 0);
+
+ return qts;
+}
+
void qtest_quit(QTestState *s)
{
g_hook_destroy_link(&abrt_hooks, g_hook_find_data(&abrt_hooks, TRUE, s));
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 7ea94139b0..5937f91912 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -62,6 +62,17 @@ QTestState *qtest_init(const char *extra_args);
*/
QTestState *qtest_init_without_qmp_handshake(const char *extra_args);
+/**
+ * qtest_init_with_serial:
+ * @extra_args: other arguments to pass to QEMU. CAUTION: these
+ * arguments are subject to word splitting and shell evaluation.
+ * @sock_fd: pointer to store the socket file descriptor for
+ * connection with serial.
+ *
+ * Returns: #QTestState instance.
+ */
+QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd);
+
/**
* qtest_quit:
* @s: #QTestState instance to operate on.
--
2.17.1
next prev parent reply other threads:[~2019-01-17 16:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-17 16:16 [Qemu-devel] [PATCH v4 0/3] tests/microbit-test: Add UART device test Julia Suvorova
2019-01-17 16:16 ` Julia Suvorova [this message]
2019-01-21 12:07 ` [Qemu-devel] [PATCH v4 1/3] tests/libqtest: Introduce qtest_init_with_serial() Thomas Huth
2019-01-17 16:16 ` [Qemu-devel] [PATCH v4 2/3] tests/microbit-test: Make test independent of global_qtest Julia Suvorova
2019-01-17 16:58 ` Philippe Mathieu-Daudé
2019-01-21 12:09 ` Thomas Huth
2019-01-17 16:16 ` [Qemu-devel] [PATCH v4 3/3] tests/microbit-test: Check nRF51 UART functionality Julia Suvorova
2019-01-17 17:41 ` Stefan Hajnoczi
2019-01-21 12:51 ` Thomas Huth
2019-01-21 15:35 ` Alex Bennée
2019-01-17 17:42 ` [Qemu-devel] [PATCH v4 0/3] tests/microbit-test: Add UART device test Stefan Hajnoczi
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=20190117161640.5496-2-jusual@mail.ru \
--to=jusual@mail.ru \
--cc=contrib@steffen-goertz.de \
--cc=jim@groklearning.com \
--cc=joel@jms.id.au \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.com \
/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).