From nobody Wed Nov 5 00:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1532371758907767.6177825438699; Mon, 23 Jul 2018 11:49:18 -0700 (PDT) Received: from localhost ([::1]:36056 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhftM-0002uG-5P for importer@patchew.org; Mon, 23 Jul 2018 14:49:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhfsE-0002bB-Tw for qemu-devel@nongnu.org; Mon, 23 Jul 2018 14:47:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhfsD-0007pb-Vt for qemu-devel@nongnu.org; Mon, 23 Jul 2018 14:47:58 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:43694) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fhfsD-0007pA-Nr for qemu-devel@nongnu.org; Mon, 23 Jul 2018 14:47:57 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1fhfs9-0007qC-Dh; Mon, 23 Jul 2018 19:47:53 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 19:47:52 +0100 Message-Id: <20180723184752.22150-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH for-3.0] tests/libqtest: Improve kill_qemu() assert X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S . Tsirkin" , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , patches@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In kill_qemu() we have an assert that checks that the QEMU process didn't dump core: assert(!WCOREDUMP(wstatus)); Unfortunately the WCOREDUMP macro here means the resulting message is not very easy to comprehend on at least some systems: ahci-test: tests/libqtest.c:113: kill_qemu: Assertion `!(((__extension__ ((= (union { __typeof(wstatus) __in; int __i; }) { .__in =3D (wstatus) }).__i))= ) & 0x80)' failed. and it doesn't identify what signal the process took. Instead of using a raw assert, print the information in an easier to understand way: /i386/ahci/sanity: tests/libqtest.c:119: kill_qemu() tried to terminate QEM= U process but it dumped core with signal 11 (Segmentation fault) Aborted (core dumped) (Of course, the really useful information would be why the QEMU process dumped core in the first place, but we don't have that by the time the test program has picked up the exit status.) Signed-off-by: Peter Maydell --- changes v1->v2: addressed some of the bikeshedding with: * print file-and-line in the fprintf message, and then just abort(), rather than assert(0) * print the signal name via strsignal() as well tests/libqtest.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 098af6aec44..bfc86a15f4b 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -110,7 +110,16 @@ static void kill_qemu(QTestState *s) pid =3D waitpid(s->qemu_pid, &wstatus, 0); =20 if (pid =3D=3D s->qemu_pid && WIFSIGNALED(wstatus)) { - assert(!WCOREDUMP(wstatus)); + if (WCOREDUMP(wstatus)) { + int sig =3D WTERMSIG(wstatus); + const char *signame =3D strsignal(sig) ?: "unknown ???"; + + fprintf(stderr, + "%s:%d: kill_qemu() tried to terminate QEMU " + "process but it dumped core with signal %d (%s)\n", + __FILE__, __LINE__, sig, signame); + abort(); + } } } } --=20 2.17.1