Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3744027pxb; Mon, 27 Sep 2021 01:19:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEcK5UYBPV5qk6kJyOFLG4D4yX8KolsfGCdSFTEkYrxwSeFSwRgY3gB2KNg5sFdl94Vxg+ X-Received: by 2002:a50:da85:: with SMTP id q5mr10573268edj.300.1632730753284; Mon, 27 Sep 2021 01:19:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632730753; cv=none; d=google.com; s=arc-20160816; b=dlPEIeU28W1HyOMiKsnTLA9md8h2dvEXDWtsjHyqzfFWAtdHUheVKIQ6TBmMlwhpdf 0ZgQT6blbygakAQDj55FUpsbgSa7rrmpe86nDNPCKsYE77cCVeTFh5u6FW/Chhzbv1MU FBmIKjCs+6epiikZeR3E9pG+ZDCP7J8e3Yggxrmuq8RYLX7p6ErSdaLzYU79wn7xQ0g/ HpI3LpLZOmu0QHmTsNwoNdI9f9VwPDUjT+bC+sjLS3ENDfXPbDBi4cgEuyTyEOF2I30D IZZxDfMTCtFKTVhpRh0xfDsRAOAjA2zzJOivH4bPb5qsWacx9G4vZnXgNI0ZhxZDwfuP KsoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=4FoCYB0R53oYzBihqJ0jC7V9Vzxsrx6Am9iqfRfp7sI=; b=L2dHWM/t8n4Lc72O4Gr1Q6salxyDcuJAuRhpMjhOWxtTOIMn86OhslfEvCJ38JUHvT Rolcw/WlAZ+r7FFx7Z1I4mgbqb2wBkXN775hvFNK7Vmi8YZwXejHWncdL8sHjklwI5Ix Kk2WD6iUlSxabgHz9AzyrWv3MKu+8PZJ7u82EWOXw3gSMQe2a3XSxq1fkB+X3WGW9wcF X/fZB+guGObwvpJwwLNJnn7zdoqufm7s+nyz9L/owMin/DZTZs9+eErbXjAz9kWz1pVw 2hAkw49AFbfDkp3D/NW4aEykKniVC6iejiWX5ZUjp1d5yJVFN2wjSJXWlaz9e4r5SqND PYfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Xd+AnOxf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o6si17174864eju.171.2021.09.27.01.18.50; Mon, 27 Sep 2021 01:19:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Xd+AnOxf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233411AbhI0IS7 (ORCPT + 99 others); Mon, 27 Sep 2021 04:18:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233368AbhI0IS7 (ORCPT ); Mon, 27 Sep 2021 04:18:59 -0400 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC330C061604 for ; Mon, 27 Sep 2021 01:17:21 -0700 (PDT) Received: by mail-oi1-x22b.google.com with SMTP id x124so24500130oix.9 for ; Mon, 27 Sep 2021 01:17:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4FoCYB0R53oYzBihqJ0jC7V9Vzxsrx6Am9iqfRfp7sI=; b=Xd+AnOxfDiFYeiOcZueBZXexoumw2PhRlFDAY4hLoG/UsDCNYvOv0Eo69YkjloOP9Z I7ouOJf+nhKWGDppjph7ngafcimWznTToLKCHlwXYcZTupOLZY+nGHFijPxeVl3Hgv15 Y6ryiE5CQhyGL+ccvnjVqkICgt1/GjRPv69F0feQVsQGXpL7kFte20u0CoGQhuHDXmLw HRGxo9nzaMTI8BLBHMx+U5ooOxWOnY2kfjfYiRR/qcBN44j6ENhjDOV5KNJtFP8utSVQ f3FCm5uZOCWRtzZ50FJKJftekarJ3LljNmw3A0mWH47TLRsHWFt4Gebui0WPrsyIAz3y RA/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4FoCYB0R53oYzBihqJ0jC7V9Vzxsrx6Am9iqfRfp7sI=; b=cPijSrxda9pnacdzsEkNKU2aytCDCiEuOLfa1/72C5r/kb4STqYpsuYKQfh0ycUHwm B9My8sEFRNiJY03IXmIIbdzgRuShZ8wU6MQGRXShQDSpJx3P5pX0rok2gknsaLQ6ssgZ OV+OPYN+SwYmluFPNZR7vOKNuGXDNaXvcrDt776cJmUm92KxbtsA0NLuYsnX/MMtJnN7 IJQitluOZAtOVLuXT6UTyWL2t6WlyJivC94bamjLQxx2j5DNvR5wb92t2UGNltJ6tmcA 5um1wX9LRM1C3QurfF8kxROb4dV0JFtNvcSVUMxrzgnh1zoJI5UCXOqdoXSBX4rxMo+d 1BQw== X-Gm-Message-State: AOAM530ussw/mWMkNzxnxYQ80SHSqmsOQ12HQ6QuBfsYqqqoIUL7ZuOp zmbBl1TBu9T0DZfVjY+eBGc8+D7JFNITeoPeAgk2tw== X-Received: by 2002:aca:db06:: with SMTP id s6mr11005425oig.70.1632730640739; Mon, 27 Sep 2021 01:17:20 -0700 (PDT) MIME-Version: 1.0 References: <20210926223322.848641-1-isabellabdoamaral@usp.br> <20210926223322.848641-4-isabellabdoamaral@usp.br> In-Reply-To: <20210926223322.848641-4-isabellabdoamaral@usp.br> From: Marco Elver Date: Mon, 27 Sep 2021 10:17:09 +0200 Message-ID: Subject: Re: [PATCH v2 3/5] test_hash.c: split test_hash_init To: Isabella Basso Cc: geert@linux-m68k.org, ferreiraenzoa@gmail.com, augusto.duraes33@gmail.com, brendanhiggins@google.com, dlatypov@google.com, davidgow@google.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com, ~lkcamp/patches@lists.sr.ht, rodrigosiqueiramelo@gmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 27 Sept 2021 at 00:33, 'Isabella Basso' via KUnit Development wrote: > > Split up test_hash_init so that it calls each test more explicitly > insofar it is possible without rewriting the entire file. This aims at > improving readability. > > Split tests performed on string_or as they don't interfere with those > performed in hash_or. Also separate pr_info calls about skipped tests as > they're not part of the tests themselves, but only warn about > (un)defined arch-specific hash functions. > > Changes since v1: > - As suggested by David Gow: > 1. Rename arch-specific test functions. > 2. Remove spare whitespace changes. > - As suggested by Marco Elver: > 1. Add struct for carrying test variables. Did the patches get mixed up? The struct doesn't appear to be introduced here. > Tested-by: David Gow > Signed-off-by: Isabella Basso > --- > lib/test_hash.c | 66 ++++++++++++++++++++++++++++++++++++++++--------- > 1 file changed, 54 insertions(+), 12 deletions(-) > > diff --git a/lib/test_hash.c b/lib/test_hash.c > index 08fe63776c4f..db9dd18b4e8b 100644 > --- a/lib/test_hash.c > +++ b/lib/test_hash.c > @@ -153,11 +153,39 @@ test_int_hash(unsigned long long h64, u32 hash_or[2][33]) > > #define SIZE 256 /* Run time is cubic in SIZE */ > > -static int __init > -test_hash_init(void) > +static int __init test_string_or(void) > { > char buf[SIZE+1]; > - u32 string_or = 0, hash_or[2][33] = { { 0, } }; > + u32 string_or = 0; > + int i, j; > + > + fill_buf(buf, SIZE, 1); > + > + /* Test every possible non-empty substring in the buffer. */ > + for (j = SIZE; j > 0; --j) { > + buf[j] = '\0'; > + > + for (i = 0; i <= j; i++) { > + u32 h0 = full_name_hash(buf+i, buf+i, j-i); > + > + string_or |= h0; > + } /* i */ > + } /* j */ > + > + /* The OR of all the hash values should cover all the bits */ > + if (~string_or) { > + pr_err("OR of all string hash results = %#x != %#x", > + string_or, -1u); > + return -EINVAL; > + } > + > + return 0; > +} > + > +static int __init test_hash_or(void) > +{ > + char buf[SIZE+1]; > + u32 hash_or[2][33] = { { 0, } }; > unsigned tests = 0; > unsigned long long h64 = 0; > int i, j; > @@ -187,7 +215,6 @@ test_hash_init(void) > return -EINVAL; > } > > - string_or |= h0; > h64 = h64 << 32 | h0; /* For use with hash_64 */ > if (!test_int_hash(h64, hash_or)) > return -EINVAL; > @@ -195,12 +222,6 @@ test_hash_init(void) > } /* i */ > } /* j */ > > - /* The OR of all the hash values should cover all the bits */ > - if (~string_or) { > - pr_err("OR of all string hash results = %#x != %#x", > - string_or, -1u); > - return -EINVAL; > - } > if (~hash_or[0][0]) { > pr_err("OR of all __hash_32 results = %#x != %#x", > hash_or[0][0], -1u); > @@ -232,6 +253,13 @@ test_hash_init(void) > } > } > > + pr_notice("%u tests passed.", tests); > + > + return 0; > +} > + > +static void __init notice_skipped_tests(void) > +{ > /* Issue notices about skipped tests. */ > #ifdef HAVE_ARCH__HASH_32 > #if HAVE_ARCH__HASH_32 != 1 > @@ -247,10 +275,24 @@ test_hash_init(void) > #else > pr_info("hash_64() has no arch implementation to test."); > #endif > +} > > - pr_notice("%u tests passed.", tests); > +static int __init > +test_hash_init(void) > +{ > + int ret; > > - return 0; > + ret = test_string_or(); > + if (ret < 0) > + return ret; > + > + ret = test_hash_or(); > + if (ret < 0) > + return ret; > + > + notice_skipped_tests(); > + > + return ret; > } > > static void __exit test_hash_exit(void) > -- > 2.33.0 > > -- > You received this message because you are subscribed to the Google Groups "KUnit Development" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kunit-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/20210926223322.848641-4-isabellabdoamaral%40usp.br.