diff --git a/devel/Makefile.am b/devel/Makefile.am index 979d021c03..42f21be75e 100644 --- a/devel/Makefile.am +++ b/devel/Makefile.am @@ -1,47 +1,53 @@ # # Copyright 2020 the Pacemaker project contributors # # The version control history for this file may have further details. # # This source code is licensed under the GNU General Public License version 2 # or later (GPLv2+) WITHOUT ANY WARRANTY. # -EXTRA_SCRIPTS = coccinelle/test/_testrunner.sh +EXTRA_SCRIPTS = coccinelle/test/testrunner.sh EXTRA_DIST = $(EXTRA_SCRIPTS) \ coccinelle/ref-passed-variables-inited.cocci \ - coccinelle/test/ref-passed-variables-inited.c + coccinelle/test/ref-passed-variables-inited.input.c \ + coccinelle/test/ref-passed-variables-inited.output # Coccinelle is a tool that takes special patch-like files (called semantic patches) and # applies them throughout a source tree. This is useful when refactoring, changing APIs, # catching dangerous or incorrect code, and other similar tasks. It's not especially # easy to write a semantic patch but most users should only be concerned about running # the target and inspecting the results. # # Documentation (including examples, which are the most useful): # http://coccinelle.lip6.fr/documentation.php # # Run the "make cocci" target to just output what would be done, or "make cocci-inplace" # to apply the changes to the source tree. # # COCCI_FILES may be set on the command line, if you want to test just a single file # while it's under development. Otherwise, it is a list of all the files that are ready # to be run. # # ref-passed-variables-inited.cocci seems to be returning some false positives around # GHashTableIters, so it is disabled for the moment. COCCI_FILES ?= cocci: for f in $(COCCI_FILES); do \ for d in daemons include lib tools; do \ test $$d = "include" \ && spatch $(_SPATCH_FLAGS) --include-headers --local-includes \ --preprocess --sp-file $$f --dir ../$$d \ || spatch $(_SPATCH_FLAGS) --local-includes \ --preprocess --sp-file $$f --dir ../$$d; \ done; \ done cocci-inplace: $(MAKE) $(AM_MAKEFLAGS) _SPATCH_FLAGS=--in-place cocci + +cocci-test: + for f in coccinelle/test/*.c; do \ + coccinelle/test/testrunner.sh $$f; \ + done diff --git a/devel/coccinelle/test/_testrunner.sh b/devel/coccinelle/test/_testrunner.sh deleted file mode 100755 index ee272c98b3..0000000000 --- a/devel/coccinelle/test/_testrunner.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env sh -set -eu -exec <&- -_tmpdir=$(mktemp -d /tmp/coccicheck-XXXXXX) -_bname=$(basename "$1") -_dname=$(dirname "$1") -sed -n '/#if 00/{n;:l;/#else/q;p;n;bl;}' "$1"> "${_tmpdir}/exp" -spatch --very-quiet --sp-file "${_dname}/../${_bname%.c}.cocci" "$1" \ - | tail -n+3 > "${_tmpdir}/out" -diff -u "${_tmpdir}/exp" "${_tmpdir}/out" -rm "${_tmpdir}"/* -rmdir "${_tmpdir}" diff --git a/devel/coccinelle/test/ref-passed-variables-inited.c b/devel/coccinelle/test/ref-passed-variables-inited.c deleted file mode 100755 index 476e1a6c36..0000000000 --- a/devel/coccinelle/test/ref-passed-variables-inited.c +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/sh -#if 0 -./$(dirname "$0")/_testrunner.sh "$0" < "${_tmpdir}/out" +diff -u "${_dname}/${_bname}.output" "${_tmpdir}/out" + +if [ -d "${_tmpdir}" ]; then + rm "${_tmpdir}"/* + rmdir "${_tmpdir}" +fi