From nobody Wed Nov 27 06:36:47 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1699753158; cv=none; d=zohomail.com; s=zohoarc; b=GOC8MBh9EJh5UoCUfa1zYdpXO3xvmYsuUIEE5ki/fS1jfN6Y96vPdej7I5Y5GZBe18MksMFA3CbA8cepE0FpPy0f1k/kyXVB/xibnGKD2KQldCK5r5h1t06DNbt4dfbQWlniBKD2Bc2ChPVPF6Z8PqJdUiqyNEkJ6TqCHVbwsOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699753158; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5iTBJRyOtbbI2Xeif97v+vFr7FkDa6oay4Q1ew9vL9c=; b=QpNruLHNsfAVlHV9p8tGRuGB6NpQsLhglaHCac/2Y6xxey8ydU1/28sHk92jWHrexiNrFdhn6Oww0cuJ1qAQEJGMjNN0S2PX2Io6FC5NhDa62iCM6vt/j2p9afkKDb/4FxMm0XTPMNM7dcWxAKkz97PPPhjsb5qworsfEMEgiIE= 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 1699753158463643.5506441093524; Sat, 11 Nov 2023 17:39:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r1zQt-0005MT-ER; Sat, 11 Nov 2023 20:38:39 -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 1r1zQr-0005M8-KR for qemu-devel@nongnu.org; Sat, 11 Nov 2023 20:38:37 -0500 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r1zQp-0005Mv-O9 for qemu-devel@nongnu.org; Sat, 11 Nov 2023 20:38:37 -0500 Received: by mail-oo1-xc30.google.com with SMTP id 006d021491bc7-5844bc378feso1894639eaf.0 for ; Sat, 11 Nov 2023 17:38:34 -0800 (PST) Received: from amd.. ([2804:7f0:b401:308c:3e7c:3fff:fe7a:e83b]) by smtp.gmail.com with ESMTPSA id w12-20020a63f50c000000b005b8ebef9fa0sm1869393pgh.83.2023.11.11.17.38.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Nov 2023 17:38:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699753113; x=1700357913; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5iTBJRyOtbbI2Xeif97v+vFr7FkDa6oay4Q1ew9vL9c=; b=a9stK5iJguUtuLOeXngWEHdu2fDVNe6fbnAz09shOMVlYvH2h9T862a/uPkOPnW/1N cOA2QJpCpxE23vt+Nv3NUkXwSjMs49QE0BG6dSF20p8eYhTQavtHlQVFNzEr6JvIv0cr uBhU1bpCe9NJ3BUNPvcj3fEnJiQDWyR9a749AB/9mdHoXAlotfZddVUuHBiHlk9c/c6+ zQvf3ecayyh3NYR2JHxZBT3DS+CKxLECm15UCVm1dnhFBpw3AjP0byq1jelylnHKX/6E yFuj72+0oRMLDmCI/b3Z/Oo+ROy+g5XOjZ7RF4gyCkt5Q4FKBNsHth31h6bpJb1tXN31 xiEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699753113; x=1700357913; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5iTBJRyOtbbI2Xeif97v+vFr7FkDa6oay4Q1ew9vL9c=; b=YuHg6fmkdxOaxURxSVfYsNn5AiHkFMWgPMHxq8rl+MKXl60cXs2JWCtSk6AqIeMPJv 0sqQ47lV3txDSNQ25YybSv1fR5Zdn3rnPFyBq7BiXoS+fYahTCgWVYRReItqbDSVXawS 178l6NLWzTnLPItq7kZYqI1APBbbmGNasSwvVmBI8ljiqu7Tr9BhV2lZhew+fo/cnoWT pcUVCUfb+pZUMG3aSX1h+W0XXzl76r0+TCTAhcP/RGkGl7ulI2xS8Lczsq0/zRnid7N7 ylxB+K2HIKWOpzT0twRxfeYEPNXsHBlPowRe6g0xquJnBCqwe63thWkVj28gpRpz3EgK 3sgg== X-Gm-Message-State: AOJu0Yyr5dMe9ChTpccjQr7qrpR3H10ao0kdaZDaNJDREsPaJV9jJKnN 3eX63n9EjSvgbx8jMLq1PUnPGCOGSMpTyndTSln/JsnR X-Google-Smtp-Source: AGHT+IGllvZ9C9DdmUr5g2c1OGWOGWsIOspQTJGFDEFe58fAIRobfDmGcAZVtEYmQIndzJ2rXO/8+Q== X-Received: by 2002:a05:6358:7f1e:b0:169:81cc:d7f9 with SMTP id p30-20020a0563587f1e00b0016981ccd7f9mr5425425rwn.0.1699753113159; Sat, 11 Nov 2023 17:38:33 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, thuth@redhat.com Cc: lvivier@redhat.com, pbonzini@redhat.com, philmd@linaro.org, gustavo.romero@linaro.org Subject: [PATCH] test/qtest: Add an API function to capture IRQ toggling Date: Sun, 12 Nov 2023 01:38:01 +0000 Message-Id: <20231112013801.293970-1-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 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::c30; envelope-from=gustavo.romero@linaro.org; helo=mail-oo1-xc30.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, 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 @linaro.org) X-ZM-MESSAGEID: 1699753160113100001 Content-Type: text/plain; charset="utf-8" Currently the QTest API does not provide a function to allow capturing when an IRQ line is toggled (raised then lowered). Functions like qtest_get_irq() read the current state of the intercepted IRQ lines, which is already low when the function is called, since the line is toggled. This commit introduces a new function, qtest_get_irq_trigger_counter(), which returns the number of times a given intercepted IRQ line was triggered (raised), hence allowing to capture when an IRQ line was toggled. Signed-off-by: Gustavo Romero Acked-by: Thomas Huth --- tests/qtest/libqtest.c | 12 ++++++++++++ tests/qtest/libqtest.h | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index f33a210861..21891b52f1 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -82,6 +82,7 @@ struct QTestState int expected_status; bool big_endian; bool irq_level[MAX_IRQ]; + uint64_t irq_trigger_counter[MAX_IRQ]; GString *rx; QTestTransportOps ops; GList *pending_events; @@ -498,6 +499,7 @@ static QTestState *qtest_init_internal(const char *qemu= _bin, s->rx =3D g_string_new(""); for (i =3D 0; i < MAX_IRQ; i++) { s->irq_level[i] =3D false; + s->irq_trigger_counter[i] =3D 0; } =20 /* @@ -690,6 +692,7 @@ redo: =20 if (strcmp(words[1], "raise") =3D=3D 0) { s->irq_level[irq] =3D true; + s->irq_trigger_counter[irq]++; } else { s->irq_level[irq] =3D false; } @@ -980,6 +983,14 @@ bool qtest_get_irq(QTestState *s, int num) return s->irq_level[num]; } =20 +uint64_t qtest_get_irq_trigger_counter(QTestState *s, int irq_num) +{ + /* dummy operation in order to make sure irq is up to date */ + qtest_inb(s, 0); + + return s->irq_trigger_counter[irq_num]; +} + void qtest_module_load(QTestState *s, const char *prefix, const char *libn= ame) { qtest_sendf(s, "module_load %s %s\n", prefix, libname); @@ -1799,6 +1810,7 @@ QTestState *qtest_inproc_init(QTestState **s, bool lo= g, const char* arch, qts->wstatus =3D 0; for (int i =3D 0; i < MAX_IRQ; i++) { qts->irq_level[i] =3D false; + qts->irq_trigger_counter[i] =3D 0; } =20 qtest_client_set_rx_handler(qts, qtest_client_inproc_recv_line); diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index 6e3d3525bf..d1c525aea0 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -364,6 +364,15 @@ void qtest_module_load(QTestState *s, const char *pref= ix, const char *libname); */ bool qtest_get_irq(QTestState *s, int num); =20 +/** + * qtest_get_irq_counter: + * @s: #QTestState instance to operate on. + * @num: Interrupt to observe. + * + * Returns: The number of times IRQ @num got triggered (raised). + */ +uint64_t qtest_get_irq_trigger_counter(QTestState *s, int num); + /** * qtest_irq_intercept_in: * @s: #QTestState instance to operate on. --=20 2.34.1