From: "Tomáš Golembiovský" <tgolembi@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: Eric Blake <eblake@redhat.com>,
Michael Roth <mdroth@linux.vnet.ibm.com>,
Vinzenz 'evilissimo' Feenstra <vfeenstr@redhat.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v6 3/3] test-qga: add test for guest-get-osinfo
Date: Mon, 3 Jul 2017 13:37:38 +0200 [thread overview]
Message-ID: <20170703133738.6e6bd346@fiorina> (raw)
In-Reply-To: <CAJ+F1CJdDYtPNZXNjs6cesKg1iL7mCEPgx01WSc3RPwL5CcZ6A@mail.gmail.com>
Uh, sorry. I will resend in a minute.
Tomas
On Fri, 30 Jun 2017 13:48:41 +0000
Marc-André Lureau <marcandre.lureau@gmail.com> wrote:
> Hi,
>
> It's missing test-qga-os-release :)
>
> On Thu, Jun 29, 2017 at 11:27 PM Tomáš Golembiovský <tgolembi@redhat.com>
> wrote:
>
> > Add test for guest-get-osinfo command.
> >
> > Qemu-ga was modified to accept QGA_OS_RELEASE environment variable. If
> > the variable is defined it is interpreted as path to the os-release file
> > and it is parsed instead of the default paths.
> >
> > Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
> > ---
> > qga/commands-posix.c | 13 ++++++++++---
> > tests/test-qga.c | 53
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 63 insertions(+), 3 deletions(-)
> >
> > diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> > index 2406518d47..f6ce8dd583 100644
> > --- a/qga/commands-posix.c
> > +++ b/qga/commands-posix.c
> > @@ -2683,9 +2683,16 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
> > info->kernel_release = g_strdup(kinfo.release);
> > info->machine_hardware = g_strdup(kinfo.machine);
> >
> > - GKeyFile *osrelease = ga_parse_osrelease("/etc/os-release");
> > - if (osrelease == NULL) {
> > - osrelease = ga_parse_osrelease("/usr/lib/os-release");
> > + GKeyFile *osrelease = NULL;
> > +
> > + const char *qga_os_release = g_getenv("QGA_OS_RELEASE");
> > + if (qga_os_release != NULL) {
> > + osrelease = ga_parse_osrelease(qga_os_release);
> > + } else {
> > + osrelease = ga_parse_osrelease("/etc/os-release");
> > + if (osrelease == NULL) {
> > + osrelease = ga_parse_osrelease("/usr/lib/os-release");
> > + }
> > }
> >
> > if (osrelease != NULL) {
> > diff --git a/tests/test-qga.c b/tests/test-qga.c
> > index 631b98639a..b9160708a0 100644
> > --- a/tests/test-qga.c
> > +++ b/tests/test-qga.c
> > @@ -936,6 +936,58 @@ static void test_qga_guest_exec_invalid(gconstpointer
> > fix)
> > QDECREF(ret);
> > }
> >
> > +static void test_qga_guest_get_osinfo(gconstpointer data)
> > +{
> > + TestFixture fixture;
> > + const gchar *str;
> > + gchar *cwd, *env[2];
> > + QDict *ret, *val;
> > +
> > + cwd = g_get_current_dir();
> > + env[0] =
> > g_strdup_printf("QGA_OS_RELEASE=%s%ctests%cdata%ctest-qga-os-release",
> > + cwd, G_DIR_SEPARATOR, G_DIR_SEPARATOR,
> > G_DIR_SEPARATOR);
> > + env[1] = NULL;
> > + g_free(cwd);
> > + fixture_setup(&fixture, NULL, env);
> > +
> > + ret = qmp_fd(fixture.fd, "{'execute': 'guest-get-osinfo'}");
> > + g_assert_nonnull(ret);
> > + qmp_assert_no_error(ret);
> > +
> > + val = qdict_get_qdict(ret, "return");
> > +
> > + str = qdict_get_try_str(val, "id");
> > + g_assert_nonnull(str);
> > + g_assert_cmpstr(str, ==, "qemu-ga-test");
> > +
> > + str = qdict_get_try_str(val, "name");
> > + g_assert_nonnull(str);
> > + g_assert_cmpstr(str, ==, "QEMU-GA");
> > +
> > + str = qdict_get_try_str(val, "pretty-name");
> > + g_assert_nonnull(str);
> > + g_assert_cmpstr(str, ==, "QEMU Guest Agent test");
> > +
> > + str = qdict_get_try_str(val, "version");
> > + g_assert_nonnull(str);
> > + g_assert_cmpstr(str, ==, "Test 1");
> > +
> > + str = qdict_get_try_str(val, "version-id");
> > + g_assert_nonnull(str);
> > + g_assert_cmpstr(str, ==, "1");
> > +
> > + str = qdict_get_try_str(val, "variant");
> > + g_assert_nonnull(str);
> > + g_assert_cmpstr(str, ==, "Unit test \"'$`\\ and \\\\ etc.");
> > +
> > + str = qdict_get_try_str(val, "variant-id");
> > + g_assert_nonnull(str);
> > + g_assert_cmpstr(str, ==, "unit-test");
> > +
> > + QDECREF(ret);
> > + g_free(env[0]);
> > +}
> > +
> > int main(int argc, char **argv)
> > {
> > TestFixture fix;
> > @@ -972,6 +1024,7 @@ int main(int argc, char **argv)
> > 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);
> > + g_test_add_data_func("/qga/guest-get-osinfo", &fix,
> > test_qga_guest_get_osinfo);
> >
> > if (g_getenv("QGA_TEST_SIDE_EFFECTING")) {
> > g_test_add_data_func("/qga/fsfreeze-and-thaw", &fix,
> > --
> > 2.13.1
> >
> > --
> Marc-André Lureau
--
Tomáš Golembiovský <tgolembi@redhat.com>
prev parent reply other threads:[~2017-07-03 11:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-29 21:27 [Qemu-devel] [PATCH v6 0/3] qemu-ga: add guest-get-osinfo command Tomáš Golembiovský
2017-06-29 21:27 ` [Qemu-devel] [PATCH v6 1/3] " Tomáš Golembiovský
2017-06-29 21:27 ` [Qemu-devel] [PATCH v6 2/3] test-qga: pass environemnt to qemu-ga Tomáš Golembiovský
2017-06-29 21:27 ` [Qemu-devel] [PATCH v6 3/3] test-qga: add test for guest-get-osinfo Tomáš Golembiovský
2017-06-30 13:48 ` Marc-André Lureau
2017-07-03 11:37 ` Tomáš Golembiovský [this message]
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=20170703133738.6e6bd346@fiorina \
--to=tgolembi@redhat.com \
--cc=eblake@redhat.com \
--cc=marcandre.lureau@gmail.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=vfeenstr@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).