{"id":806502,"url":"http://patchwork.ozlabs.org/api/1.0/patches/806502/?format=json","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.0/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<1503916557-1292-1-git-send-email-thuth@redhat.com>","date":"2017-08-28T10:35:57","name":"tests/libqtest: Use a proper error message if QTEST_QEMU_BINARY is missing","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"3e683880fb286ad1d838e71d49a89eebb300d9af","submitter":{"id":66152,"url":"http://patchwork.ozlabs.org/api/1.0/people/66152/?format=json","name":"Thomas Huth","email":"thuth@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1503916557-1292-1-git-send-email-thuth@redhat.com/mbox/","series":[{"id":129,"url":"http://patchwork.ozlabs.org/api/1.0/series/129/?format=json","date":"2017-08-28T10:35:57","name":"tests/libqtest: Use a proper error message if QTEST_QEMU_BINARY is missing","version":1,"mbox":"http://patchwork.ozlabs.org/series/129/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/806502/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=thuth@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xgpBF523bz9s8J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 28 Aug 2017 20:37:41 +1000 (AEST)","from localhost ([::1]:38981 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dmHQJ-0001uC-Kk\n\tfor incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 06:37:39 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:48541)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1dmHOm-00019f-Qr\n\tfor qemu-devel@nongnu.org; Mon, 28 Aug 2017 06:36:08 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1dmHOj-0001yT-Jy\n\tfor qemu-devel@nongnu.org; Mon, 28 Aug 2017 06:36:04 -0400","from mx1.redhat.com ([209.132.183.28]:40484)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <thuth@redhat.com>)\n\tid 1dmHOj-0001wZ-EE; Mon, 28 Aug 2017 06:36:01 -0400","from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 3BCEA4A6E8;\n\tMon, 28 Aug 2017 10:36:00 +0000 (UTC)","from thh440s.redhat.com (ovpn-116-110.ams2.redhat.com\n\t[10.36.116.110])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id F1DE97F494;\n\tMon, 28 Aug 2017 10:35:58 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 3BCEA4A6E8","From":"Thomas Huth <thuth@redhat.com>","To":"qemu-devel@nongnu.org,\n\tqemu-trivial@nongnu.org","Date":"Mon, 28 Aug 2017 12:35:57 +0200","Message-Id":"<1503916557-1292-1-git-send-email-thuth@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.15","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tMon, 28 Aug 2017 10:36:00 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"[Qemu-devel] [PATCH] tests/libqtest: Use a proper error message if\n\tQTEST_QEMU_BINARY is missing","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Markus Armbruster <armbru@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"The user can currently still cause an abort() if running certain tests\n(like the prom-env-test) without setting the QTEST_QEMU_BINARY first.\nA similar problem has been fixed with commit 7c933ad61b8f3f51337\nalready, but forgot to also take care of the qtest_get_arch() function,\nso let's introduce a proper wrapper around getenv(\"QTEST_QEMU_BINARY\")\nthat can be used in both locations now.\n\nBuglink: https://bugs.launchpad.net/qemu/+bug/1713434\nSigned-off-by: Thomas Huth <thuth@redhat.com>\n---\n tests/libqtest.c | 24 +++++++++++++++---------\n 1 file changed, 15 insertions(+), 9 deletions(-)","diff":"diff --git a/tests/libqtest.c b/tests/libqtest.c\nindex b9a1f18..342a77b 100644\n--- a/tests/libqtest.c\n+++ b/tests/libqtest.c\n@@ -150,6 +150,19 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *data)\n     g_hook_prepend(&abrt_hooks, hook);\n }\n \n+static const char *qtest_qemu_binary(void)\n+{\n+    const char *qemu_bin;\n+\n+    qemu_bin = getenv(\"QTEST_QEMU_BINARY\");\n+    if (!qemu_bin) {\n+        fprintf(stderr, \"Environment variable QTEST_QEMU_BINARY required\\n\");\n+        exit(1);\n+    }\n+\n+    return qemu_bin;\n+}\n+\n QTestState *qtest_init_without_qmp_handshake(const char *extra_args)\n {\n     QTestState *s;\n@@ -157,13 +170,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)\n     gchar *socket_path;\n     gchar *qmp_socket_path;\n     gchar *command;\n-    const char *qemu_binary;\n-\n-    qemu_binary = getenv(\"QTEST_QEMU_BINARY\");\n-    if (!qemu_binary) {\n-        fprintf(stderr, \"Environment variable QTEST_QEMU_BINARY required\\n\");\n-        exit(1);\n-    }\n+    const char *qemu_binary = qtest_qemu_binary();\n \n     s = g_malloc(sizeof(*s));\n \n@@ -624,8 +631,7 @@ char *qtest_hmp(QTestState *s, const char *fmt, ...)\n \n const char *qtest_get_arch(void)\n {\n-    const char *qemu = getenv(\"QTEST_QEMU_BINARY\");\n-    g_assert(qemu != NULL);\n+    const char *qemu = qtest_qemu_binary();\n     const char *end = strrchr(qemu, '/');\n \n     return end + strlen(\"/qemu-system-\");\n","prefixes":[]}