From patchwork Fri Jun 29 15:34:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 168237 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 72822B6FA0 for ; Sat, 30 Jun 2012 03:53:02 +1000 (EST) Received: from localhost ([::1]:35628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkdER-0003FI-Ls for incoming@patchwork.ozlabs.org; Fri, 29 Jun 2012 11:35:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkdDu-0002gV-SM for qemu-devel@nongnu.org; Fri, 29 Jun 2012 11:35:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SkdDo-0005Mn-Es for qemu-devel@nongnu.org; Fri, 29 Jun 2012 11:35:06 -0400 Received: from oxygen.pond.sub.org ([78.46.104.156]:41235) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkdDo-0005M5-8g for qemu-devel@nongnu.org; Fri, 29 Jun 2012 11:35:00 -0400 Received: from blackfin.pond.sub.org (p5B3298A7.dip.t-dialin.net [91.50.152.167]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 45B68A5A57; Fri, 29 Jun 2012 17:34:58 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 9403F600A2; Fri, 29 Jun 2012 17:34:54 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2012 17:34:27 +0200 Message-Id: <1340984094-5451-6-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.6.5 In-Reply-To: <1340984094-5451-1-git-send-email-armbru@redhat.com> References: <1340984094-5451-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 78.46.104.156 Cc: kwolf@redhat.com, pbonzini@redhat.com, aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 05/32] qtest: Tidy up temporary files properly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Each test litters /tmp with several files: a pid file and two sockets. Tidy up. Signed-off-by: Markus Armbruster --- tests/libqtest.c | 29 ++++++++++++++++------------- 1 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 071b6be..02d0392 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -40,6 +40,7 @@ struct QTestState bool irq_level[MAX_IRQ]; GString *rx; gchar *pid_file; + char *socket_path, *qmp_socket_path; }; #define g_assert_no_errno(ret) do { \ @@ -88,8 +89,6 @@ QTestState *qtest_init(const char *extra_args) { QTestState *s; int sock, qmpsock, ret, i; - gchar *socket_path; - gchar *qmp_socket_path; gchar *pid_file; gchar *command; const char *qemu_binary; @@ -98,14 +97,14 @@ QTestState *qtest_init(const char *extra_args) qemu_binary = getenv("QTEST_QEMU_BINARY"); g_assert(qemu_binary != NULL); - socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid()); - qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid()); - pid_file = g_strdup_printf("/tmp/qtest-%d.pid", getpid()); - s = g_malloc(sizeof(*s)); - sock = init_socket(socket_path); - qmpsock = init_socket(qmp_socket_path); + s->socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid()); + s->qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid()); + pid_file = g_strdup_printf("/tmp/qtest-%d.pid", getpid()); + + sock = init_socket(s->socket_path); + qmpsock = init_socket(s->qmp_socket_path); pid = fork(); if (pid == 0) { @@ -115,8 +114,8 @@ QTestState *qtest_init(const char *extra_args) "-qmp unix:%s,nowait " "-pidfile %s " "-machine accel=qtest " - "%s", qemu_binary, socket_path, - qmp_socket_path, pid_file, + "%s", qemu_binary, s->socket_path, + s->qmp_socket_path, pid_file, extra_args ?: ""); ret = system(command); @@ -133,9 +132,6 @@ QTestState *qtest_init(const char *extra_args) s->irq_level[i] = false; } - g_free(socket_path); - g_free(qmp_socket_path); - /* Read the QMP greeting and then do the handshake */ qtest_qmp(s, ""); qtest_qmp(s, "{ 'execute': 'qmp_capabilities' }"); @@ -160,6 +156,13 @@ void qtest_quit(QTestState *s) fclose(f); } + + unlink(s->pid_file); + unlink(s->socket_path); + unlink(s->qmp_socket_path); + g_free(s->pid_file); + g_free(s->socket_path); + g_free(s->qmp_socket_path); } static void socket_sendf(int fd, const char *fmt, va_list ap)