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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF7A2C433EF for ; Sun, 10 Apr 2022 02:29:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243280AbiDJCbH (ORCPT ); Sat, 9 Apr 2022 22:31:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243282AbiDJCbG (ORCPT ); Sat, 9 Apr 2022 22:31:06 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3B106338E for ; Sat, 9 Apr 2022 19:28:53 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id v4so772463edl.7 for ; Sat, 09 Apr 2022 19:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2GkARg2eLQk4U0SOAWwrR87e6jTIhF1FLiGo30eY7II=; b=bOPIg5nEnVq5/dOkk2slkVv0GnZs+Bq9ifiXYawxhM4d+vrwId4nLc9B54oAQOaJ5C F+jF6vAd8xSFJCqPXffBl+qOQOtJ/kSGx2mYert2MR5gK55+7tkudkhJMFL6FA3Wq4Cb K9dKfsIERDhI3NS/irXZtX6O5bWXs2AVjRjG3TNS6k1rv3vW4DmDGxOUrlzsx/XP6A2D iXtjfZTKDZ1n2o4qog3XVuXUEyfBJL+bAmMn5n+6L69gfJt+Cgeh2JzkYpKpzU5xDXvO RsOBLaUxgBNkK4SLQ7NUvew+MY4A3TyhDOO6xGmbL7o1mZop8pYb2oHYL7b8Zp8lrSZ4 zrZA== 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=2GkARg2eLQk4U0SOAWwrR87e6jTIhF1FLiGo30eY7II=; b=C5hiEH4aM07ODcBqDs7sGiaBXanlzVtKezYjEcuSflZ4mDFa0wpUObyUPesvcb5/Gw 3hwWO5R9z5mQL3nyyegMLeVBM6NVRDCyYBXdXg0yEmtkVP6uWgfA4udI9alwZ2vFMwUa Fa3zAldNSSUocTd1DI/ImoXgPlf4E3958UJUxBCS7fic9XKoxeoaIs7QJXoNjBYS4z6U Y6BLS6XqM9JWXhRPFwdJGE2CpjsPRzfDxTFF0XxZuAvf9CsxZIUfdjt/DnPx27rgktOc pjnh2bkdxhlCPxiYJnpC1HDNBl9DqLfBRTRQfbWtXe1We/0tFZ/d2HCSkiay9OvCjtGR 0F9w== X-Gm-Message-State: AOAM531skv7i4holeRYBC7N1oW5hoph2qe9VDLL7SzUUEjZ6QgAHj9+j IkuZqyqzR5b4VCWk1GvPFhQXmqaGx0an0VZjR2+aKg== X-Google-Smtp-Source: ABdhPJw7HwGZaK8WYofg/ix1YfzxwCkHaSYShdy2E6JN6OrpR+rX8DrYV/C47/rBx5BLt197ubBGSA== X-Received: by 2002:a05:6402:1e88:b0:419:746e:fb05 with SMTP id f8-20020a0564021e8800b00419746efb05mr26139998edf.307.1649557732153; Sat, 09 Apr 2022 19:28:52 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([104.245.96.34]) by smtp.gmail.com with ESMTPSA id g9-20020a056402424900b0041d10255257sm3890598edb.46.2022.04.09.19.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Apr 2022 19:28:51 -0700 (PDT) Date: Sun, 10 Apr 2022 10:28:46 +0800 From: Leo Yan To: carsten.haitzler@foss.arm.com Cc: linux-kernel@vger.kernel.org, coresight@lists.linaro.org, suzuki.poulose@arm.com, mathieu.poirier@linaro.org, mike.leach@linaro.org, linux-perf-users@vger.kernel.org, acme@kernel.org Subject: Re: [PATCH 2/3] perf test: Shell - only run .sh shell files to skip other files Message-ID: <20220410022846.GB14326@leoy-ThinkPad-X240s> References: <20220309122859.31487-1-carsten.haitzler@foss.arm.com> <20220309122859.31487-2-carsten.haitzler@foss.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220309122859.31487-2-carsten.haitzler@foss.arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org On Wed, Mar 09, 2022 at 12:28:58PM +0000, carsten.haitzler@foss.arm.com wrote: > From: Carsten Haitzler > > You edit your scripts in the tests and end up with your usual shell > backup files with ~ or .bak or something else at the end, but then your > next perf test run wants to run the backups too. You might also have perf > .data files in the directory or something else undesireable as well. You end > up chasing which test is the one you edited and the backup and have to keep > removing all the backup files, so automatically skip any files that are > not plain *.sh scripts to limit the time wasted in chasing ghosts. > > Signed-off-by: Carsten Haitzler > > --- > tools/perf/tests/builtin-test.c | 17 +++++++++++++++-- > 1 file changed, 15 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c > index 3c34cb766724..3a02ba7a7a89 100644 > --- a/tools/perf/tests/builtin-test.c > +++ b/tools/perf/tests/builtin-test.c > @@ -296,9 +296,22 @@ static const char *shell_test__description(char *description, size_t size, > > #define for_each_shell_test(entlist, nr, base, ent) \ > for (int __i = 0; __i < nr && (ent = entlist[__i]); __i++) \ > - if (!is_directory(base, ent) && \ > + if (ent->d_name[0] != '.' && \ > + !is_directory(base, ent) && \ > is_executable_file(base, ent) && \ > - ent->d_name[0] != '.') > + is_shell_script(ent->d_name)) Just nitpick: since multiple conditions are added, seems to me it's good to use a single function is_executable_shell_script() to make decision if a file is an executable shell script. And the condition checking 'ent->d_name[0] != '.'' would be redundant after we have checked the file suffix '.sh'. Thanks, Leo > + > +static bool is_shell_script(const char *file) > +{ > + const char *ext; > + > + ext = strrchr(file, '.'); > + if (!ext) > + return false; > + if (!strcmp(ext, ".sh")) > + return true; > + return false; > +} > > static const char *shell_tests__dir(char *path, size_t size) > { > -- > 2.32.0 >