From nobody Tue Nov 26 16:29:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1706199031; cv=none; d=zohomail.com; s=zohoarc; b=ISs4rIEiFBrHlOeZJg8P6hOK5qVbQ9xwb+C0FkvOvEdcBOSEVIuAgVHOodkYX9xrFZ09ADdfSHIxB9Or9EQqEqnv/C4cnIUETdIGWUDpGCv0iQ2UUQtyedN2OECNo9U64E9jzbTqJHFG3Gp8QsQQxH0L6hitsORWf3Zl+0ACZ9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706199031; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pkwo7UCJpMNv5mPn2sWjbV8ooarPUagmTu1VnxL99W0=; b=cpbfwVgVkBFZhfhWKt1wksb8Xw9Wk2AVRwJwGHvrewWNk46LgsDbCGczrY8Ijb3rfxK6xQoC9C58Ro+UBRdR2PkLbTBkznSJr9Ou/bK+zteGW7MhLcIn4WZOuC+M67lUzBeiB+b04jLFdnVYsC2UppXyZMEO4G/ltCNccAYV13g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17061990311001012.7283157467407; Thu, 25 Jan 2024 08:10:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT2Hu-0006yl-FS; Thu, 25 Jan 2024 11:09:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT2Ht-0006vj-44 for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:09:09 -0500 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rT2Hr-0000NS-75 for qemu-devel@nongnu.org; Thu, 25 Jan 2024 11:09:08 -0500 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so5279253a12.1 for ; Thu, 25 Jan 2024 08:09:06 -0800 (PST) Received: from wheely.local0.net (110-175-3-177.tpgi.com.au. [110.175.3.177]) by smtp.gmail.com with ESMTPSA id oe7-20020a17090b394700b00293851b198csm14190pjb.56.2024.01.25.08.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 08:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706198944; x=1706803744; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pkwo7UCJpMNv5mPn2sWjbV8ooarPUagmTu1VnxL99W0=; b=Pb+EbWFzONOflOcPXQ+B5pwth+kHgsvb/MiYrXFZ0nsweoNwnq7GQVn4FJ6M4C88m6 hmG9ZgsJJvifsfA87N2ILv2Nl0TD4ahRn8/B0YDC7abGtEy2gkr/N8vW3DwcLpaDJeHA +FS5M33G/IYybzkvDgweJXBvM0M9yNy8iZWKOzyFzEJmM2D9yTdyb6xcaTq++QV7bld7 FeCpxDH9Sy/QjkmQzZTlARyG4pvIj+nxjupqLWM3IkXWuCBED7PmPlvew5/st2IOgqoB uNXS5w/H/cC/+IToIQmWTnCNGrR6Bf46wL8OWv99gDS/rSitfiIjBorxGASWTQjJclnn n41w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706198944; x=1706803744; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pkwo7UCJpMNv5mPn2sWjbV8ooarPUagmTu1VnxL99W0=; b=W6sDYXQi8ec70dspaqj3GjUjS/HWr5+WfHfXbV732y//R+Rqe+h0hc7MPuFqDYm9YW N8N4FN49EtSb04hI4Pajk8AAIHGM7u2rmFAvTQa6Azdd9vQc1Ga1Bqjos0LUurxoTYTf K0DoZJ9UrcM4LOS4k89DDxApBbCOORdayPwj4LN0Kuf2QWFXQoXjIcsF+mIq5h7TtTFi D37tGJhkY1MNPUwRjHtiqcE3F+qUDBs1RZUqoFNN1xRD2HUL09vm0WTE4X1yvY1qCGDt U3a4uRKlk4wj7wMDoHsBsEN1P3CzRyB5O1siAB6nQfDjyk98RoIyWGdSTH9kSFbW6joO bATA== X-Gm-Message-State: AOJu0Ywnb05iUu+gcgbw9SyKGVlUyY1t3rQHJpaVpEVTePbauZ4rPp8y 52kF4MD/oZyaFV6aInXFnvF7MqlmMsZfrzCcN5B686Y5xD3lyPxg4q+hLXtC X-Google-Smtp-Source: AGHT+IHkq+KFB8siFeMpeiKhcBdVZCuCCy+rsE0uDvcSnJYCyTlA2yC3AXNw0dMDgrsuaHhs9EcEaw== X-Received: by 2002:a17:90a:d313:b0:290:f9b6:8078 with SMTP id p19-20020a17090ad31300b00290f9b68078mr1050445pju.7.1706198944532; Thu, 25 Jan 2024 08:09:04 -0800 (PST) From: Nicholas Piggin To: qemu-devel@nongnu.org Cc: Nicholas Piggin , Pavel Dovgalyuk , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , John Snow , Cleber Rosa , Wainer dos Santos Moschetta , Beraldo Leal Subject: [PATCH v2 4/4] tests/avocado: excercise scripts/replay-dump.py in replay tests Date: Fri, 26 Jan 2024 02:08:35 +1000 Message-ID: <20240125160835.480488-5-npiggin@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240125160835.480488-1-npiggin@gmail.com> References: <20240125160835.480488-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=npiggin@gmail.com; helo=mail-pg1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1706199031890100001 Content-Type: text/plain; charset="utf-8" This runs replay-dump.py after recording a trace, and fails the test if the script fails. replay-dump.py is modified to exit with non-zero if an error is encountered while parsing, to support this. Signed-off-by: Nicholas Piggin Reviewed-by: Pavel Dovgalyuk --- scripts/replay-dump.py | 6 ++++-- tests/avocado/replay_kernel.py | 16 ++++++++++++++++ tests/avocado/replay_linux.py | 16 ++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/scripts/replay-dump.py b/scripts/replay-dump.py index a1d7ae0364..bfea9c099b 100755 --- a/scripts/replay-dump.py +++ b/scripts/replay-dump.py @@ -21,6 +21,7 @@ import argparse import struct import os +import sys from collections import namedtuple from os import path =20 @@ -104,7 +105,7 @@ def call_decode(table, index, dumpfile): print("Could not decode index: %d" % (index)) print("Entry is: %s" % (decoder)) print("Decode Table is:\n%s" % (table)) - return False + raise(Exception("unknown event")) else: return decoder.fn(decoder.eid, decoder.name, dumpfile) =20 @@ -125,7 +126,7 @@ def print_event(eid, name, string=3DNone, event_count= =3DNone): def decode_unimp(eid, name, _unused_dumpfile): "Unimplemented decoder, will trigger exit" print("%s not handled - will now stop" % (name)) - return False + raise(Exception("unhandled event")) =20 def decode_plain(eid, name, _unused_dumpfile): "Plain events without additional data" @@ -439,6 +440,7 @@ def decode_file(filename): dumpfile) except Exception as inst: print(f"error {inst}") + sys.exit(1) =20 finally: print(f"Reached {dumpfile.tell()} of {dumpsize} bytes") diff --git a/tests/avocado/replay_kernel.py b/tests/avocado/replay_kernel.py index 10d99403a4..9b3ee6726b 100644 --- a/tests/avocado/replay_kernel.py +++ b/tests/avocado/replay_kernel.py @@ -13,6 +13,7 @@ import shutil import logging import time +import subprocess =20 from avocado import skip from avocado import skipUnless @@ -22,6 +23,11 @@ from avocado.utils import process from boot_linux_console import LinuxKernelTest =20 +from pathlib import Path + +self_dir =3D Path(__file__).parent +src_dir =3D self_dir.parent.parent + class ReplayKernelBase(LinuxKernelTest): """ Boots a Linux kernel in record mode and checks that the console @@ -63,6 +69,8 @@ def run_vm(self, kernel_path, kernel_command_line, consol= e_pattern, vm.shutdown() logger.info('finished the recording with log size %s bytes' % os.path.getsize(replay_path)) + self.run_replay_dump(replay_path) + logger.info('successfully tested replay-dump.py') else: vm.wait() logger.info('successfully finished the replay') @@ -70,6 +78,14 @@ def run_vm(self, kernel_path, kernel_command_line, conso= le_pattern, logger.info('elapsed time %.2f sec' % elapsed) return elapsed =20 + def run_replay_dump(self, replay_path): + try: + subprocess.check_call(["./scripts/replay-dump.py", + "-f", replay_path], + cwd=3Dsrc_dir, stdout=3Dsubprocess.DEVNU= LL) + except subprocess.CalledProcessError: + self.fail('replay-dump.py failed') + def run_rr(self, kernel_path, kernel_command_line, console_pattern, shift=3D7, args=3DNone): replay_path =3D os.path.join(self.workdir, 'replay.bin') diff --git a/tests/avocado/replay_linux.py b/tests/avocado/replay_linux.py index f3a43dc98c..dd148ff639 100644 --- a/tests/avocado/replay_linux.py +++ b/tests/avocado/replay_linux.py @@ -11,6 +11,7 @@ import os import logging import time +import subprocess =20 from avocado import skipUnless from avocado_qemu import BUILD_DIR @@ -21,6 +22,11 @@ from avocado.utils.path import find_command from avocado_qemu import LinuxTest =20 +from pathlib import Path + +self_dir =3D Path(__file__).parent +src_dir =3D self_dir.parent.parent + class ReplayLinux(LinuxTest): """ Boots a Linux system, checking for a successful initialization @@ -94,6 +100,8 @@ def launch_and_wait(self, record, args, shift): vm.shutdown() logger.info('finished the recording with log size %s bytes' % os.path.getsize(replay_path)) + self.run_replay_dump(replay_path) + logger.info('successfully tested replay-dump.py') else: vm.event_wait('SHUTDOWN', self.timeout) vm.wait() @@ -108,6 +116,14 @@ def run_rr(self, args=3DNone, shift=3D7): logger =3D logging.getLogger('replay') logger.info('replay overhead {:.2%}'.format(t2 / t1 - 1)) =20 + def run_replay_dump(self, replay_path): + try: + subprocess.check_call(["./scripts/replay-dump.py", + "-f", replay_path], + cwd=3Dsrc_dir, stdout=3Dsubprocess.DEVNU= LL) + except subprocess.CalledProcessError: + self.fail('replay-dump.py failed') + @skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout') class ReplayLinuxX8664(ReplayLinux): """ --=20 2.42.0