All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 1/2] Add Coccinelle helper scripts for reference
Date: Wed, 9 Jun 2021 10:48:59 +0200	[thread overview]
Message-ID: <YMCAe9PO5NMToFOq@pevik> (raw)
In-Reply-To: <20210607141421.15072-1-rpalethorpe@suse.com>

Hi Richie,

> Check-in a couple of scripts used for removing the TEST macro from the
> library. Also a shell script to show how to run them. These are only
> intended to help someone develop their own refactoring scripts. Not
> for running automatically.
Nice, LGTM, with two notes bellow.

> +++ b/scripts/coccinelle/run-spatch.sh
> @@ -0,0 +1,39 @@
> +#!/bin/sh -eu
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 SUSE LLC  <rpalethorpe@suse.com>
> +
> +# Helper for running spatch Coccinelle scripts on the LTP source tree
> +
> +if [[ ! -d lib || ! -d scripts/coccinelle ]]; then
[[ ... ]] is bashism. It should be
if [ ! -d lib ] || [ ! -d scripts/coccinelle ]; then

or

> +    echo "$0: Can't find lib or scripts directories. Run me from top src dir"
> +    exit 1
> +fi
> +
> +# Run a script on the lib dir
> +libltp_spatch_report() {
> +    spatch --dir lib \
> +	   --ignore lib/parse_opts.c \
> +	   --ignore lib/newlib_tests \
> +	   --ignore lib/tests \
> +	   --use-gitgrep \
> +	   -D report \
> +	   --include-headers \
> +	   $*
> +}
> +
> +libltp_spatch_fix() {
> +    spatch --dir lib \
> +	   --ignore lib/parse_opts.c \
> +	   --ignore lib/newlib_tests \
> +	   --ignore lib/tests \
> +	   --use-gitgrep \
> +	   --in-place \
> +	   -D fix \
> +	   --include-headers \
> +	   $*
> +}
> +
> +echo You should uncomment one of the scripts below!
> +#libltp_spatch_report --sp-file scripts/coccinelle/libltp-test-macro.cocci
> +#libltp_spatch_report --sp-file scripts/coccinelle/libltp-test-macro-vars.cocci \
> +#		     --ignore lib/tst_test.c
Maybe have getopts to specify what needs to be running would prevent a need to
modify versioned file.

Kind regards,
Petr

  parent reply	other threads:[~2021-06-09  8:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07 14:14 [LTP] [PATCH v2 1/2] Add Coccinelle helper scripts for reference Richard Palethorpe
2021-06-07 14:14 ` [LTP] [PATCH v2 2/2] API: Remove TEST macro usage from library Richard Palethorpe
2021-06-09  8:48 ` Petr Vorel [this message]
2021-06-09 10:28   ` [LTP] [PATCH v2 1/2] Add Coccinelle helper scripts for reference Richard Palethorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YMCAe9PO5NMToFOq@pevik \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.