From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E6DD6CD4F25 for ; Tue, 12 May 2026 05:25:30 +0000 (UTC) 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=3iVrgSBjR5rY2B+u+9QgCSXSvqhqbXYGl2v6G7maQ8E=; b=oL52943xuycWkP XPn04UD5WMC183aIfrm4JVsn9vRqU9I6JrSsoE5EhBQASSNSEyfqzJstqJ1HOtbNT6T6MYA7ZVhVC /nAf/Z0lZg8a3+93oHDlUlbX9GUoFBLlszy8+K6sWZfJ3djqB8dmUpCJvcfU02dUYs7v1x1PuWgNZ r7/ug8a4wpW/7N5MBPUGZqqE7gYdEMGGkLHYxtmW/JpJzwqHOxgmp9b5myJi2cXyitK3MULrPAfoI TUD3qnYZhX5jlwkIRvvjnwhf1RV5r84KEv9ltb1JKhCllZLwC93dsP6BxAuj4wtvTEVLR1/u7pMQL ZIV+Sbt4x0p4K1NoIr4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wMfcP-0000000FclB-2tNo; Tue, 12 May 2026 05:25:21 +0000 Received: from 2a02-8389-2341-5b80-decc-1a96-daaa-a2cc.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:decc:1a96:daaa:a2cc] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.99.1 #2 (Red Hat Linux)) id 1wMfcN-0000000FcaV-3M01; Tue, 12 May 2026 05:25:20 +0000 From: Christoph Hellwig To: Andrew Morton Cc: Catalin Marinas , Will Deacon , Ard Biesheuvel , Huacai Chen , WANG Xuerui , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Herbert Xu , Dan Williams , Chris Mason , David Sterba , Arnd Bergmann , Song Liu , Yu Kuai , Li Nan , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-crypto@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-arch@vger.kernel.org, linux-raid@vger.kernel.org Subject: [PATCH 14/19] raid6_kunit: use KUNIT_CASE_PARAM Date: Tue, 12 May 2026 07:20:54 +0200 Message-ID: <20260512052230.2947683-15-hch@lst.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260512052230.2947683-1-hch@lst.de> References: <20260512052230.2947683-1-hch@lst.de> MIME-Version: 1.0 X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The raid6 test combines various generation and recovery algorithms. Use KUNIT_CASE_PARAM and provide a generator that iterates over the possible combinations instead of looping inside a single test instance. Signed-off-by: Christoph Hellwig --- lib/raid/raid6/tests/raid6_kunit.c | 120 ++++++++++++++++------------- 1 file changed, 68 insertions(+), 52 deletions(-) diff --git a/lib/raid/raid6/tests/raid6_kunit.c b/lib/raid/raid6/tests/raid6_kunit.c index daaa28e96ff1..f55b081b6b13 100644 --- a/lib/raid/raid6/tests/raid6_kunit.c +++ b/lib/raid/raid6/tests/raid6_kunit.c @@ -21,6 +21,15 @@ static char data[NDISKS][PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); static char recovi[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); static char recovj[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); +struct test_args { + unsigned int recov_idx; + const struct raid6_recov_calls *recov; + unsigned int gen_idx; + const struct raid6_calls *gen; +}; + +static struct test_args args; + static void makedata(int start, int stop) { int i; @@ -43,9 +52,10 @@ static char member_type(int d) } } -static void test_disks(struct kunit *test, const struct raid6_calls *calls, - const struct raid6_recov_calls *ra, int faila, int failb) +static void test_recover(struct kunit *test, int faila, int failb) { + const struct test_args *ta = test->param_value; + memset(recovi, 0xf0, PAGE_SIZE); memset(recovj, 0xba, PAGE_SIZE); @@ -61,25 +71,23 @@ static void test_disks(struct kunit *test, const struct raid6_calls *calls, goto skip; /* P+Q failure. Just rebuild the syndrome. */ - calls->gen_syndrome(NDISKS, PAGE_SIZE, dataptrs); + ta->gen->gen_syndrome(NDISKS, PAGE_SIZE, dataptrs); } else if (failb == NDISKS - 2) { /* data+P failure. */ - ra->datap(NDISKS, PAGE_SIZE, faila, dataptrs); + ta->recov->datap(NDISKS, PAGE_SIZE, faila, dataptrs); } else { /* data+data failure. */ - ra->data2(NDISKS, PAGE_SIZE, faila, failb, dataptrs); + ta->recov->data2(NDISKS, PAGE_SIZE, faila, failb, dataptrs); } KUNIT_EXPECT_MEMEQ_MSG(test, data[faila], recovi, PAGE_SIZE, - "algo=%-8s/%-8s faila miscompared: %3d[%c] (failb=%3d[%c])\n", - calls->name, ra->name, - faila, member_type(faila), - failb, member_type(failb)); + "faila miscompared: %3d[%c] (failb=%3d[%c])\n", + faila, member_type(faila), + failb, member_type(failb)); KUNIT_EXPECT_MEMEQ_MSG(test, data[failb], recovj, PAGE_SIZE, - "algo=%-8s/%-8s failb miscompared: %3d[%c] (faila=%3d[%c])\n", - calls->name, ra->name, - failb, member_type(failb), - faila, member_type(faila)); + "failb miscompared: %3d[%c] (faila=%3d[%c])\n", + failb, member_type(failb), + faila, member_type(faila)); skip: dataptrs[faila] = data[faila]; @@ -88,58 +96,66 @@ static void test_disks(struct kunit *test, const struct raid6_calls *calls, static void raid6_test(struct kunit *test) { + const struct test_args *ta = test->param_value; int i, j, p1, p2; - unsigned int r, g; - - for (r = 0; ; r++) { - const struct raid6_recov_calls *ra = raid6_recov_algo_find(r); - - if (!ra) - break; - - for (g = 0; ; g++) { - const struct raid6_calls *calls = raid6_algo_find(g); - - if (!calls) - break; - /* Nuke syndromes */ - memset(data[NDISKS - 2], 0xee, PAGE_SIZE); - memset(data[NDISKS - 1], 0xee, PAGE_SIZE); + /* Nuke syndromes */ + memset(data[NDISKS - 2], 0xee, PAGE_SIZE); + memset(data[NDISKS - 1], 0xee, PAGE_SIZE); - /* Generate assumed good syndrome */ - calls->gen_syndrome(NDISKS, PAGE_SIZE, - (void **)&dataptrs); + /* Generate assumed good syndrome */ + ta->gen->gen_syndrome(NDISKS, PAGE_SIZE, (void **)&dataptrs); - for (i = 0; i < NDISKS-1; i++) - for (j = i+1; j < NDISKS; j++) - test_disks(test, calls, ra, i, j); + for (i = 0; i < NDISKS - 1; i++) + for (j = i + 1; j < NDISKS; j++) + test_recover(test, i, j); - if (!calls->xor_syndrome) - continue; + if (!ta->gen->xor_syndrome) + return; - for (p1 = 0; p1 < NDISKS-2; p1++) - for (p2 = p1; p2 < NDISKS-2; p2++) { + for (p1 = 0; p1 < NDISKS - 2; p1++) { + for (p2 = p1; p2 < NDISKS - 2; p2++) { + /* Simulate rmw run */ + ta->gen->xor_syndrome(NDISKS, p1, p2, PAGE_SIZE, + (void **)&dataptrs); + makedata(p1, p2); + ta->gen->xor_syndrome(NDISKS, p1, p2, PAGE_SIZE, + (void **)&dataptrs); - /* Simulate rmw run */ - calls->xor_syndrome(NDISKS, p1, p2, PAGE_SIZE, - (void **)&dataptrs); - makedata(p1, p2); - calls->xor_syndrome(NDISKS, p1, p2, PAGE_SIZE, - (void **)&dataptrs); + for (i = 0; i < NDISKS - 1; i++) + for (j = i + 1; j < NDISKS; j++) + test_recover(test, i, j); + } + } +} - for (i = 0; i < NDISKS-1; i++) - for (j = i+1; j < NDISKS; j++) - test_disks(test, calls, - ra, i, j); - } +static const void *raid6_gen_params(struct kunit *test, const void *prev, + char *desc) +{ + if (!prev) { + memset(&args, 0, sizeof(args)); +next_algo: + args.recov_idx = 0; + args.gen = raid6_algo_find(args.gen_idx); + if (!args.gen) + return NULL; + } - } + if (args.recov) + args.recov_idx++; + args.recov = raid6_recov_algo_find(args.recov_idx); + if (!args.recov) { + args.gen_idx++; + goto next_algo; } + + snprintf(desc, KUNIT_PARAM_DESC_SIZE, "gen=%s recov=%s", + args.gen->name, args.recov->name); + return &args; } static struct kunit_case raid6_test_cases[] = { - KUNIT_CASE(raid6_test), + KUNIT_CASE_PARAM(raid6_test, raid6_gen_params), {}, }; -- 2.53.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv