Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2968531rdb; Mon, 4 Dec 2023 12:33:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtnMkDuJ6JkNZGtx0njKVPE6+m9APOXPnnhr7DggImEgWVJm2SXujKI+mdhB/4hB484Y58 X-Received: by 2002:a17:903:230a:b0:1d0:af28:4603 with SMTP id d10-20020a170903230a00b001d0af284603mr1838861plh.32.1701722014698; Mon, 04 Dec 2023 12:33:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701722014; cv=none; d=google.com; s=arc-20160816; b=yhU9xhrt9oFEXWsAb1uvYLZ6ZlHqwlrWOQJOH22PsCDM89K6sSvfp6ij0m/8r/ZK2/ zg6ANz1E8zfrZFllpvgc2q2g3cPA2m8IP4bB37OjS/g7rWMUx0JPWo5kABBkayZbGY6F y0x9UYw3jCEh/578s2tNh/wMIQVkqdBvR/dERFf7mYeXn0yy13OH6GShYXo40U59HDXO bS9LpmJXsPA5ZQaWwNW1MTv5E4FCc8UFKE9tKdbI7b51+jM5CSd3zubJKRts03yECiBr WFV8V+Cb9EPCrP766qQkULu2v+sLS7v8e0U+sf07/OZdbQkL4gVaEbxFEvZMJUuXr30I 2thA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mXGrw3/Z153zyKELMTqS2r/lbA0whJM0vBAEjkKExT4=; fh=x+MAGwzjM+a1ULVc/bf+ZFLrUKAZuAi+lIXzFdUVjHk=; b=R/hEt0RG47McIV46qV3VPWtlb1R4Dd/EXITtFim/e4v4/RSVh39nrUBY9Nuz3sIzy3 cGy9MQ/UWxU0x6cBSmJkSnIN1L3EyIf/hMPB5eA6Izl107KdB59kM0vkyRLBHBWVFjz9 sc+8UVmOsC9A2mR2Boj8pCYH0817bGCDc3oAiINKb4eGIN+Da/MQUEE2MSbid8z1zE5f FHQ38OM7JSA58DvUI3i6E80K7ad4YnF+ZOwH9BOCbSBMwmC03BjRfjKqhIVQmGMB2e+H EfAEYNeJKVgZgK3d+2jqH1sVSreFcAq1XVA9B8lujhpQhJcY71aBl6v+CgoVNzpWmxOD PJTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dvNFnpFz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z7-20020a170902834700b001d0b78ea7a2si1062668pln.516.2023.12.04.12.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 12:33:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dvNFnpFz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id ACBE8804C232; Mon, 4 Dec 2023 12:33:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345776AbjLDUdW (ORCPT + 99 others); Mon, 4 Dec 2023 15:33:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345544AbjLDUdU (ORCPT ); Mon, 4 Dec 2023 15:33:20 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FE02D2 for ; Mon, 4 Dec 2023 12:33:26 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AD3EC433CC; Mon, 4 Dec 2023 20:33:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701722005; bh=VQ1kDw6UcR7JbTEq2lMQAZ17c1wIZV3ufze0fEvndbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dvNFnpFz/PSWcSxylNhLAdk53Csf6TjBDMF40Vc8+lPruq8HRef9dS+GGfYv9Vy5i sK6zR5EJMxk1is3BB0nukj19AyM/racWMAMBy2hP7UvFAouTokKK+UddrM3NahmXzt Zr7AKMX4+ThlUzQFL3C7IHGLOE9/448KzY5tzi4GngaqivDk5zdUhylzw89dYR69re 8p2314zXghypQ2iLBXhg3PYLPGbdBoeaeVNPQ9AHMGF/oAQLif09D6iiq1lA6lPB0O XjEjVU86FG9DKMNUfW5a0V7daA1CTD5M0ZrQNDWUkdvm7QuC1WrNmfg9FC7pmA6I8H ia2c7wTEgn8pg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Michal Wajdeczko , David Gow , Rae Moar , Shuah Khan , Sasha Levin , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Subject: [PATCH AUTOSEL 6.6 03/32] kunit: Reset suite counter right before running tests Date: Mon, 4 Dec 2023 15:32:23 -0500 Message-ID: <20231204203317.2092321-3-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231204203317.2092321-1-sashal@kernel.org> References: <20231204203317.2092321-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.4 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 12:33:33 -0800 (PST) From: Michal Wajdeczko [ Upstream commit 2e3c94aed51eabbe9c1c0ee515371ea5441c2fa7 ] Today we reset the suite counter as part of the suite cleanup, called from the module exit callback, but it might not work that well as one can try to collect results without unloading a previous test (either unintentionally or due to dependencies). For easy reproduction try to load the kunit-test.ko and then collect and parse results from the kunit-example-test.ko load. Parser will complain about mismatch of expected test number: [ ] KTAP version 1 [ ] 1..1 [ ] # example: initializing suite [ ] KTAP version 1 [ ] # Subtest: example .. [ ] # example: pass:5 fail:0 skip:4 total:9 [ ] # Totals: pass:6 fail:0 skip:6 total:12 [ ] ok 7 example [ ] [ERROR] Test: example: Expected test number 1 but found 7 [ ] ===================== [PASSED] example ===================== [ ] ============================================================ [ ] Testing complete. Ran 12 tests: passed: 6, skipped: 6, errors: 1 Since we are now printing suite test plan on every module load, right before running suite tests, we should make sure that suite counter will also start from 1. Easiest solution seems to be move counter reset to the __kunit_test_suites_init() function. Signed-off-by: Michal Wajdeczko Cc: David Gow Cc: Rae Moar Reviewed-by: David Gow Signed-off-by: Shuah Khan Signed-off-by: Sasha Levin --- lib/kunit/test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kunit/test.c b/lib/kunit/test.c index e451cfe6143ec..7452d1a2acd98 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -740,6 +740,8 @@ int __kunit_test_suites_init(struct kunit_suite * const * const suites, int num_ return 0; } + kunit_suite_counter = 1; + static_branch_inc(&kunit_running); for (i = 0; i < num_suites; i++) { @@ -766,8 +768,6 @@ void __kunit_test_suites_exit(struct kunit_suite **suites, int num_suites) for (i = 0; i < num_suites; i++) kunit_exit_suite(suites[i]); - - kunit_suite_counter = 1; } EXPORT_SYMBOL_GPL(__kunit_test_suites_exit); -- 2.42.0