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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7224C2B9F4 for ; Thu, 17 Jun 2021 14:53:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF705610A1 for ; Thu, 17 Jun 2021 14:53:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232221AbhFQOze (ORCPT ); Thu, 17 Jun 2021 10:55:34 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:40664 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232359AbhFQOzF (ORCPT ); Thu, 17 Jun 2021 10:55:05 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 65A1C1FD7D; Thu, 17 Jun 2021 14:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1623941576; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Q7q0OZNtypGAEjCrcoo+ttjQVNFn1Ky9KY47NqMeoHE=; b=swr8RaWpri8QMRimhSLL+MkiXIZp1KJaciCMlH71yrQPWh9RackYe0xdVbd+MOvvLq0wSG pviYRxCu1hhV/SGLMmfHsCdasxmK4ZEY9vkWSEMzcqEljci6lKbLjwt60+SQHl1rS/wVEC pTdTyAh32KJvNY+knLY20D/4Zgx2rl8= Received: from suse.cz (unknown [10.100.224.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id DB893A3BB9; Thu, 17 Jun 2021 14:52:55 +0000 (UTC) Date: Thu, 17 Jun 2021 16:52:55 +0200 From: Petr Mladek To: Andy Shevchenko Cc: Jia He , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes , Jonathan Corbet , Alexander Viro , Linus Torvalds , "Peter Zijlstra (Intel)" , Eric Biggers , "Ahmed S. Darwish" , Linux Documentation List , Linux Kernel Mailing List , Linux FS Devel , Matthew Wilcox Subject: Re: [PATCH RFCv4 4/4] lib/test_printf.c: add test cases for '%pD' Message-ID: References: <20210615154952.2744-1-justin.he@arm.com> <20210615154952.2744-5-justin.he@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue 2021-06-15 23:47:29, Andy Shevchenko wrote: > On Tue, Jun 15, 2021 at 6:55 PM Jia He wrote: > > > > After the behaviour of specifier '%pD' is changed to print full path > > of struct file, the related test cases are also updated. > > > > Given the string of '%pD' is prepended from the end of the buffer, the > > check of "wrote beyond the nul-terminator" should be skipped. > > > > Signed-off-by: Jia He > > --- > > lib/test_printf.c | 26 +++++++++++++++++++++++++- > > 1 file changed, 25 insertions(+), 1 deletion(-) > > > > diff --git a/lib/test_printf.c b/lib/test_printf.c > > index d1d2f898ebae..9f851a82b3af 100644 > > --- a/lib/test_printf.c > > +++ b/lib/test_printf.c > > @@ -78,7 +80,7 @@ do_test(int bufsize, const char *expect, int elen, > > return 1; > > } > > > > - if (memchr_inv(test_buffer + written + 1, FILL_CHAR, bufsize - (written + 1))) { > > > + if (!is_prepended_buf && memchr_inv(test_buffer + written + 1, FILL_CHAR, bufsize - (written + 1))) { > > Can it be parametrized? I don't like the custom test case being > involved here like this. Yup, it would be nice. Also it is far from obvious what @is_prepended_buf means if you do not have context of this patchset. I think about a more generic name that comes from the wording used in 3rd patch, e.g. @need_scratch_space or @using_scratch_space or @dirty_buf Anyway, the most easy way to pass this as a parameter would be to add it to __test() and define a wrapper, .e.g: static void __printf(3, 4) __init __test(const char *expect, int elen, bool using_scratch_space, const char *fmt, ...) /* * More relaxed test for non-standard formats that are using the provided buffer * as a scratch space and write beyond the trailing '\0'. */ #define test_using_scratch_space(expect, fmt, ...) \ __test(expect, strlen(expect), true, fmt, ##__VA_ARGS__) Best Regards, Petr