From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: eblake@redhat.com, ehabkost@redhat.com, pkrempa@redhat.com,
armbru@redhat.com
Subject: [Qemu-devel] [PATCH v6 08/11] tests: extend qmp test with preconfig checks
Date: Fri, 27 Apr 2018 17:05:20 +0200 [thread overview]
Message-ID: <1524841523-95513-9-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1524841523-95513-1-git-send-email-imammedo@redhat.com>
Add permission checks for commands at 'preconfig' stage.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
v6:
* replace 'cont' with 'exit-preconfig' command
v5:
* s/-preconfig/--preconfig/
v4:
* s/is_err()/qmp_rsp_is_err()/
* return true even if 'error' doesn't contain 'desc'
(Eric Blake <eblake@redhat.com>)
---
tests/qmp-test.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/tests/qmp-test.c b/tests/qmp-test.c
index 772058f..c49837a 100644
--- a/tests/qmp-test.c
+++ b/tests/qmp-test.c
@@ -392,6 +392,49 @@ static void add_query_tests(QmpSchema *schema)
}
}
+static bool qmp_rsp_is_err(QDict *rsp)
+{
+ QDict *error = qdict_get_qdict(rsp, "error");
+ QDECREF(rsp);
+ return !!error;
+}
+
+static void test_qmp_preconfig(void)
+{
+ QDict *rsp, *ret;
+ QTestState *qs = qtest_startf("%s --preconfig", common_args);
+
+ /* preconfig state */
+ /* enabled commands, no error expected */
+ g_assert(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'query-commands' }")));
+
+ /* forbidden commands, expected error */
+ g_assert(qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'query-cpus' }")));
+
+ /* check that query-status returns preconfig state */
+ 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(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'exit-preconfig' }")));
+ qtest_qmp_eventwait(qs, "RESUME");
+
+ /* check that query-status returns running state */
+ 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(!qmp_rsp_is_err(qtest_qmp(qs, "{ 'execute': 'query-cpus' }")));
+
+ qtest_quit(qs);
+}
+
int main(int argc, char *argv[])
{
QmpSchema schema;
@@ -403,6 +446,7 @@ int main(int argc, char *argv[])
qtest_add_func("qmp/oob", test_qmp_oob);
qmp_schema_init(&schema);
add_query_tests(&schema);
+ qtest_add_func("qmp/preconfig", test_qmp_preconfig);
ret = g_test_run();
--
2.7.4
next prev parent reply other threads:[~2018-04-27 15:06 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-27 15:05 [Qemu-devel] [PATCH v6 00/11] enable numa configuration before machine_init() from QMP Igor Mammedov
2018-04-27 15:05 ` [Qemu-devel] [PATCH v6 01/11] numa: postpone options post-processing till machine_run_board_init() Igor Mammedov
2018-04-27 15:05 ` [Qemu-devel] [PATCH v6 02/11] numa: split out NumaOptions parsing into set_numa_options() Igor Mammedov
2018-04-27 15:05 ` [Qemu-devel] [PATCH v6 03/11] cli: add --preconfig option Igor Mammedov
2018-04-27 21:44 ` Eric Blake
2018-05-01 15:07 ` Daniel P. Berrangé
2018-05-03 11:35 ` Igor Mammedov
2018-04-27 15:05 ` [Qemu-devel] [PATCH v6 04/11] hmp: disable monitor in preconfig state Igor Mammedov
2018-04-27 21:48 ` Eric Blake
2018-04-27 15:05 ` [Qemu-devel] [PATCH v6 05/11] qapi: introduce new cmd option "allowed-in-preconfig" Igor Mammedov
2018-04-27 22:05 ` Eric Blake
2018-04-28 3:51 ` Peter Xu
2018-04-30 14:49 ` Eric Blake
2018-05-01 14:57 ` Igor Mammedov
2018-05-01 15:29 ` Daniel P. Berrangé
2018-05-03 11:22 ` Igor Mammedov
2018-04-27 15:05 ` [Qemu-devel] [PATCH v6 06/11] tests: let qapi-schema tests detect allowed-in-preconfig Igor Mammedov
2018-04-27 22:08 ` Eric Blake
2018-04-27 22:12 ` Eric Blake
2018-04-27 15:05 ` [Qemu-devel] [PATCH v6 07/11] tests: add allowed-in-preconfig-test for qapi-schema Igor Mammedov
2018-04-27 22:11 ` Eric Blake
2018-04-27 15:05 ` Igor Mammedov [this message]
2018-04-27 15:05 ` [Qemu-devel] [PATCH v6 09/11] qmp: permit query-hotpluggable-cpus in preconfig state Igor Mammedov
2018-04-27 15:05 ` [Qemu-devel] [PATCH v6 10/11] qmp: add set-numa-node command Igor Mammedov
2018-04-27 15:05 ` [Qemu-devel] [PATCH v6 11/11] tests: functional tests for QMP command set-numa-node Igor Mammedov
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=1524841523-95513-9-git-send-email-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--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).