qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: qemu-devel@nongnu.org, Adam Litke <agl@us.ibm.com>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Avi Kivity <avi@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 14/15] qapi: add test-libqmp
Date: Sat, 12 Mar 2011 08:59:28 -0600	[thread overview]
Message-ID: <4D7B8A50.5020303@codemonkey.ws> (raw)
In-Reply-To: <AANLkTimhUjRT2h0grqoUOTiJfp6RZoPv-40uTgU7A8wM@mail.gmail.com>

On 03/12/2011 05:23 AM, Blue Swirl wrote:
> On Sat, Mar 12, 2011 at 1:05 AM, Anthony Liguori<aliguori@us.ibm.com>  wrote:
>> This provides a glib-test based testing framework for QMP
>>
>> Signed-off-by: Anthony Liguori<aliguori@us.ibm.com>
>>
>> diff --git a/Makefile b/Makefile
>> index 5170675..1d363d7 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -72,6 +72,8 @@ defconfig:
>>
>>   -include config-all-devices.mak
>>
>> +TOOLS += test-libqmp
>> +
>>   build-all: $(DOCS) $(TOOLS) recurse-all
>>
>>   config-host.h: config-host.h-timestamp
>> @@ -205,6 +207,15 @@ check-qlist: check-qlist.o qlist.o qint.o $(CHECK_PROG_DEPS)
>>   check-qfloat: check-qfloat.o qfloat.o $(CHECK_PROG_DEPS)
>>   check-qjson: check-qjson.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o qjson.o json-streamer.o json-lexer.o json-parser.o $(CHECK_PROG_DEPS)
>>
>> +LIBQMP_OBJS := qmp-types.o libqmp.o error.o libqmp-core.o
>> +LIBQMP_OBJS += qmp-marshal-types-core.o qmp-marshal-types.o
>> +LIBQMP_OBJS += qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o qjson.o
>> +LIBQMP_OBJS += qerror.o
>> +LIBQMP_OBJS += json-streamer.o json-lexer.o json-parser.o
>> +LIBQMP_OBJS += $(oslib-obj-y) $(trace-obj-y) qemu-malloc.o
>> +
>> +test-libqmp: test-libqmp.o $(LIBQMP_OBJS) qemu-timer-common.o
>> +
>>   clean:
>>   # avoid old build problems by removing potentially incorrect old files
>>         rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
>> diff --git a/test-libqmp.c b/test-libqmp.c
>> new file mode 100644
> I'd put this to tests/.

tests/ lives outside of the QEMU build system today.  It's also very TCG 
specific.

How about taking the current contents of tests/ and moving it to 
tests/tcg and moving test-libqmp and check-*.c to tests/?

>> index 0000000..9b73987
>> --- /dev/null
>> +++ b/test-libqmp.c
>> @@ -0,0 +1,170 @@
>> +/*
>> + * QAPI
>> + *
>> + * Copyright IBM, Corp. 2011
>> + *
>> + * Authors:
>> + *  Anthony Liguori<aliguori@us.ibm.com>
>> + *
>> + * This work is licensed under the terms of the GNU LGPL, version 2.  See
>> + * the COPYING.LIB file in the top-level directory.
>> + */
>> +#include<stdio.h>
>> +#include<sys/socket.h>
>> +#include<netinet/in.h>
>> +#include<netinet/tcp.h>
>> +#include<arpa/inet.h>
>> +#include<sys/un.h>
>> +#include<stdlib.h>
>> +#include<glib.h>
>> +#include<sys/wait.h>
>> +#include "config-host.h"
>> +#include "libqmp.h"
>> +#include "qerror.h"
>> +
>> +#define g_assert_noerr(err) g_assert(err == NULL);
>> +#define g_assert_anyerr(err) g_assert(err != NULL);
>> +#define g_assert_cmperr(err, op, type) do {                   \
>> +    g_assert_anyerr(err);                                        \
>> +    g_assert_cmpstr(error_get_field(err, "class"), op, type); \
>> +} while (0)
>> +
>> +static pid_t last_qemu_pid = -1;
>> +
>> +static QmpSession *qemu(const char *fmt, ...)
>> +{
>> +    char buffer0[4096];
>> +    char buffer1[4096];
>> +    const char *pid_filename = "/tmp/test-libqmp-qemu.pid";
>> +    const char *path = "/tmp/test-libqmp-qemu.sock";
> Very insecure filenames.

This disappears in round 3 when I introduce discovery support in libqmp.

Even so, I don't think security is a major concern here.

>> +static void wait_for_pid_exit(pid_t pid)
>> +{
>> +    FILE *f = NULL;
>> +
>> +    /* This is ugly but I don't know of a better way */
> man waitpid?

waitpid only works for child processes.  Since we launch with 
-daemonize, that the QEMU instance is no longer a child process.

We use -daemonize because it avoids the race condition where we try to 
connect to a QMP socket but QEMU hasn't created the socket yet.  It also 
means that we can just use system() to invoke QEMU which makes life a 
whole lot simpler.

Regards,

Anthony Liguori

  reply	other threads:[~2011-03-12 14:59 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-11 23:05 [Qemu-devel] [PATCH 00/15] QAPI Round 1 (core code generator) (v2) Anthony Liguori
2011-03-11 23:05 ` [Qemu-devel] [PATCH 01/15] qapi: add code generator for qmp-types (v2) Anthony Liguori
2011-03-11 23:12   ` [Qemu-devel] " Anthony Liguori
2011-03-12 11:29   ` [Qemu-devel] " Blue Swirl
2011-03-12 15:00     ` Anthony Liguori
2011-03-18 14:18       ` Luiz Capitulino
2011-03-18 14:14   ` [Qemu-devel] " Luiz Capitulino
2011-03-11 23:05 ` [Qemu-devel] [PATCH 02/15] qapi: add code generator for type marshallers Anthony Liguori
2011-03-18 15:13   ` [Qemu-devel] " Luiz Capitulino
2011-03-11 23:05 ` [Qemu-devel] [PATCH 03/15] qapi: add core QMP server support (v2) Anthony Liguori
2011-03-11 23:05 ` [Qemu-devel] [PATCH 04/15] qapi: add signal support to core QMP server Anthony Liguori
2011-03-11 23:05 ` [Qemu-devel] [PATCH 05/15] qapi: add QAPI module type Anthony Liguori
2011-03-11 23:05 ` [Qemu-devel] [PATCH 06/15] qapi: add code generators for QMP command marshaling Anthony Liguori
2011-03-11 23:05 ` [Qemu-devel] [PATCH 07/15] qapi: add query-version QMP command Anthony Liguori
2011-03-12 11:19   ` Blue Swirl
2011-03-12 15:06     ` Anthony Liguori
2011-03-11 23:05 ` [Qemu-devel] [PATCH 08/15] qapi: add new QMP server that uses CharDriverState (v2) Anthony Liguori
2011-03-11 23:05 ` [Qemu-devel] [PATCH 09/15] vl: add a new -qmp2 option to expose experimental QMP server Anthony Liguori
2011-03-11 23:14   ` [Qemu-devel] " Anthony Liguori
2011-03-11 23:05 ` [Qemu-devel] [PATCH 10/15] qapi: add QMP quit command Anthony Liguori
2011-03-11 23:05 ` [Qemu-devel] [PATCH 11/15] qapi: add QMP qmp_capabilities command Anthony Liguori
2011-03-11 23:05 ` [Qemu-devel] [PATCH 12/15] qapi: add QMP put-event command Anthony Liguori
2011-03-11 23:05 ` [Qemu-devel] [PATCH 13/15] qapi: add code generator for libqmp (v2) Anthony Liguori
2011-03-12 11:10   ` Blue Swirl
2011-03-12 14:53     ` Anthony Liguori
2011-03-11 23:05 ` [Qemu-devel] [PATCH 14/15] qapi: add test-libqmp Anthony Liguori
2011-03-12 11:23   ` Blue Swirl
2011-03-12 14:59     ` Anthony Liguori [this message]
2011-03-11 23:05 ` [Qemu-devel] [PATCH 15/15] qapi: generate HTML report for test-libqmp Anthony Liguori
2011-03-16 14:34 ` [Qemu-devel] Re: [PATCH 00/15] QAPI Round 1 (core code generator) (v2) Luiz Capitulino
2011-03-16 14:49   ` Paolo Bonzini
2011-03-16 15:00     ` Luiz Capitulino
2011-03-16 16:06       ` Anthony Liguori
2011-03-16 16:03     ` Anthony Liguori
2011-03-16 16:31       ` Paolo Bonzini
2011-03-16 18:06         ` Anthony Liguori
2011-03-16 15:59   ` Anthony Liguori
2011-03-16 18:09     ` Luiz Capitulino
2011-03-16 18:32       ` Anthony Liguori
2011-03-16 19:27         ` Luiz Capitulino
2011-03-16 20:00           ` Anthony Liguori
2011-03-18 14:10             ` Luiz Capitulino
2011-03-18 14:22               ` Anthony Liguori
2011-03-17 12:21     ` Kevin Wolf
2011-03-17 12:46       ` Anthony Liguori
2011-03-17 13:15         ` Kevin Wolf
2011-03-17 13:28           ` Anthony Liguori
2011-03-17 14:04             ` Kevin Wolf
2011-03-17 15:49               ` Anthony Liguori

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=4D7B8A50.5020303@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=agl@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=lcapitulino@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).