From: Colin Vidal Date: Tue, 14 Oct 2025 12:01:42 +0000 (+0200) Subject: run individual spatch form check-cocci.sh X-Git-Tag: v9.21.15~47^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=085bf46a09f193afd3fcb634cd695dfaa967f145;p=thirdparty%2Fbind9.git run individual spatch form check-cocci.sh Add util/check-cocci.sh support for a command-line argument which is a path to a spatch file. Running `util/check-cocci.sh` runs all the spatch in `cocci` folder. Running `util/check-cocci.sh cocci/foo.spatch` only run the spatch `cocci/foo.spatch`. Any command line parameters after `--` are forwarded to `spatch` command, for instance: `util/check-cocci.sh -- --debug` `util/check-cocci.sh cocci/foo.spatch -- --debug` Will (1) run all spatch files in cocci/ with --debug spatch option and (2) run only `cocci/foo.spatch` with --debug options. --- diff --git a/util/check-cocci.sh b/util/check-cocci.sh index 1f749b137a3..5dd382c6ad5 100755 --- a/util/check-cocci.sh +++ b/util/check-cocci.sh @@ -12,11 +12,16 @@ # information regarding copyright ownership. ret=0 -for spatch in cocci/*.spatch; do - patch="$(dirname "$spatch")/$(basename "$spatch" .spatch).patch" + +run_spatch() { + local spatch=$1 + shift + local spatchargs="$@" + local patch="$(dirname "$spatch")/$(basename "$spatch" .spatch).patch" + : >"$patch" echo "Applying semantic patch $spatch..." - spatch --jobs "${TEST_PARALLEL_JOBS:-1}" --sp-file "$spatch" --use-gitgrep --dir "." --very-quiet --include-headers "$@" >>"$patch" 2>cocci.stderr + spatch --jobs "${TEST_PARALLEL_JOBS:-1}" --sp-file "$spatch" --use-gitgrep --dir "." --include-headers $spatchargs >>"$patch" 2>cocci.stderr cat cocci.stderr if grep -q -e "parse error" cocci.stderr; then ret=1 @@ -27,8 +32,35 @@ for spatch in cocci/*.spatch; do else rm "$patch" fi +} + +spatchargs="" +spatchfile="" + +for arg in "$@"; do + if [ "$arg" = "--" ]; then + shift + spatchargs="$@" + break + fi + + if [ -z "$spatchfile" ]; then + spatchfile="$arg" + shift + else + echo "USAGE: $0 [spatch-file] [-- spatch arguments]" + exit 1 + fi done +if [ -n "$spatchfile" ]; then + run_spatch $spatchfile $spatchargs +else + for spatch in cocci/*.spatch; do + run_spatch $spatch --very-quiet $spatchargs + done +fi + rm -f cocci.stderr exit $ret