* [Qemu-devel] [PULL 0/1] qemu-ga patch queue
@ 2016-06-07 20:52 Michael Roth
2016-06-07 20:52 ` [Qemu-devel] [PULL 1/1] tests: start a /qga/guest-exec test Michael Roth
2016-06-08 15:31 ` [Qemu-devel] [PULL 0/1] qemu-ga patch queue Peter Maydell
0 siblings, 2 replies; 3+ messages in thread
From: Michael Roth @ 2016-06-07 20:52 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell
The following changes since commit 6ed5546fa7bf12c5b87ef76bafb86e1d77ed6e85:
Merge remote-tracking branch 'remotes/mjt/tags/pull-trivial-patches-2016-06-07' into staging (2016-06-07 16:34:45 +0100)
are available in the git repository at:
git://github.com/mdroth/qemu.git tags/qga-pull-2016-07-07-tag
for you to fetch changes up to 3dab9fa1ac8fdfebbfbc5142ba42d89d96a6b5f4:
tests: start a /qga/guest-exec test (2016-06-07 11:25:06 -0500)
----------------------------------------------------------------
qemu-ga patch queue
* add unit tests for guest-exec command set
----------------------------------------------------------------
Marc-André Lureau (1):
tests: start a /qga/guest-exec test
tests/test-qga.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PULL 1/1] tests: start a /qga/guest-exec test
2016-06-07 20:52 [Qemu-devel] [PULL 0/1] qemu-ga patch queue Michael Roth
@ 2016-06-07 20:52 ` Michael Roth
2016-06-08 15:31 ` [Qemu-devel] [PULL 0/1] qemu-ga patch queue Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Michael Roth @ 2016-06-07 20:52 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Test a few guest-exec guest agent commands, added in qemu 2.5.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
tests/test-qga.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/tests/test-qga.c b/tests/test-qga.c
index 9c9039f..251b201 100644
--- a/tests/test-qga.c
+++ b/tests/test-qga.c
@@ -822,6 +822,84 @@ static void test_qga_fsfreeze_and_thaw(gconstpointer fix)
QDECREF(ret);
}
+static void test_qga_guest_exec(gconstpointer fix)
+{
+ const TestFixture *fixture = fix;
+ QDict *ret, *val;
+ const gchar *out;
+ guchar *decoded;
+ int64_t pid, now, exitcode;
+ gsize len;
+ bool exited;
+
+ /* exec 'echo foo bar' */
+ ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {"
+ " 'path': '/bin/echo', 'arg': [ '-n', '\" test_str \"' ],"
+ " 'capture-output': true } }");
+ g_assert_nonnull(ret);
+ qmp_assert_no_error(ret);
+ val = qdict_get_qdict(ret, "return");
+ pid = qdict_get_int(val, "pid");
+ g_assert_cmpint(pid, >, 0);
+ QDECREF(ret);
+
+ /* wait for completion */
+ now = g_get_monotonic_time();
+ do {
+ ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec-status',"
+ " 'arguments': { 'pid': %" PRId64 " } }", pid);
+ g_assert_nonnull(ret);
+ val = qdict_get_qdict(ret, "return");
+ exited = qdict_get_bool(val, "exited");
+ if (!exited) {
+ QDECREF(ret);
+ }
+ } while (!exited &&
+ g_get_monotonic_time() < now + 5 * G_TIME_SPAN_SECOND);
+ g_assert(exited);
+
+ /* check stdout */
+ exitcode = qdict_get_int(val, "exitcode");
+ g_assert_cmpint(exitcode, ==, 0);
+ out = qdict_get_str(val, "out-data");
+ decoded = g_base64_decode(out, &len);
+ g_assert_cmpint(len, ==, 12);
+ g_assert_cmpstr((char *)decoded, ==, "\" test_str \"");
+ g_free(decoded);
+ QDECREF(ret);
+}
+
+static void test_qga_guest_exec_invalid(gconstpointer fix)
+{
+ const TestFixture *fixture = fix;
+ QDict *ret, *error;
+ const gchar *class, *desc;
+
+ /* invalid command */
+ ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec', 'arguments': {"
+ " 'path': '/bin/invalid-cmd42' } }");
+ g_assert_nonnull(ret);
+ error = qdict_get_qdict(ret, "error");
+ g_assert_nonnull(error);
+ class = qdict_get_str(error, "class");
+ desc = qdict_get_str(error, "desc");
+ g_assert_cmpstr(class, ==, "GenericError");
+ g_assert_cmpint(strlen(desc), >, 0);
+ QDECREF(ret);
+
+ /* invalid pid */
+ ret = qmp_fd(fixture->fd, "{'execute': 'guest-exec-status',"
+ " 'arguments': { 'pid': 0 } }");
+ g_assert_nonnull(ret);
+ error = qdict_get_qdict(ret, "error");
+ g_assert_nonnull(error);
+ class = qdict_get_str(error, "class");
+ desc = qdict_get_str(error, "desc");
+ g_assert_cmpstr(class, ==, "GenericError");
+ g_assert_cmpint(strlen(desc), >, 0);
+ QDECREF(ret);
+}
+
int main(int argc, char **argv)
{
TestFixture fix;
@@ -852,6 +930,9 @@ int main(int argc, char **argv)
g_test_add_data_func("/qga/blacklist", NULL, test_qga_blacklist);
g_test_add_data_func("/qga/config", NULL, test_qga_config);
+ g_test_add_data_func("/qga/guest-exec", &fix, test_qga_guest_exec);
+ g_test_add_data_func("/qga/guest-exec-invalid", &fix,
+ test_qga_guest_exec_invalid);
if (g_getenv("QGA_TEST_SIDE_EFFECTING")) {
g_test_add_data_func("/qga/fsfreeze-and-thaw", &fix,
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PULL 0/1] qemu-ga patch queue
2016-06-07 20:52 [Qemu-devel] [PULL 0/1] qemu-ga patch queue Michael Roth
2016-06-07 20:52 ` [Qemu-devel] [PULL 1/1] tests: start a /qga/guest-exec test Michael Roth
@ 2016-06-08 15:31 ` Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2016-06-08 15:31 UTC (permalink / raw)
To: Michael Roth; +Cc: QEMU Developers
On 7 June 2016 at 21:52, Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> The following changes since commit 6ed5546fa7bf12c5b87ef76bafb86e1d77ed6e85:
>
> Merge remote-tracking branch 'remotes/mjt/tags/pull-trivial-patches-2016-06-07' into staging (2016-06-07 16:34:45 +0100)
>
> are available in the git repository at:
>
>
> git://github.com/mdroth/qemu.git tags/qga-pull-2016-07-07-tag
>
> for you to fetch changes up to 3dab9fa1ac8fdfebbfbc5142ba42d89d96a6b5f4:
>
> tests: start a /qga/guest-exec test (2016-06-07 11:25:06 -0500)
>
> ----------------------------------------------------------------
> qemu-ga patch queue
>
> * add unit tests for guest-exec command set
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-08 15:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-07 20:52 [Qemu-devel] [PULL 0/1] qemu-ga patch queue Michael Roth
2016-06-07 20:52 ` [Qemu-devel] [PULL 1/1] tests: start a /qga/guest-exec test Michael Roth
2016-06-08 15:31 ` [Qemu-devel] [PULL 0/1] qemu-ga patch queue Peter Maydell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.