Message ID | 20170625192950.17677-4-f4bug@amsat.org |
---|---|
State | New |
Headers | show |
On Sun, Jun 25, 2017 at 04:29:49PM -0300, Philippe Mathieu-Daudé wrote: > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > scripts/check-cocci-scripts.sh | 47 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 47 insertions(+) > create mode 100755 scripts/check-cocci-scripts.sh > > diff --git a/scripts/check-cocci-scripts.sh b/scripts/check-cocci-scripts.sh > new file mode 100755 > index 0000000000..ec3a8b39ef > --- /dev/null > +++ b/scripts/check-cocci-scripts.sh > @@ -0,0 +1,47 @@ > +#! /usr/bin/env bash > + > +test -d scripts/coccinelle || exit 1 > + > +SPATCH_IMAGE="philmd/coccinelle:1.0.4" > + > +GIT_AUTHOR_NAME="Coccinelle Spatch" > +GIT_COMMITTER_NAME="Coccinelle Spatch" > + > +if [ -n "$TRAVIS" ]; then > + # avoid stalling builds: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received > + TIMEOUT_S=530 > + TIMEOUT_CMD="timeout -k 550 500" > + EXTRA_ARGS="--timeout ${TIMEOUT_S}" > +else > + TIMEOUT_S=0 > +fi > + > +HEAD=19 #`echo -n scripts/coccinelle/ | wc -c` > +TAIL=6 #`echo -n .cocci | wc -c` > + > +test -z "$(${SUDO} docker images -q ${SPATCH_IMAGE})" && ${SUDO} docker pull ${SPATCH_IMAGE} > + Can the docker magic be made optional (and disabled by default), so people who already have Coccinelle installed can run this script more quickly? > +LOG=/tmp/cocci-spatch-$$ > +for script in scripts/coccinelle/*.cocci; do > + desc=${script:$HEAD:-$TAIL} > + echo -e "\nRunning ${script}...\n" > + echo -e "coccinelle: committing changes after running \"$desc\" script\n" > ${LOG}.topic > + ${TIMEOUT_CMD} ${SUDO} \ > + docker run --rm -v `pwd`:`pwd` -w `pwd` -u `id -u` \ > + ${SPATCH_IMAGE} --use-cache --use-gitgrep --keep-comments \ > + --very-quiet ${EXTRA_ARGS} \ > + --sp-file ${script} \ > + --macro-file scripts/cocci-macro-file.h \ > + --dir . \ > + --in-place | tee ${LOG}.content > + git add -u > + git diff --cached --exit-code -s > + if [ $? -ne 0 ]; then > + :> ${LOG}.content > + else > + test -s ${LOG}.content || continue > + fi > + cat ${LOG}.{topic,content} | git commit --allow-empty -F - > +done > + > +rm -f ${LOG}.{topic,content} > -- > 2.13.1 >
On Mon, Jun 26, 2017 at 11:17 PM, Eduardo Habkost <ehabkost@redhat.com> wrote: > On Sun, Jun 25, 2017 at 04:29:49PM -0300, Philippe Mathieu-Daudé wrote: [...] >> +test -z "$(${SUDO} docker images -q ${SPATCH_IMAGE})" && ${SUDO} docker pull ${SPATCH_IMAGE} >> + > > Can the docker magic be made optional (and disabled by default), so > people who already have Coccinelle installed can run this script more > quickly? Ok. Actually I didn't even think about running out of docker, the list of ocaml requisites scared me a bit. Using a dockerized spatch allow to stick to a common version (so I know the scripts I run locally will run exactly the same on Travis). But it makes sens ;) I tried the multi-threaded options and for some reason they did not work within docker, but I did not try out of it. Regards, Phil.
On Sun, 06/25 16:29, Philippe Mathieu-Daudé wrote: > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> > --- > scripts/check-cocci-scripts.sh | 47 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 47 insertions(+) > create mode 100755 scripts/check-cocci-scripts.sh > > diff --git a/scripts/check-cocci-scripts.sh b/scripts/check-cocci-scripts.sh > new file mode 100755 > index 0000000000..ec3a8b39ef > --- /dev/null > +++ b/scripts/check-cocci-scripts.sh > @@ -0,0 +1,47 @@ > +#! /usr/bin/env bash > + > +test -d scripts/coccinelle || exit 1 > + > +SPATCH_IMAGE="philmd/coccinelle:1.0.4" > + > +GIT_AUTHOR_NAME="Coccinelle Spatch" > +GIT_COMMITTER_NAME="Coccinelle Spatch" > + > +if [ -n "$TRAVIS" ]; then > + # avoid stalling builds: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received > + TIMEOUT_S=530 > + TIMEOUT_CMD="timeout -k 550 500" > + EXTRA_ARGS="--timeout ${TIMEOUT_S}" > +else > + TIMEOUT_S=0 > +fi > + > +HEAD=19 #`echo -n scripts/coccinelle/ | wc -c` > +TAIL=6 #`echo -n .cocci | wc -c` > + > +test -z "$(${SUDO} docker images -q ${SPATCH_IMAGE})" && ${SUDO} docker pull ${SPATCH_IMAGE} > + > +LOG=/tmp/cocci-spatch-$$ > +for script in scripts/coccinelle/*.cocci; do > + desc=${script:$HEAD:-$TAIL} > + echo -e "\nRunning ${script}...\n" > + echo -e "coccinelle: committing changes after running \"$desc\" script\n" > ${LOG}.topic > + ${TIMEOUT_CMD} ${SUDO} \ > + docker run --rm -v `pwd`:`pwd` -w `pwd` -u `id -u` \ > + ${SPATCH_IMAGE} --use-cache --use-gitgrep --keep-comments \ > + --very-quiet ${EXTRA_ARGS} \ > + --sp-file ${script} \ > + --macro-file scripts/cocci-macro-file.h \ > + --dir . \ > + --in-place | tee ${LOG}.content Is it possible to do an "incremental" run of coccinelle to only process affected files by a series (maybe on those files that are updated by an incremental make invocation)? That way we can save much time. BTW I think you should use whitespaces instead of tabs for indentation. Fam
diff --git a/scripts/check-cocci-scripts.sh b/scripts/check-cocci-scripts.sh new file mode 100755 index 0000000000..ec3a8b39ef --- /dev/null +++ b/scripts/check-cocci-scripts.sh @@ -0,0 +1,47 @@ +#! /usr/bin/env bash + +test -d scripts/coccinelle || exit 1 + +SPATCH_IMAGE="philmd/coccinelle:1.0.4" + +GIT_AUTHOR_NAME="Coccinelle Spatch" +GIT_COMMITTER_NAME="Coccinelle Spatch" + +if [ -n "$TRAVIS" ]; then + # avoid stalling builds: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received + TIMEOUT_S=530 + TIMEOUT_CMD="timeout -k 550 500" + EXTRA_ARGS="--timeout ${TIMEOUT_S}" +else + TIMEOUT_S=0 +fi + +HEAD=19 #`echo -n scripts/coccinelle/ | wc -c` +TAIL=6 #`echo -n .cocci | wc -c` + +test -z "$(${SUDO} docker images -q ${SPATCH_IMAGE})" && ${SUDO} docker pull ${SPATCH_IMAGE} + +LOG=/tmp/cocci-spatch-$$ +for script in scripts/coccinelle/*.cocci; do + desc=${script:$HEAD:-$TAIL} + echo -e "\nRunning ${script}...\n" + echo -e "coccinelle: committing changes after running \"$desc\" script\n" > ${LOG}.topic + ${TIMEOUT_CMD} ${SUDO} \ + docker run --rm -v `pwd`:`pwd` -w `pwd` -u `id -u` \ + ${SPATCH_IMAGE} --use-cache --use-gitgrep --keep-comments \ + --very-quiet ${EXTRA_ARGS} \ + --sp-file ${script} \ + --macro-file scripts/cocci-macro-file.h \ + --dir . \ + --in-place | tee ${LOG}.content + git add -u + git diff --cached --exit-code -s + if [ $? -ne 0 ]; then + :> ${LOG}.content + else + test -s ${LOG}.content || continue + fi + cat ${LOG}.{topic,content} | git commit --allow-empty -F - +done + +rm -f ${LOG}.{topic,content}
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- scripts/check-cocci-scripts.sh | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 scripts/check-cocci-scripts.sh