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 745DBC43334 for ; Wed, 29 Jun 2022 11:35:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F2346B0071; Wed, 29 Jun 2022 07:34:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A19F6B0073; Wed, 29 Jun 2022 07:34:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 469808E0002; Wed, 29 Jun 2022 07:34:59 -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 37DB86B0071 for ; Wed, 29 Jun 2022 07:34:59 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 1099F60BE9 for ; Wed, 29 Jun 2022 11:34:59 +0000 (UTC) X-FDA: 79631066718.08.7A4172F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 9344A18003D for ; Wed, 29 Jun 2022 11:34:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656502498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sDPyX9bt2HpOiFPkmoMHHpjNaKTkyBrVmLwrrW6VGXE=; b=EmQjjtDpmxgMA4MG5iFNkps5HmvjkP47CaXup3J90LJ7ithVcTF1X3w4/VcKpukWv4beeb YfKqWB1to5INVUGGYurzU0XVn4Ly0U5czyfDRSFaUUEOZXdxFrl0DnTo44ZmUp+aan+qIm w/qExmnf0IrHGqE/09JEHuFXpBhxzUs= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-633-rxCOEOkAMwuoyBq7RmeK7g-1; Wed, 29 Jun 2022 07:34:56 -0400 X-MC-Unique: rxCOEOkAMwuoyBq7RmeK7g-1 Received: by mail-wm1-f70.google.com with SMTP id n35-20020a05600c3ba300b003a02d7bd5caso8559928wms.2 for ; Wed, 29 Jun 2022 04:34:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:organization:in-reply-to :content-transfer-encoding; bh=sDPyX9bt2HpOiFPkmoMHHpjNaKTkyBrVmLwrrW6VGXE=; b=awI3hfYVOIH+o8H0sKOX/oDURtyFL0d3JaHJNqA4SMezedLUPNXPGIBs8PE5ZsG9ID r8mqXxNMQPTIZ7/eBBQC0WL3X0M6kseBkKsaj+Nnrw12lpkG/jvmt0pJrsjCmFcnu1h+ 6WoGFBesE+r83kBGqFzHLrcSMV5fuu1R3bL6t8LL1pE6DHZIM2iTM2MHD0URdCZ2msoZ ywOp9yWFv/tySc92irBJfQ9trKKB6b9NBxqGWhwUrIvigyLiRqr6q9VL7iOwllcsiE4Y qijg9C6w2wTS2D7f49MwDlIoLCQoIElQhZ4M3BjrK/1s+AOOPDEEwPLO2A6yOglUndrT +tlg== X-Gm-Message-State: AJIora/PPa7UHrfccAqLSxAFOC+gk0uKk4LeTjOfZkSTk0x5MBoKxF1c rEBHJ7FHN9GRaB8HWDISSo+jvA8WKauATF8g8DjSCURAog/V5VGIzG9gmYdrJtjQ4+gnIWaLSFo 6B3ZLFxJJncc= X-Received: by 2002:a05:6000:1541:b0:21d:2afa:17ed with SMTP id 1-20020a056000154100b0021d2afa17edmr2247624wry.311.1656502495745; Wed, 29 Jun 2022 04:34:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u3XLB5CcpJjlAAgk6ocajqIVVWthKRl+wXrWoZ5+rko6PsxgOQ96w23HFad6LRYYByOL54BA== X-Received: by 2002:a05:6000:1541:b0:21d:2afa:17ed with SMTP id 1-20020a056000154100b0021d2afa17edmr2247606wry.311.1656502495471; Wed, 29 Jun 2022 04:34:55 -0700 (PDT) Received: from ?IPV6:2003:cb:c708:e600:d4fa:af4b:d7b6:20df? (p200300cbc708e600d4faaf4bd7b620df.dip0.t-ipconnect.de. [2003:cb:c708:e600:d4fa:af4b:d7b6:20df]) by smtp.gmail.com with ESMTPSA id q3-20020a1c4303000000b003a03185231bsm2775257wma.31.2022.06.29.04.34.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jun 2022 04:34:54 -0700 (PDT) Message-ID: <5db2944e-9d64-8faa-83d3-fd02fce583bd@redhat.com> Date: Wed, 29 Jun 2022 13:34:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v4 2/4] memblock tests: add verbose output to memblock tests To: Rebecca Mckeever , Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <883c28e34527fd4cdc55df97c791ed8b2e79538d.1656368930.git.remckee0@gmail.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <883c28e34527fd4cdc55df97c791ed8b2e79538d.1656368930.git.remckee0@gmail.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656502498; a=rsa-sha256; cv=none; b=hI/CaV+2jFxWPPpEIDtl+nSuGasRu3qd1nExSfM7N2wDbUYv5HBX+hgK9QcqjsP0+FTYGQ s6F7xOjoU3prK9RkUS+lW4KMPwgrVj7RXoqhIG1KejLe/FFqoXJnhLNtzwCw4Q/ZKOEake X/Ll5aYXxA8WGfEkSHt/SzjJpcZ3JdI= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EmQjjtDp; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf16.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656502498; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sDPyX9bt2HpOiFPkmoMHHpjNaKTkyBrVmLwrrW6VGXE=; b=v66JFmLK1WEkiJKJc27HIUopWVGUe8ewD7ln2RMk2WVPSc0y0kFcjLFaZqiBdRLw9HH0+S wK6h52gACtGE7UqjyxvxwCnGFDn6cFFH3/1eduBlWgjSE5vrNdFK6i+ObF6ZD+WmGA8alA ZMGkpJvTeAQ5FKGfoqsvzKLE/GCfXDk= X-Stat-Signature: m395as4ocpn6wen554u1uy43hph8fgzd X-Rspamd-Queue-Id: 9344A18003D Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EmQjjtDp; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf16.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1656502498-330377 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 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. Anyhow, this LGTM Acked-by: David Hildenbrand -- Thanks, David / dhildenb