From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: eblake@redhat.com, armbru@redhat.com, ehabkost@redhat.com,
pkrempa@redhat.com, david@gibson.dropbear.id.au,
peter.maydell@linaro.org, pbonzini@redhat.com, cohuck@redhat.com
Subject: [Qemu-devel] [PATCH v3 6/9] tests: extend qmp test with pereconfig checks
Date: Fri, 16 Feb 2018 13:37:18 +0100 [thread overview]
Message-ID: <1518784641-43151-7-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1518784641-43151-1-git-send-email-imammedo@redhat.com>
Add permission checks for commands in 'preconfig' state.
It should work for all targets, but won't work with
machine 'none' as it's limited to -smp 1 only.
So use PC machine for testing preconfig and 'runstate'
parameter.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
tests/qmp-test.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/tests/qmp-test.c b/tests/qmp-test.c
index 5808483..3adc485 100644
--- a/tests/qmp-test.c
+++ b/tests/qmp-test.c
@@ -304,8 +304,54 @@ static void add_query_tests(QmpSchema *schema)
}
}
+static bool is_err(QDict *rsp)
+{
+ const char *desc = NULL;
+ QDict *error = qdict_get_qdict(rsp, "error");
+ if (error) {
+ desc = qdict_get_try_str(error, "desc");
+ }
+ QDECREF(rsp);
+ return !!desc;
+}
+
+static void test_qmp_preconfig(void)
+{
+ QDict *rsp, *ret;
+ QTestState *qs = qtest_startf("-nodefaults -preconfig -smp 2");
+
+ /* preconfig state */
+ /* enabled commands, no error expected */
+ g_assert(!is_err(qtest_qmp(qs, "{ 'execute': 'query-commands' }")));
+
+ /* forbidden commands, expected error */
+ g_assert(is_err(qtest_qmp(qs, "{ 'execute': 'query-cpus' }")));
+
+ rsp = qtest_qmp(qs, "{ 'execute': 'query-status' }");
+ ret = qdict_get_qdict(rsp, "return");
+ g_assert(ret);
+ g_assert_cmpstr(qdict_get_try_str(ret, "status"), ==, "preconfig");
+ QDECREF(rsp);
+
+ /* exit preconfig state */
+ g_assert(!is_err(qtest_qmp(qs, "{ 'execute': 'cont' }")));
+ qtest_qmp_eventwait(qs, "RESUME");
+
+ rsp = qtest_qmp(qs, "{ 'execute': 'query-status' }");
+ ret = qdict_get_qdict(rsp, "return");
+ g_assert(ret);
+ g_assert_cmpstr(qdict_get_try_str(ret, "status"), ==, "running");
+ QDECREF(rsp);
+
+ /* enabled commands, no error expected */
+ g_assert(!is_err(qtest_qmp(qs, "{ 'execute': 'query-cpus' }")));
+
+ qtest_quit(qs);
+}
+
int main(int argc, char *argv[])
{
+ const char *arch = qtest_get_arch();
QmpSchema schema;
int ret;
@@ -314,6 +360,9 @@ int main(int argc, char *argv[])
qtest_add_func("qmp/protocol", test_qmp_protocol);
qmp_schema_init(&schema);
add_query_tests(&schema);
+ if (!strcmp(arch, "i386") || !strcmp(arch, "x86_64")) {
+ qtest_add_func("qmp/preconfig", test_qmp_preconfig);
+ }
ret = g_test_run();
--
2.7.4
next prev parent reply other threads:[~2018-02-16 12:39 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-16 12:37 [Qemu-devel] [PATCH v3 0/9] enable numa configuration before machine_init() from QMP Igor Mammedov
2018-02-16 12:37 ` [Qemu-devel] [PATCH v3 1/9] numa: postpone options post-processing till machine_run_board_init() Igor Mammedov
2018-02-16 12:37 ` [Qemu-devel] [PATCH v3 2/9] numa: split out NumaOptions parsing into parse_NumaOptions() Igor Mammedov
2018-02-16 12:37 ` [Qemu-devel] [PATCH v3 3/9] CLI: add -preconfig option Igor Mammedov
2018-02-27 20:39 ` Eric Blake
2018-02-28 15:54 ` Igor Mammedov
2018-02-16 12:37 ` [Qemu-devel] [PATCH v3 4/9] HMP: disable monitor in preconfig state Igor Mammedov
2018-03-07 14:01 ` Dr. David Alan Gilbert
2018-03-08 15:47 ` Igor Mammedov
2018-02-16 12:37 ` [Qemu-devel] [PATCH v3 5/9] QAPI: allow to specify valid runstates per command Igor Mammedov
2018-02-27 22:10 ` Eric Blake
2018-02-28 16:17 ` Igor Mammedov
2018-03-07 14:16 ` Dr. David Alan Gilbert
2018-03-08 15:55 ` Igor Mammedov
2018-02-16 12:37 ` Igor Mammedov [this message]
2018-02-27 22:13 ` [Qemu-devel] [PATCH v3 6/9] tests: extend qmp test with pereconfig checks Eric Blake
2018-02-16 12:37 ` [Qemu-devel] [PATCH v3 7/9] QMP: permit query-hotpluggable-cpus in preconfig state Igor Mammedov
2018-02-16 12:37 ` [Qemu-devel] [PATCH v3 8/9] QMP: add set-numa-node command Igor Mammedov
2018-02-27 22:17 ` Eric Blake
2018-02-16 12:37 ` [Qemu-devel] [PATCH v3 9/9] tests: functional tests for QMP command set-numa-node Igor Mammedov
2018-02-27 22:19 ` Eric Blake
2018-02-27 16:36 ` [Qemu-devel] [PATCH v3 0/9] enable numa configuration before machine_init() from QMP Igor Mammedov
2018-02-27 20:29 ` Eric Blake
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=1518784641-43151-7-git-send-email-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=armbru@redhat.com \
--cc=cohuck@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=pkrempa@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).