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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1B9AC433EF for ; Fri, 24 Jun 2022 07:18:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4040D8E01ED; Fri, 24 Jun 2022 03:18:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 38D558E01E7; Fri, 24 Jun 2022 03:18:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2066B8E01ED; Fri, 24 Jun 2022 03:18:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0B3A88E01E7 for ; Fri, 24 Jun 2022 03:18:52 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D037E1475 for ; Fri, 24 Jun 2022 07:18:51 +0000 (UTC) X-FDA: 79612277262.15.758ECC6 Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) by imf12.hostedemail.com (Postfix) with ESMTP id 662624001D for ; Fri, 24 Jun 2022 07:18:51 +0000 (UTC) Received: by mail-ot1-f66.google.com with SMTP id y16-20020a9d5190000000b0060c1292a5b9so1281307otg.3 for ; Fri, 24 Jun 2022 00:18:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TlCklXqXir+UR5t7qk7lKX7NWbT2pDB/489tY0Ei/lA=; b=T+gq6JuT5nQ06hgLvArGTAiVKwENDq4hRSLXFsagTHYICMKvtt6t89qiUO4tvltGsV OWe9Mh3AIFDyyhjKoMbyUeq/PuwCuC2nbjQ9oyQ75YrMUIpWjput+SWKDVJOruzqY1K/ +ImFg48zAaufC0Ja/vlG5Xb6bzpGUJuA+F1TgEDg/A9+/rafZXBcIZvrS9W0oaW380/T tgGoR1KIhSLkBJGCkBM4QqVP1DU6w5jp8WUed3CdlGljY79oqlpd4x/A7fnhUAk9+mkD nTU3Q2lqn933JbxWHjVKdQXL075Zk4sihan8lldsPRfA2SdtyQApoP+4OFxaf2U0lm9z pf5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TlCklXqXir+UR5t7qk7lKX7NWbT2pDB/489tY0Ei/lA=; b=PR1z6qS1VelG5TZjp/rdTH8yBZFXOYJNeMDarlYcuc5f1ISLwxOsLxSX66t5AZ+ofb vb0nwhZgtuwOoyl/T+ECqIBdjxTzJ9umSn+vSjCOb3dSyA/LhNgOv8je/0lnRGaC1Uly PYSCk4+KjBB96ldxNoZXIVfMs5S6OwB8zMEUriVkMjSOCGM6mqQ13xXFXw88iYxFYQ8H a5vQPvmhEPhyO94fQvAWXVdlBRymAriDz3HidisLVXW6Jc4CVHYLBGq9U5B8ZwAninix 9dk4Xx+cbyfjs+awQEpSaq97MEjV1Nq2EvnJfjfrOSIpG7iZe9Iw1XSe7TyyzirKXakv ewHA== X-Gm-Message-State: AJIora/+av/4vg1A3p/qfpAP9oi412ghJMq1R5CQzYCZ19oPbFRMjkSa vTz/asvhVs+mUsxTAcYPRWw= X-Google-Smtp-Source: AGRyM1snaUJxUjb5wrRsmmLAQLqK+mPMkAGmPKC1jmjCeNtoQscdDMz5Q444HxsO7WbSqOzQo5d3yA== X-Received: by 2002:a05:6830:2390:b0:60c:20cf:5946 with SMTP id l16-20020a056830239000b0060c20cf5946mr5540783ots.88.1656055130589; Fri, 24 Jun 2022 00:18:50 -0700 (PDT) Received: from bertie (072-190-140-117.res.spectrum.com. [72.190.140.117]) by smtp.gmail.com with ESMTPSA id l17-20020a05687014d100b000f349108868sm1330505oab.44.2022.06.24.00.18.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 00:18:50 -0700 (PDT) Date: Fri, 24 Jun 2022 02:18:48 -0500 From: Rebecca Mckeever To: Mike Rapoport Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, David Hildenbrand Subject: Re: [PATCH v3 2/4] memblock tests: add verbose output to memblock tests Message-ID: References: <004e021cc3cb7be8749361b3b1cb324459b9cb9f.1655889641.git.remckee0@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=T+gq6JuT; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of remckee0@gmail.com designates 209.85.210.66 as permitted sender) smtp.mailfrom=remckee0@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656055131; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TlCklXqXir+UR5t7qk7lKX7NWbT2pDB/489tY0Ei/lA=; b=R4HkdtJEXXTVOiDbhXhZ8qhJBjU5d+cS5PlsBRhsvbQXhPJDrDNWQ2/YH3pbkyIYa6HgfL qDLKNSeen5csCuri2+poA1G+ibjBwXe9YvhdBqpmW2fdw61YJs7I2+RBkUDw7ONGnWaDGh bm2OmLFwdURn4I1DLf81UdiMW4gTKww= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656055131; a=rsa-sha256; cv=none; b=jAtm5kHg030xZkC1+VC8V4gtqZAkGqhimykpACKaXWgswM8G3sLOYCcERhTKdepJYZ9Mq9 18r/cjZPiP44uPxojf3Gflj9O72RyIN+d2044e/QDT8Hc7mQndmGUkm5lYmNS6UMOze0dE cT/exnIhMGhXurkmrmJ+Cme1p6kg0no= X-Stat-Signature: tpj3emwwiyc4c4jwe8y19hetdqcmf16o X-Rspamd-Queue-Id: 662624001D X-Rspam-User: Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=T+gq6JuT; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of remckee0@gmail.com designates 209.85.210.66 as permitted sender) smtp.mailfrom=remckee0@gmail.com X-Rspamd-Server: rspam12 X-HE-Tag: 1656055131-270798 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jun 23, 2022 at 09:40:30AM -0500, Mike Rapoport wrote: > On Thu, Jun 23, 2022 at 01:30:42AM -0500, Rebecca Mckeever wrote: > > On Wed, Jun 22, 2022 at 11:30:10PM -0500, Mike Rapoport wrote: > > > On Wed, Jun 22, 2022 at 04:29:07AM -0500, Rebecca Mckeever wrote: > > > > Add and use functions for printing verbose testing output. > > > > > > > > If the Memblock simulator was compiled with VERBOSE=1: > > > > prefix_push() appends the given string to a prefix string that will be > > > > printed in the test functions. > > > > prefix_pop() removes the last prefix from the prefix string. > > > > prefix_reset() clears the prefix string. > > > > test_fail() prints a message after a test fails containing the test > > > > number of the failing test and the prefix. > > > > test_pass() prints a message after a test passes containing its test > > > > number and the prefix. > > > > test_print() prints the given formatted output string. > > > > > > > > If the Memblock simulator was not compiled with VERBOSE=1, these > > > > functions do nothing. > > > > > > > > Add the assert wrapper macros ASSERT_EQ(), ASSERT_NE(), and ASSERT_LT(). > > > > If the assert condition fails, these macros call test_fail() before > > > > executing assert(). > > > > > > > > Signed-off-by: Rebecca Mckeever > > > > --- > > > > tools/testing/memblock/tests/alloc_api.c | 241 ++++++++---- > > > > .../memblock/tests/alloc_helpers_api.c | 135 +++++-- > > > > tools/testing/memblock/tests/alloc_nid_api.c | 371 ++++++++++++------ > > > > tools/testing/memblock/tests/basic_api.c | 365 ++++++++++++----- > > > > tools/testing/memblock/tests/common.c | 58 +++ > > > > tools/testing/memblock/tests/common.h | 54 +++ > > > > 6 files changed, 880 insertions(+), 344 deletions(-) > > > > > > > > diff --git a/tools/testing/memblock/tests/alloc_api.c b/tools/testing/memblock/tests/alloc_api.c > > > > index d1aa7e15c18d..96df033d4300 100644 > > > > --- a/tools/testing/memblock/tests/alloc_api.c > > > > +++ b/tools/testing/memblock/tests/alloc_api.c > > > > > > ... > > > > > > > @@ -729,6 +820,12 @@ static int alloc_no_memory_check(void) > > > > > > > > int memblock_alloc_checks(void) > > > > { > > > > + static const char func_testing[] = "memblock_alloc"; > > > > + > > > > + prefix_reset(); > > > > + prefix_push(func_testing); > > > > + test_print("Running %s tests...\n", func_testing); > > > > > > Why not > > > > > > test_print("Running memblock_alloc tests...\n"); > > > > > > ? > > > > > > (applies to other cases below) > > > > Both prefix_push() and test_print() are using that string, and I thought > > it made sense to use a constant instead of hard coding the string in both > > places. Is it better to hard code the string in this case? > > Oh, missed that. > I'd drop static, it doesn't really matter here. > Will do. > > > > + > > > > reset_memblock_attributes(); > > > > dummy_physical_memory_init(); > > > > > > ... > > > > > > > diff --git a/tools/testing/memblock/tests/alloc_helpers_api.c b/tools/testing/memblock/tests/alloc_helpers_api.c > > > > index 963a966db461..f6eaed540427 100644 > > > > --- a/tools/testing/memblock/tests/alloc_helpers_api.c > > > > +++ b/tools/testing/memblock/tests/alloc_helpers_api.c > > > > > > ... > > > > > > > @@ -378,6 +423,12 @@ static int alloc_from_min_addr_cap_check(void) > > > > > > > > int memblock_alloc_helpers_checks(void) > > > > { > > > > + static const char func_testing[] = "memblock_alloc_from"; > > > > + > > > > + prefix_reset(); > > > > + prefix_push(func_testing); > > > > + test_print("Running %s tests...\n", func_testing); > > > > + > > > > reset_memblock_attributes(); > > > > dummy_physical_memory_init(); > > > > > > > > diff --git a/tools/testing/memblock/tests/alloc_nid_api.c b/tools/testing/memblock/tests/alloc_nid_api.c > > > > index 6390206e50e1..601f4a7ee30d 100644 > > > > --- a/tools/testing/memblock/tests/alloc_nid_api.c > > > > +++ b/tools/testing/memblock/tests/alloc_nid_api.c > > > > > > ... > > > > > > > @@ -1150,6 +1263,12 @@ static int alloc_try_nid_low_max_check(void) > > > > > > > > int memblock_alloc_nid_checks(void) > > > > { > > > > + static const char func_testing[] = "memblock_alloc_try_nid"; > > > > + > > > > + prefix_reset(); > > > > + prefix_push(func_testing); > > > > + test_print("Running %s tests...\n", func_testing); > > > > + > > > > reset_memblock_attributes(); > > > > dummy_physical_memory_init(); > > > > > > > > @@ -1170,5 +1289,7 @@ int memblock_alloc_nid_checks(void) > > > > > > > > dummy_physical_memory_cleanup(); > > > > > > > > + prefix_pop(); > > > > + > > > > return 0; > > > > } > > > > diff --git a/tools/testing/memblock/tests/basic_api.c b/tools/testing/memblock/tests/basic_api.c > > > > index a7bc180316d6..f223a9a57be7 100644 > > > > --- a/tools/testing/memblock/tests/basic_api.c > > > > +++ b/tools/testing/memblock/tests/basic_api.c > > > > @@ -4,21 +4,30 @@ > > > > #include "basic_api.h" > > > > > > > > #define EXPECTED_MEMBLOCK_REGIONS 128 > > > > +#define FUNC_ADD "memblock_add" > > > > +#define FUNC_RESERVE "memblock_reserve" > > > > +#define FUNC_REMOVE "memblock_remove" > > > > +#define FUNC_FREE "memblock_free" > > > > > > > > static int memblock_initialization_check(void) > > > > { > > > > - assert(memblock.memory.regions); > > > > - assert(memblock.memory.cnt == 1); > > > > - assert(memblock.memory.max == EXPECTED_MEMBLOCK_REGIONS); > > > > - assert(strcmp(memblock.memory.name, "memory") == 0); > > > > + prefix_push(__func__); > > > > > > > > - assert(memblock.reserved.regions); > > > > - assert(memblock.reserved.cnt == 1); > > > > - assert(memblock.memory.max == EXPECTED_MEMBLOCK_REGIONS); > > > > - assert(strcmp(memblock.reserved.name, "reserved") == 0); > > > > + ASSERT_NE(memblock.memory.regions, NULL); > > > > + ASSERT_EQ(memblock.memory.cnt, 1); > > > > + ASSERT_EQ(memblock.memory.max, EXPECTED_MEMBLOCK_REGIONS); > > > > + ASSERT_EQ(strcmp(memblock.memory.name, "memory"), 0); > > > > > > > > - assert(!memblock.bottom_up); > > > > - assert(memblock.current_limit == MEMBLOCK_ALLOC_ANYWHERE); > > > > + ASSERT_NE(memblock.reserved.regions, NULL); > > > > + ASSERT_EQ(memblock.reserved.cnt, 1); > > > > + ASSERT_EQ(memblock.memory.max, EXPECTED_MEMBLOCK_REGIONS); > > > > + ASSERT_EQ(strcmp(memblock.reserved.name, "reserved"), 0); > > > > + > > > > + ASSERT_EQ(memblock.bottom_up, false); > > > > + ASSERT_EQ(memblock.current_limit, MEMBLOCK_ALLOC_ANYWHERE); > > > > + > > > > + test_pass(); > > > > + prefix_pop(); > > > > > > > > return 0; > > > > } > > > > @@ -40,14 +49,19 @@ static int memblock_add_simple_check(void) > > > > .size = SZ_4M > > > > }; > > > > > > > > + prefix_push(__func__); > > > > + > > > > reset_memblock_regions(); > > > > memblock_add(r.base, r.size); > > > > > > > > - assert(rgn->base == r.base); > > > > - assert(rgn->size == r.size); > > > > + ASSERT_EQ(rgn->base, r.base); > > > > + ASSERT_EQ(rgn->size, r.size); > > > > + > > > > + ASSERT_EQ(memblock.memory.cnt, 1); > > > > + ASSERT_EQ(memblock.memory.total_size, r.size); > > > > > > > > - assert(memblock.memory.cnt == 1); > > > > - assert(memblock.memory.total_size == r.size); > > > > + test_pass(); > > > > + prefix_pop(); > > > > > > > > return 0; > > > > } > > > > @@ -69,18 +83,27 @@ static int memblock_add_node_simple_check(void) > > > > .size = SZ_16M > > > > }; > > > > > > > > + prefix_pop(); > > > > + prefix_push("memblock_add_node"); > > > > + prefix_push(__func__); > > > > > > I think there is no need to change the prefix from memblock_add to > > > memblock_add_node here. > > > > > > ok 3 : memblock_add: memblock_add_node_simple_check: passed > > > > > > provides enough information. > > > > > > > Will do. > > > > > > + > > > > reset_memblock_regions(); > > > > memblock_add_node(r.base, r.size, 1, MEMBLOCK_HOTPLUG); > > > > > > > > - assert(rgn->base == r.base); > > > > - assert(rgn->size == r.size); > > > > + ASSERT_EQ(rgn->base, r.base); > > > > + ASSERT_EQ(rgn->size, r.size); > > > > #ifdef CONFIG_NUMA > > > > - assert(rgn->nid == 1); > > > > + ASSERT_EQ(rgn->nid, 1); > > > > #endif > > > > - assert(rgn->flags == MEMBLOCK_HOTPLUG); > > > > + ASSERT_EQ(rgn->flags, MEMBLOCK_HOTPLUG); > > > > + > > > > + ASSERT_EQ(memblock.memory.cnt, 1); > > > > + ASSERT_EQ(memblock.memory.total_size, r.size); > > > > > > > > - assert(memblock.memory.cnt == 1); > > > > - assert(memblock.memory.total_size == r.size); > > > > + test_pass(); > > > > + prefix_pop(); > > > > + prefix_pop(); > > > > + prefix_push(FUNC_ADD); > > > > > > > > return 0; > > > > } > > > > > > -- > > > Sincerely yours, > > > Mike. > > > > Thanks, > > Rebecca > > -- > Sincerely yours, > Mike.