From patchwork Tue Sep 10 15:08:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Raphael Tiovalen X-Patchwork-Id: 1983284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=KwaanLrm; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=epCjgdO/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X36Yn19cNz1y1x for ; Wed, 11 Sep 2024 01:09:32 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BmATo+n9Q/WkPT/1DNVIuWqyt++ReRLpO2b9i7B/kLQ=; b=KwaanLrm13KUoZ j/SfIBr3zeYXp1DmELz9uKncqVR9ftzPsZwxVlSmq+zfRnPHwHMlD8BGd8Hc72fEKjnUxVKk4+H6I t9LCS2m4FM78sibs1f2L0YOcefP4BRVKRMGV2oZdr9rjN5JClt95erIZIX+WF8JQcx0HYXZuqoXYu rrpQIHyyf6uGYGzDKQhueVWSQ34P0MV0FsZSXizL0lpja767+KY4GMMeKjatTMQfJjkW5iBk6KQb/ RE2xnWpe4bIOk9OExt/GMdunKuVzRx+s6DUZ4abLFg2nOH4njfLcOQL9mWZ1eWfA2F7rkRya8QDKK brg8G+TGtHrDkK1oS1Bg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1so2Ul-0000000608n-0b0s; Tue, 10 Sep 2024 15:09:31 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1so2UF-0000000602s-2HCO for kvm-riscv@lists.infradead.org; Tue, 10 Sep 2024 15:09:00 +0000 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2daaa9706a9so647080a91.1 for ; Tue, 10 Sep 2024 08:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725980938; x=1726585738; darn=lists.infradead.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=jJ0SGbueLL+CmiAymH1gcSoFZqvjzIWyBVOl8YOSxQk=; b=epCjgdO/uW7rSGlQI/SnnX6qC7mUDnYBLcC0AVkzDHhEunTnvlnoAHDLjhMbfIblFI wtIcd8g8sArAsLtVtGuvQENfCK2v5hbhmpOO8Y+J3xl8n3tIp2XsWuvuORE7irly+fx0 CbVvHP5bHGQqWHk/IGLCz/0EI98uQoZy5RW1/el4fXiy2vqEVOqpi8d1LRLEyWPUk40T 7dcyAFyUa/RuEvNPioyAL3LdbqsS++D+apYH35e0e2RdTeb14KV/fNu5kPHVyFVn4c8H LccHWgvGFMda0b1fTXhdsr4tLkzhaGq9GyKKRs9ict/sfnY/29Wu1II7lMjxRrnDXdYy pDPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725980938; x=1726585738; 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=jJ0SGbueLL+CmiAymH1gcSoFZqvjzIWyBVOl8YOSxQk=; b=xBcj24wZyVjhfwBRFJUQE7MmHpO+GRYKUYEHSRubpwpeOo1cM/ZrrXY/P/5PBttm8l P1wwb7gciQEj0ie8na3C3Ry0fDcnbnef2fpO1IihgGoa8Bfx+0dmWEryFqyAdE5VV3Sq R2Y6FEjvNOZu6iv/BmMjGjz14ulr6J/os50/5DZ8QAJ6SsqzB1fQxxqCCPcPLViVYQsp xOu1iYrvqqN3+vCh5cCao+edcUV7kbDs68JC9GTQNkUTXHKRnyP4fyo3uZSgAxO/7/Oq PUPLBvupKzd/6mbhXJmlHEjbH8FtlS201vsIAaa++r5toZFEx5MR57WYiPJmFAij1y4I imNA== X-Forwarded-Encrypted: i=1; AJvYcCWm/8W2I/ww1pheETQ8m18o6b0Yv26XqK83mXks764f3HZbkdSnT7qE1+PYyirI/2OJwJs5U/jzA0w=@lists.infradead.org X-Gm-Message-State: AOJu0YxzsnSkVG20pEXVlcfdlAxN0G0oewO7ShMYfv0djUXclIKmJZA1 362frurXA8Wfyq7hr8AgorAK2DCSJW8UoLOq8bNitc4EOCcmZjyK X-Google-Smtp-Source: AGHT+IG0iyMqvqxpu0X/2Og0DCIqsyuVLf32tPr2K/8TAm+mC5FKKAucoitOwNcYmiCvgmXTVcflaA== X-Received: by 2002:a17:90b:3b8b:b0:2d8:84df:fa0a with SMTP id 98e67ed59e1d1-2dad50e8778mr14157637a91.32.1725980937974; Tue, 10 Sep 2024 08:08:57 -0700 (PDT) Received: from JRT-PC.. ([202.166.44.78]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db041a02c7sm6615120a91.19.2024.09.10.08.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 08:08:57 -0700 (PDT) From: James Raphael Tiovalen To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Cc: andrew.jones@linux.dev, atishp@rivosinc.com, cade.richard@berkeley.edu, James Raphael Tiovalen Subject: [kvm-unit-tests PATCH 1/2] lib/report: Add helper method to clear multiple prefixes Date: Tue, 10 Sep 2024 23:08:41 +0800 Message-ID: <20240910150842.156949-2-jamestiotio@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240910150842.156949-1-jamestiotio@gmail.com> References: <20240910150842.156949-1-jamestiotio@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240910_080859_655564_497B3D69 X-CRM114-Status: GOOD ( 10.49 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Add a method to pop a specified number of prefixes. This method is useful when tests want to clear multiple prefixes at once. Suggested-by: Andrew Jones Signed-off-by: James Raphael Tiovalen --- lib/libcflat.h | 1 + lib/report.c | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1031 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jamestiotio(at)gmail.com] X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add a method to pop a specified number of prefixes. This method is useful when tests want to clear multiple prefixes at once. Suggested-by: Andrew Jones Signed-off-by: James Raphael Tiovalen --- lib/libcflat.h | 1 + lib/report.c | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/libcflat.h b/lib/libcflat.h index 16a83880..eec34c3f 100644 --- a/lib/libcflat.h +++ b/lib/libcflat.h @@ -96,6 +96,7 @@ void report_prefix_pushf(const char *prefix_fmt, ...) __attribute__((format(printf, 1, 2))); extern void report_prefix_push(const char *prefix); extern void report_prefix_pop(void); +extern void report_prefix_popn(int n); extern void report(bool pass, const char *msg_fmt, ...) __attribute__((format(printf, 2, 3), nonnull(2))); extern void report_xfail(bool xfail, bool pass, const char *msg_fmt, ...) diff --git a/lib/report.c b/lib/report.c index 7f3c4f05..0756e64e 100644 --- a/lib/report.c +++ b/lib/report.c @@ -60,23 +60,32 @@ void report_prefix_push(const char *prefix) report_prefix_pushf("%s", prefix); } -void report_prefix_pop(void) +static void __report_prefix_pop(void) { char *p, *q; - spin_lock(&lock); - - if (!*prefixes) { - spin_unlock(&lock); + if (!*prefixes) return; - } for (p = prefixes, q = strstr(p, PREFIX_DELIMITER) + 2; *q; p = q, q = strstr(p, PREFIX_DELIMITER) + 2) ; *p = '\0'; +} +void report_prefix_pop(void) +{ + spin_lock(&lock); + __report_prefix_pop(); + spin_unlock(&lock); +} + +void report_prefix_popn(int n) +{ + spin_lock(&lock); + while (n--) + __report_prefix_pop(); spin_unlock(&lock); }