From patchwork Thu Apr 23 17:05:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 185740 Delivered-To: patch@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp2302600ilf; Thu, 23 Apr 2020 10:14:14 -0700 (PDT) X-Google-Smtp-Source: APiQypJKXt2f2IMIOfM6k0XEGHNgBpX7XzfA0tL6CKzE93KPeEa8+cb075mUz/Et2tlioUTIxLFP X-Received: by 2002:a0c:ac41:: with SMTP id m1mr5238244qvb.71.1587662054344; Thu, 23 Apr 2020 10:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587662054; cv=none; d=google.com; s=arc-20160816; b=gKB6Fc6UtdUzoxVT5S5xerHu59eMTax52C0VxETbrPjAXx4KyCgP6nUfHJNr7fowFN R9hYOHegENMFnauGHB2Q3Fm+fnGb7afxfOcLy1wc+6LoDL3ny/m8WfNLUUua2n/NsEVG 0UEye92g2FkpjHPfq/9yJ05XfBaKEf/bGb4UDKfTFL3lUQQd3F5HWU7yoL+7gPdBptDn 5FghcOuXLWmjflvi7ZIRoQzTkVAcQMrnrPIAYG9p8V13jc+h4LByhNNyaWsFB2EIeM9S 4T/l0l0tYFeCKYg9QE7HxsLbCMb0kZM/5UfB2xTr4vbYdxFWOnOCTDoFCQPYaewDiwfN L7TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=67oQwpEs2PvLm/27/7hAV2hnOAJBQY7TkPiq2zfh6Fw=; b=rzf7GMb4cPdE2lPUfWO8LstJ+rgIuOwwtLpuplhGz5z5tm2QkyGhbOOntu/BSmhIGO hdjiVnAqnSl0nUCzDf4cYTXOkHgeH5oL9CMDnpEbEax/Hn0F6x0K1jYAFTIlYemlPtBk 1Fx+x0OP66RBYv9gf/zrK7d2SfyO7s1yEIwgATu5UyLKHsR1p3hvmLtr5RZrdmRT24Dp fczt3G0wG+IhtwxCqva3cLLOMoGsaUOsQNbwwtY3NdOMYsfRcxGocWrTKqC3bk+gSRn0 VuUEP66emp/i4RLEwlWqOGUFM67jcndheV2FVDB5+t2PJtz8AV1a3YgJa1HV8b+oEUdV eMFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=brad7Rq2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z17si1721047qtv.48.2020.04.23.10.14.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Apr 2020 10:14:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=brad7Rq2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:32994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRfQT-0001YM-Px for patch@linaro.org; Thu, 23 Apr 2020 13:14:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44712) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRfIp-0001Ry-1a for qemu-devel@nongnu.org; Thu, 23 Apr 2020 13:06:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRfIo-0005f7-5l for qemu-devel@nongnu.org; Thu, 23 Apr 2020 13:06:18 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:37935) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jRfIn-0005cr-OR for qemu-devel@nongnu.org; Thu, 23 Apr 2020 13:06:17 -0400 Received: by mail-wm1-x343.google.com with SMTP id g12so7333261wmh.3 for ; Thu, 23 Apr 2020 10:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=67oQwpEs2PvLm/27/7hAV2hnOAJBQY7TkPiq2zfh6Fw=; b=brad7Rq2sbjxkQJ7dfaw01wkBgXa0jBPIMo/EVMbjnVrcLk1SDk7BUy4E8L1/D0WPg 3Cnfuw+DiiaijgZBK0hJnGzuHfUde0u3TMArRWizTB5UX4MMghPfGzWg0YJtCz2VREsc iJzi/8k7f7vcvGE7XPlVCEVc8a76bVaprCtfWS/tqqHBODiUl271q5T3y+APjhZtQGmr Q6DbPskYNaLtFfGVvA4DzMD+O3cRTkE/wz9nitkbR5BgMahZVYDI0/IRLnU7+dQ+lWi9 PfcIIMUQwKSovNeihWUbaOtD493KAODS8MUwPkSDiW4mLP/sBjG9805NWuN7vTYuhMHF LD5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=67oQwpEs2PvLm/27/7hAV2hnOAJBQY7TkPiq2zfh6Fw=; b=szVotpU2QY6pNfI5mvNMAEGECVViSAFENH0tbo4C2WsDPTUorUyb/A7TbisUo5Xjq2 +pC/hX0suvF0hDe45w4m0Meoq9Y81eW1ix4023LwIsKlxpNSxVD5HcET8dbVqYqFeRde AKomXG5VPx4vmZ1JBp+obv5Cqwuh57OccfrJC7ULiXmlIsjYxMgNQdKdNItgyBjrppI6 bWlZV5mXqr7kjT7Gb+X69eoRln50gZAVgr7Nw6I/xH+Rqpi/2AiL9fg/BlXQwomIgoMU 4Iw7kfNwufPbnClw2G/HIMoMrFOa+0MygdWEu13V1O7P0fWPtYcN/VBNEkC5M/BS4G5t LKYQ== X-Gm-Message-State: AGi0PubmvbYph1KiW/bdwwB5r/ryvxOI/r2rYdtG2G355eCR2z/tRkdp nvyupBFpvIlfQjO6wnKg7Kivbw== X-Received: by 2002:a1c:5403:: with SMTP id i3mr5477209wmb.10.1587661576163; Thu, 23 Apr 2020 10:06:16 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id t17sm4188958wro.2.2020.04.23.10.06.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Apr 2020 10:06:05 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 68FF51FF9B; Thu, 23 Apr 2020 18:05:58 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 12/14] tests/tcg: add a multiarch linux-user gdb test Date: Thu, 23 Apr 2020 18:05:55 +0100 Message-Id: <20200423170557.31106-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200423170557.31106-1-alex.bennee@linaro.org> References: <20200423170557.31106-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x343.google.com X-detected-operating-system: by eggs.gnu.org: Error: [-] PROGRAM ABORT : Malformed IPv6 address (bad octet value). Location : parse_addr6(), p0f-client.c:67 X-Received-From: 2a00:1450:4864:20::343 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , "open list:ARM TCG CPUs" , =?utf-8?q?Alex_Benn=C3=A9e?= , "Edgar E. Iglesias" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When the gdbstub code was converted to the new API we missed a few snafus in the various guests. Add a simple gdb test script which can be used on all our linux-user guests to check for obvious failures. Signed-off-by: Alex Bennée --- v2 - use EXTRA_RUNS to queue the tests so as not to break plugins --- tests/tcg/aarch64/Makefile.target | 5 +- tests/tcg/cris/Makefile.target | 1 + tests/tcg/multiarch/Makefile.target | 14 +++++ tests/tcg/multiarch/gdbstub/sha1.py | 81 +++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 tests/tcg/multiarch/gdbstub/sha1.py -- 2.20.1 diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target index d99b2a9ece..312f36cde5 100644 --- a/tests/tcg/aarch64/Makefile.target +++ b/tests/tcg/aarch64/Makefile.target @@ -54,9 +54,6 @@ sve-ioctls: CFLAGS+=-march=armv8.1-a+sve ifneq ($(HAVE_GDB_BIN),) GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py -AARCH64_TESTS += gdbstub-sysregs gdbstub-sve-ioctls - -.PHONY: gdbstub-sysregs gdbstub-sve-ioctls run-gdbstub-sysregs: sysregs $(call run-test, $@, $(GDB_SCRIPT) \ --gdb $(HAVE_GDB_BIN) \ @@ -70,6 +67,8 @@ run-gdbstub-sve-ioctls: sve-ioctls --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ --bin $< --test $(AARCH64_SRC)/gdbstub/test-sve-ioctl.py, \ "basic gdbstub SVE ZLEN support") + +EXTRA_RUNS += run-gdbstub-sysregs run-gdbstub-sve-ioctls endif endif diff --git a/tests/tcg/cris/Makefile.target b/tests/tcg/cris/Makefile.target index 24c7f2e761..e72d3cbdb2 100644 --- a/tests/tcg/cris/Makefile.target +++ b/tests/tcg/cris/Makefile.target @@ -23,6 +23,7 @@ CRIS_RUNS = $(patsubst %, run-%, $(CRIS_USABLE_TESTS)) # override the list of tests, as we can't build the multiarch tests TESTS = $(CRIS_USABLE_TESTS) +EXTRA_RUNS = VPATH = $(CRIS_SRC) AS = $(CC) -x assembler-with-cpp diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index 035b09c853..51fb75ecfd 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -42,5 +42,19 @@ run-test-mmap-%: test-mmap $(call run-test, test-mmap-$*, $(QEMU) -p $* $<,\ "$< ($* byte pages) on $(TARGET_NAME)") +ifneq ($(HAVE_GDB_BIN),) +GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py + +run-gdbstub-sha1: sha1 + $(call run-test, $@, $(GDB_SCRIPT) \ + --gdb $(HAVE_GDB_BIN) \ + --qemu $(QEMU) --qargs "$(QEMU_OPTS)" \ + --bin $< --test $(MULTIARCH_SRC)/gdbstub/sha1.py, \ + "basic gdbstub support") + +EXTRA_RUNS += run-gdbstub-sha1 +endif + + # Update TESTS TESTS += $(MULTIARCH_TESTS) diff --git a/tests/tcg/multiarch/gdbstub/sha1.py b/tests/tcg/multiarch/gdbstub/sha1.py new file mode 100644 index 0000000000..734553b98b --- /dev/null +++ b/tests/tcg/multiarch/gdbstub/sha1.py @@ -0,0 +1,81 @@ +from __future__ import print_function +# +# A very simple smoke test for debugging the SHA1 userspace test on +# each target. +# +# This is launched via tests/guest-debug/run-test.py +# + +import gdb +import sys + +initial_vlen = 0 +failcount = 0 + +def report(cond, msg): + "Report success/fail of test" + if cond: + print("PASS: %s" % (msg)) + else: + print("FAIL: %s" % (msg)) + global failcount + failcount += 1 + +def check_break(sym_name): + "Setup breakpoint, continue and check we stopped." + sym, ok = gdb.lookup_symbol(sym_name) + bp = gdb.Breakpoint(sym_name) + + gdb.execute("c") + + # hopefully we came back + end_pc = gdb.parse_and_eval('$pc') + report(bp.hit_count == 1, + "break @ %s (%s %d hits)" % (end_pc, sym.value(), bp.hit_count)) + + bp.delete() + +def run_test(): + "Run through the tests one by one" + + check_break("SHA1Init") + + # check step and inspect values + gdb.execute("next") + val_ctx = gdb.parse_and_eval("context->state[0]") + exp_ctx = 0x67452301 + report(int(val_ctx) == exp_ctx, "context->state[0] == %x" % exp_ctx); + + gdb.execute("next") + val_ctx = gdb.parse_and_eval("context->state[1]") + exp_ctx = 0xEFCDAB89 + report(int(val_ctx) == exp_ctx, "context->state[1] == %x" % exp_ctx); + + # finally check we don't barf inspecting registers + gdb.execute("info registers") + +# +# This runs as the script it sourced (via -x, via run-test.py) +# +try: + inferior = gdb.selected_inferior() + arch = inferior.architecture() + print("ATTACHED: %s" % arch.name()) +except (gdb.error, AttributeError): + print("SKIPPING (not connected)", file=sys.stderr) + exit(0) + +try: + # These are not very useful in scripts + gdb.execute("set pagination off") + gdb.execute("set confirm off") + + # Run the actual tests + run_test() +except (gdb.error): + print ("GDB Exception: %s" % (sys.exc_info()[0])) + failcount += 1 + pass + +print("All tests complete: %d failures" % failcount) +exit(failcount)