From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:39519) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RnY5U-0004XO-5e for qemu-devel@nongnu.org; Wed, 18 Jan 2012 11:10:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RnY5S-0000ak-Iw for qemu-devel@nongnu.org; Wed, 18 Jan 2012 11:10:12 -0500 Received: from e39.co.us.ibm.com ([32.97.110.160]:51059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RnY5S-0000aS-B6 for qemu-devel@nongnu.org; Wed, 18 Jan 2012 11:10:10 -0500 Received: from /spool/local by e39.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Jan 2012 09:10:07 -0700 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 7429C3E401FD for ; Wed, 18 Jan 2012 09:08:50 -0700 (MST) Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0IG8kVs266620 for ; Wed, 18 Jan 2012 11:08:47 -0500 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0IG8dmD006239 for ; Wed, 18 Jan 2012 09:08:39 -0700 Message-ID: <4F16EE89.4000006@us.ibm.com> Date: Wed, 18 Jan 2012 10:08:41 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <1326479558-3016-1-git-send-email-aliguori@us.ibm.com> <1326479558-3016-3-git-send-email-aliguori@us.ibm.com> <4F16EC9F.9020503@redhat.com> In-Reply-To: <4F16EC9F.9020503@redhat.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 3/6] qtest: add C version of test infrastructure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Paolo Bonzini , qemu-devel@nongnu.org, Stefan Hajnoczi On 01/18/2012 10:00 AM, Kevin Wolf wrote: > Am 13.01.2012 19:32, schrieb Anthony Liguori: >> This also includes a qtest wrapper script to make it easier to launch qtest >> tests directly. >> >> Signed-off-by: Anthony Liguori > >> +QTestState *qtest_init(const char *extra_args) >> +{ >> + QTestState *s; >> + struct sockaddr_un addr; >> + int sock, ret, i; >> + gchar *socket_path; >> + gchar *pid_file; >> + gchar *command; >> + const char *qemu_binary; >> + pid_t pid; >> + >> + qemu_binary = getenv("QTEST_QEMU_BINARY"); >> + g_assert(qemu_binary != NULL); >> + >> + socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid()); >> + pid_file = g_strdup_printf("/tmp/qtest-%d.pid", getpid()); >> + >> + s = g_malloc(sizeof(*s)); >> + >> + sock = socket(PF_UNIX, SOCK_STREAM, 0); >> + g_assert_no_errno(sock); >> + >> + addr.sun_family = AF_UNIX; >> + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", socket_path); >> + >> + pid = fork(); >> + if (pid == 0) { >> + command = g_strdup_printf("%s " >> + "-qtest unix:%s,server,nowait " >> + "-qtest-log /dev/null " >> + "-pidfile %s " >> + "-machine accel=qtest " >> + "%s", qemu_binary, socket_path, >> + pid_file, >> + extra_args ?: ""); >> + >> + ret = system(command); >> + exit(ret); >> + g_free(command); >> + } >> + >> + do { >> + sleep(1); > > This is the line that takes the greatest part of the time for make > check-qtest. Can we use some shorter delay if it's required at all? Ah, good catch. It should change to a usleep(). It is needed, you can't guarantee that qemu is listening yet on the sockets when you try to connect. Regards, Anthony Liguori > >> + ret = connect(sock, (struct sockaddr *)&addr, sizeof(addr)); >> + } while (ret == -1); >> + g_assert_no_errno(ret); >> + >> + s->fd = sock; >> + s->rx = g_string_new(""); >> + s->pid_file = pid_file; >> + for (i = 0; i< MAX_IRQ; i++) { >> + s->irq_level[i] = false; >> + } >> + >> + g_free(socket_path); >> + >> + return s; >> +} > > Kevin >