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 DE4A7C43334 for ; Wed, 29 Jun 2022 17:07:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3FDDB8E0018; Wed, 29 Jun 2022 13:07:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3ADE18E0015; Wed, 29 Jun 2022 13:07:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 275018E0018; Wed, 29 Jun 2022 13:07:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 15D768E0015 for ; Wed, 29 Jun 2022 13:07:40 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D5EE334D44 for ; Wed, 29 Jun 2022 17:07:39 +0000 (UTC) X-FDA: 79631905038.18.2F3FE6C Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) by imf15.hostedemail.com (Postfix) with ESMTP id 4AD3CA0026 for ; Wed, 29 Jun 2022 17:07:37 +0000 (UTC) Received: by mail-ot1-f65.google.com with SMTP id l9-20020a056830268900b006054381dd35so12644257otu.4 for ; Wed, 29 Jun 2022 10:07:36 -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=ani27qvWfhhMe/zeIF8mB9KZc5Lqz8+v8+hLYRP+d+I=; b=e4ElhJBCu4PRKQoutwrAAa3FolaIqIVKuJw+WU1xcRNo2oraMivRVMNZdkP5Ow7f95 B2vCDV+N+2td5HvyB8r9ZvbLZUwWmWtle7tih8Vh/gdqWxYf8gBXYnQ+62/LzfO8yYtP kdHBnNrYcilWzDnM7JB9YOfKnwcEYKrxNyLNVr26DcpeRpdcdetd+I2VumF7EZYrgO8b CAwuomluaGxYXE0f9z9alRjY9dC0/Wz96At8MK1t/mpZbZjdKBdQMx62/UKDLQwRWfCw /mx2Bbs7yA5xVbt778wyynKubAtUMHhuu1xk4xcowzHkMit5vjR+Z3Ej+H9wwqUEmmak c2sw== 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=ani27qvWfhhMe/zeIF8mB9KZc5Lqz8+v8+hLYRP+d+I=; b=JzrFHHzWJDllHAJguDuSHNS2n+ilKM2J7Ym597t/W+3DfpL0gyf4HdrUIozSxZheTy THzibnNEI2SO19GW0YxNW7FlerWBz/rPH6DSwPKKeNCmxoZWrGjHa8/u+BQxoZ5oVz4e hAlL6L4HhKRRBkMtcKnASrlDsT3oTqI6NX5jUBy0P4b00uRE4MZPkEVW+rWOaprO58dh RA+eHg0tgrZUB1tvT/Gev9AkaxzB+7oZQnAPAp02veNy/uU7nJii45ZnAFj1vAeszHw4 O2Rm54LjkzhwtlxyHTvjZzkei3EFF1y4SfOy5wOOnL7pwdhbCkH3172kRNVJMrvIenCG 46Kg== X-Gm-Message-State: AJIora86/zSmz9Bf5cUAoT0ODaXob9nOBng1S/L/AIw0wMlUh7TiV1pD FmDbALqEryf3l4aGPE4eOBM= X-Google-Smtp-Source: AGRyM1vQV5rs/uR2BoHI5x/1SCooR6Go9/KbU+5an7lTaqfEfh/z/cRVEsAnIwDji6f/fNSyJQLzOg== X-Received: by 2002:a9d:6291:0:b0:616:d7b2:5832 with SMTP id x17-20020a9d6291000000b00616d7b25832mr1801653otk.103.1656522456268; Wed, 29 Jun 2022 10:07:36 -0700 (PDT) Received: from bertie (072-190-140-117.res.spectrum.com. [72.190.140.117]) by smtp.gmail.com with ESMTPSA id u13-20020a056870f28d00b001048b819e13sm11289036oap.8.2022.06.29.10.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jun 2022 10:07:35 -0700 (PDT) Date: Wed, 29 Jun 2022 12:07:34 -0500 From: Rebecca Mckeever To: David Hildenbrand Cc: Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 2/4] memblock tests: add verbose output to memblock tests Message-ID: References: <883c28e34527fd4cdc55df97c791ed8b2e79538d.1656368930.git.remckee0@gmail.com> <5db2944e-9d64-8faa-83d3-fd02fce583bd@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5db2944e-9d64-8faa-83d3-fd02fce583bd@redhat.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656522458; a=rsa-sha256; cv=none; b=bQVkO32kRpl5B7OEAtX8r1HHCCB0H9uIUfHRtnK9IvlOxVyoPisEa4tyMPgkO2o1UrKsUD v2V1ewBUpYbRh76Dfl40l5sCGOeKp5xBFvKrLvUCswy9Qhqs4bJO3kw1VMqI+lmZ2zQWZN cTevh0JLuB3aYy7O4N0eg2S9L+4j00o= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=e4ElhJBC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of remckee0@gmail.com designates 209.85.210.65 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=1656522458; 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=ani27qvWfhhMe/zeIF8mB9KZc5Lqz8+v8+hLYRP+d+I=; b=gfpwOmFD8Tr9cbDYaybWIUxk6lLLnNOamcmJevFHBl7jNJoWOVwveXXlfITOvh5tSCIuW7 XOU5PzJMA40scfvnRCePJttfc0vQbQ3hj2+ajSczj6OIsZ2AS9Ea/8Z5H5eJubPfi5sOGe DErucw1x8LoDHUWJE64QLANO5hI642o= X-Rspam-User: X-Stat-Signature: kssu6c775yii97tkdppy86bjxqubywok X-Rspamd-Queue-Id: 4AD3CA0026 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=e4ElhJBC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of remckee0@gmail.com designates 209.85.210.65 as permitted sender) smtp.mailfrom=remckee0@gmail.com X-Rspamd-Server: rspam03 X-HE-Tag: 1656522456-842353 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 Wed, Jun 29, 2022 at 01:34:54PM +0200, David Hildenbrand wrote: > On 28.06.22 00:34, Rebecca Mckeever wrote: > > Add and use functions and macros 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 test_fail() and test_pass*(). > > > > - 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. > > > > - test_pass_pop(): runs test_pass() followed by prefix_pop(). > > > > - PREFIX_PUSH(): runs prefix_push(__func__). > > > > If the Memblock simulator was not compiled with VERBOSE=1, these > > functions/macros 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 > > > [...] > > > > > diff --git a/tools/testing/memblock/tests/common.c b/tools/testing/memblock/tests/common.c > > index 62d3191f7c9a..e55b2a8bf0ff 100644 > > --- a/tools/testing/memblock/tests/common.c > > +++ b/tools/testing/memblock/tests/common.c > > @@ -4,8 +4,12 @@ > > > > #define INIT_MEMBLOCK_REGIONS 128 > > #define INIT_MEMBLOCK_RESERVED_REGIONS INIT_MEMBLOCK_REGIONS > > +#define PREFIXES_LEN_MAX 256 > > +#define DELIM ": " > > +#define DELIM_LEN strlen(DELIM) > > Why not simply > > #define PREFIXES_MAX 15 > static const char * __maybe_unused prefixes[PREFIXES_MAX]; > static int nr_prefixes; > > And then simply insert/clear the corresponding prefixes[] pointer and > update nr_prefixes? > > When printing, you only have to walk prefixes from 0 ... nr_prefixes - 1 > and print the values. > > Avoids any string modifications. > What is nr_prefixes? Number of prefixes? Currently, the longest prefix is 49 characters (alloc_try_nid_bottom_up_reserved_with_space_check), so I think PREFIXES_MAX would need to be at least 52 (including the delimiter), but let me know if I'm misunderstanding. > > Anyhow, this LGTM > > Acked-by: David Hildenbrand > > -- > Thanks, > > David / dhildenb > Thanks, Rebecca