From patchwork Fri Nov 10 03:40:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 742835 Delivered-To: patch@linaro.org Received: by 2002:a5d:4848:0:b0:32c:eacc:7fa with SMTP id n8csp1160339wrs; Thu, 9 Nov 2023 19:41:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhwlGlijvMwE6LzBuzXF1Ga6IZOzADn5hlgBdU6RmBJ0m5heNu1lW0NLyGhIE4lIGc3v9H X-Received: by 2002:a05:620a:3726:b0:767:82e8:eb88 with SMTP id de38-20020a05620a372600b0076782e8eb88mr7534462qkb.7.1699587678978; Thu, 09 Nov 2023 19:41:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699587678; cv=none; d=google.com; s=arc-20160816; b=AcHfKcMoakPKFA4pxNTNzqo4AZwGssxda/GOwdMvJsI3QSy89oGeFJWz0ZZB4MQTBt qaMCXpy+NYuZK33qqUC0jMON6ixLXDBjnR8gZ0c9KwTithpCeyv6Mn25K7VQJng6L6g5 O45NtTC/DTCL6mcTJdKUEUzJYcB/fSLuVzNf+TgqTkcTMkeN1Myheum8VIo1S8+7bl0v MSgBgkbGHCNlCuGiZawiwyFwo9gxxflJFZWWzsNN7mY6GJ86FpGPxVMgLB71BKoayONj chCpCDwBObC37Fb7NETFw9fF+a4J7d5/UCAukwAtLapNaA3E63yCMyULSZdsmpvVrLCX Nxww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :content-language:mime-version:user-agent:date:message-id:subject :from:cc:to:dkim-signature; bh=Z81K35OO2eUCpve25H5Tuz7piXHa8fecDSrxoQEOC68=; fh=2LsdgIX88lQ4IwJxjVFLR/A4M1LyLJ5ETWy5cNWvOU4=; b=um5yPGMVg6cbxNlMim/aOVQmBEnPKRNhu3UysA/HdJhplcMYoXTinHEEggOPV1GjlW vr5kEGSTL/q5/OEuSwi5s+9PAxTsdI1iQHpDvKLjKTcltr5Gqpa0IM4queoNFDERBG60 GIikgXKErzJW9zt7hzV+mQ1LkfmyHtx4/QCkcd1CaKEyIe8KS6H43F4Gi8zgvjkydKBv ThBeH/nXHdyAwQuFzgIIjNuw3lUp548FU52/1CFhxscQxLziWyQVSbzjMJVT9F96FXFn G4iWn8Fm62LPD2JkZMIucuUDBiitcNBeAKRjJRxKQsxADShmOzBHV4EeXBR32qzvc/fb LI/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qFur74qo; 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=pass (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 w11-20020a05620a424b00b007756c8c89e2si4087480qko.614.2023.11.09.19.41.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Nov 2023 19:41:18 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=qFur74qo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r1INk-0004y7-LX; Thu, 09 Nov 2023 22:40:32 -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 1r1INi-0004xc-Mc for qemu-devel@nongnu.org; Thu, 09 Nov 2023 22:40:30 -0500 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r1INh-0005uO-1w for qemu-devel@nongnu.org; Thu, 09 Nov 2023 22:40:30 -0500 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6c33ab26dddso1504117b3a.0 for ; Thu, 09 Nov 2023 19:40:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699587627; x=1700192427; darn=nongnu.org; h=content-transfer-encoding:content-language:mime-version:user-agent :date:message-id:subject:from:cc:to:from:to:cc:subject:date :message-id:reply-to; bh=Z81K35OO2eUCpve25H5Tuz7piXHa8fecDSrxoQEOC68=; b=qFur74qoRLm8j7aOFFNBEjHfyqqmI9ttik02A5ldk8otKkhZtDjcEepiKYPilK3OG3 MjXq04RNFnBrJTi2Sxh5vW+AlSDa3xPG9VgysVYSnIaeMpPSVnjeO9Ea4txAXVGQPiXf mTfrsYnSdf55+U3GhAQNu84QhmPVNxKIuJgYsjnow9icpeybxFcICqDLnE9wj4BiuOO4 EHHbM6gLC4ciJgq8pVFYkoUVoYP5Nsv4uZxlPS+CisxP3kf+bA5Crn0tJzG31TjfgOBQ 2+iVmYN8JoGtc+Shgoq8361VhI0KlAFi/QMF6RsimRdM29YD3NKsD/TtWmr8HvotpdsK XcbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699587627; x=1700192427; h=content-transfer-encoding:content-language:mime-version:user-agent :date:message-id:subject:from:cc:to:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z81K35OO2eUCpve25H5Tuz7piXHa8fecDSrxoQEOC68=; b=N7D5R/0dVL23ybVuLfgXb+aDWSkE8tL0AOvLZJObx/70/KpGHy/EDcUWo03TGWR6sa V70fZ9ldbvYCu8M49WMtV9qjQOG2TlAN0jg5PVqfQ7GGr50Rxn3lIUT9VP2fY7jGuN/5 HDoNO4ym5HfNUbv5px8TE0x9NPYqtx4lEL2cuLyLKmWQUHSywUZf30QQefEazGnbR53Y 4ppqm+CqWRM3XjXy2K4wKmNi+sr+2pW4nkv4/dATUb+Ev8G/VvPaJLVSoafswFaW5vRn lnJX2ir50OmsqXqyAWDaVspNVEG844z21Dw3M9KwnQ/PPGJME4TJfQ4nclcbj9fUwyan Jdxw== X-Gm-Message-State: AOJu0YwThH59koCZb9k8E2EiXEm0WzWWR/s/Qi3Zl+CWpm2+wBkNuRLe e9nZefl0LxWfz6lrTDNIjcLvcg== X-Received: by 2002:a05:6a00:b92:b0:68b:bf33:2957 with SMTP id g18-20020a056a000b9200b0068bbf332957mr7188066pfj.22.1699587627268; Thu, 09 Nov 2023 19:40:27 -0800 (PST) Received: from ?IPv6:2804:7f0:b401:308c:fa40:2f92:19ee:4ba? ([2804:7f0:b401:308c:fa40:2f92:19ee:4ba]) by smtp.gmail.com with ESMTPSA id h15-20020aa786cf000000b006bd26bdc909sm11503708pfo.72.2023.11.09.19.40.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Nov 2023 19:40:26 -0800 (PST) To: thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com Cc: qemu-devel@nongnu.org, philmd@linaro.org From: Gustavo Romero Subject: QTest framework does not capture toggled irq line Message-ID: <4daf0424-b767-b5d9-bacb-0fe879c92963@linaro.org> Date: Fri, 10 Nov 2023 00:40:22 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 Content-Language: en-US Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=gustavo.romero@linaro.org; helo=mail-pf1-x434.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Hi folks, I'm writing a test for a device that has one IRQ output line that is toggled (raised then lowered) by the device to trigger a CPU interrupt. Afaics the QTest framework does not provide a way to capture when an output line is raised because the API functions, e.g. 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 by the device. I'd like to introduce a new API function to address this case, called qtest_get_irq_trigger_counter(): This change addresses the current QTest limitation. Is it acceptable? Cheers, Gustavo diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 471529e6cc..9ed2a43155 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -79,6 +79,7 @@ struct QTestState diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 471529e6cc..9ed2a43155 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -79,6 +79,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; @@ -481,6 +482,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args) s->rx = g_string_new(""); for (i = 0; i < MAX_IRQ; i++) { s->irq_level[i] = false; + s->irq_trigger_counter[i] = 0; } /* @@ -663,6 +665,7 @@ redo: if (strcmp(words[1], "raise") == 0) { s->irq_level[irq] = true; + s->irq_trigger_counter[irq]++; } else { s->irq_level[irq] = false; } @@ -953,6 +956,14 @@ bool qtest_get_irq(QTestState *s, int num) return s->irq_level[num]; } +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 *libname) { qtest_sendf(s, "module_load %s %s\n", prefix, libname); @@ -1693,6 +1704,7 @@ QTestState *qtest_inproc_init(QTestState **s, bool log, const char* arch, qts->wstatus = 0; for (int i = 0; i < MAX_IRQ; i++) { qts->irq_level[i] = false; + qts->irq_trigger_counter[i] = 0; } qtest_client_set_rx_handler(qts, qtest_client_inproc_recv_line); diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index e53e350e3a..0e763a4507 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -351,6 +351,16 @@ void qtest_module_load(QTestState *s, const char *prefix, const char *libname); */ bool qtest_get_irq(QTestState *s, int num); + +/** + * qtest_get_irq_counter: + * @s: #QTestState instance to operate on. + * @irq_num: Interrupt to observe. + * + * Returns: The number of times @irq_num got triggered (raised). + */ +uint64_t qtest_get_irq_trigger_counter(QTestState *s, int irq_num); + /** * qtest_irq_intercept_in: * @s: #QTestState instance to operate on.