Message ID | d8f2677fdb9c4d261b6c0f80ca0fd4ce5ef6efba.1524247455.git.tgolembi@redhat.com |
---|---|
State | New |
Headers | show |
Series | test-qga: add trivial tests for some commands | expand |
On Fri, Apr 20, 2018 at 8:04 PM, Tomáš Golembiovský <tgolembi@redhat.com> wrote: > These commands did not get their tests in the original commits: > - guest-get-host-name > - guest-get-timezone > - guest-get-users > > Trivial tests that mostly only call the commands were added. > > Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> thank you: Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > tests/test-qga.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 54 insertions(+) > > diff --git a/tests/test-qga.c b/tests/test-qga.c > index e6ab788f31..503f48bacf 100644 > --- a/tests/test-qga.c > +++ b/tests/test-qga.c > @@ -856,6 +856,54 @@ static void test_qga_guest_exec_invalid(gconstpointer fix) > QDECREF(ret); > } > > +static void test_qga_guest_get_host_name(gconstpointer fix) > +{ > + const TestFixture *fixture = fix; > + QDict *ret, *val; > + > + ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-host-name'}"); > + g_assert_nonnull(ret); > + qmp_assert_no_error(ret); > + > + val = qdict_get_qdict(ret, "return"); > + g_assert(qdict_haskey(val, "host-name")); > + > + QDECREF(ret); > +} > + > +static void test_qga_guest_get_timezone(gconstpointer fix) > +{ > + const TestFixture *fixture = fix; > + QDict *ret, *val; > + > + ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-timezone'}"); > + g_assert_nonnull(ret); > + qmp_assert_no_error(ret); > + > + /* Make sure there's at least offset */ > + val = qdict_get_qdict(ret, "return"); > + g_assert(qdict_haskey(val, "offset")); > + > + QDECREF(ret); > +} > + > +static void test_qga_guest_get_users(gconstpointer fix) > +{ > + const TestFixture *fixture = fix; > + QDict *ret; > + QList *val; > + > + ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-users'}"); > + g_assert_nonnull(ret); > + qmp_assert_no_error(ret); > + > + /* There is not much to test here */ > + val = qdict_get_qlist(ret, "return"); > + g_assert_nonnull(val); > + > + QDECREF(ret); > +} > + > static void test_qga_guest_get_osinfo(gconstpointer data) > { > TestFixture fixture; > @@ -948,6 +996,12 @@ int main(int argc, char **argv) > test_qga_guest_exec_invalid); > g_test_add_data_func("/qga/guest-get-osinfo", &fix, > test_qga_guest_get_osinfo); > + g_test_add_data_func("/qga/guest-get-host-name", &fix, > + test_qga_guest_get_host_name); > + g_test_add_data_func("/qga/guest-get-timezone", &fix, > + test_qga_guest_get_timezone); > + g_test_add_data_func("/qga/guest-get-users", &fix, > + test_qga_guest_get_users); > > ret = g_test_run(); > > -- > 2.17.0 > >
diff --git a/tests/test-qga.c b/tests/test-qga.c index e6ab788f31..503f48bacf 100644 --- a/tests/test-qga.c +++ b/tests/test-qga.c @@ -856,6 +856,54 @@ static void test_qga_guest_exec_invalid(gconstpointer fix) QDECREF(ret); } +static void test_qga_guest_get_host_name(gconstpointer fix) +{ + const TestFixture *fixture = fix; + QDict *ret, *val; + + ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-host-name'}"); + g_assert_nonnull(ret); + qmp_assert_no_error(ret); + + val = qdict_get_qdict(ret, "return"); + g_assert(qdict_haskey(val, "host-name")); + + QDECREF(ret); +} + +static void test_qga_guest_get_timezone(gconstpointer fix) +{ + const TestFixture *fixture = fix; + QDict *ret, *val; + + ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-timezone'}"); + g_assert_nonnull(ret); + qmp_assert_no_error(ret); + + /* Make sure there's at least offset */ + val = qdict_get_qdict(ret, "return"); + g_assert(qdict_haskey(val, "offset")); + + QDECREF(ret); +} + +static void test_qga_guest_get_users(gconstpointer fix) +{ + const TestFixture *fixture = fix; + QDict *ret; + QList *val; + + ret = qmp_fd(fixture->fd, "{'execute': 'guest-get-users'}"); + g_assert_nonnull(ret); + qmp_assert_no_error(ret); + + /* There is not much to test here */ + val = qdict_get_qlist(ret, "return"); + g_assert_nonnull(val); + + QDECREF(ret); +} + static void test_qga_guest_get_osinfo(gconstpointer data) { TestFixture fixture; @@ -948,6 +996,12 @@ int main(int argc, char **argv) test_qga_guest_exec_invalid); g_test_add_data_func("/qga/guest-get-osinfo", &fix, test_qga_guest_get_osinfo); + g_test_add_data_func("/qga/guest-get-host-name", &fix, + test_qga_guest_get_host_name); + g_test_add_data_func("/qga/guest-get-timezone", &fix, + test_qga_guest_get_timezone); + g_test_add_data_func("/qga/guest-get-users", &fix, + test_qga_guest_get_users); ret = g_test_run();
These commands did not get their tests in the original commits: - guest-get-host-name - guest-get-timezone - guest-get-users Trivial tests that mostly only call the commands were added. Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com> --- tests/test-qga.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)