From 7629fad1e35204bbe7fac5685c837de2008dc9d4 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 21 Jun 2017 17:57:44 +0200 Subject: [PATCH] TT#17650 Create syntaxcheck to identify bash/perl/python errors during build time devscripts is necessary for checkbashisms. python is necessary for pythoncheck. libconfig-tiny-perl, libhash-merge-perl, libyaml-libyaml-perl are necessary for bin/create_lnp.pl. liblist-allutils-perl is necessary for bin/create_subscribers.pl. libtemplate-perl is necessary for bin/generate_test.pl. libjson-perl + libgraphviz-perl are necessary for bin/graph_flow.pl libtext-csv-perl is necessary for bin/scenario.pl While at it update the runtime dependencies accordingly which were identified with the syntaxchecks. Change-Id: Ia60b215c5d97918457ea1b417477f204818b5eeb --- Makefile | 42 ++++++++++++++++++++++++++++++++++++++++++ debian/control | 17 +++++++++++++++-- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9cf78a6a..dab30338 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,52 @@ SCENARIOS:=$(shell find -maxdepth 1 -type d -name 'scenarios*'|sed 's_\./__g') TESTS=$(addprefix test_,$(SCENARIOS)) +BASH_SCRIPTS = bench.sh get_results.sh run_tests.sh t/testrunner bin/*.sh +PERL_SCRIPTS = bin/*.pl +PYTHON_SCRIPTS = tests/test_check.py tests/test_yaml_format.py bin/*.py +SHELL_SCRIPTS = tests/do_test_yaml_format.sh + RESULTS ?= reports # do nothing as default all: + $(MAKE) syntaxcheck + +syntaxcheck: bashismcheck perlcheck pythoncheck shellcheck + +bashismcheck: + @echo -n "Checking for bashisms: "; \ + for SCRIPT in $(SHELL_SCRIPTS); do \ + checkbashisms -x $${SCRIPT} || exit 1 ; \ + done; \ + echo "done."; \ + +perlcheck: + @echo "Checking for perl syntax errors: "; \ + mkdir -p perl-dummy/Sipwise ; \ + for f in Sipwise/API.pm ; do \ + echo '1;' > perl-dummy/$$f ; \ + done; \ + for SCRIPT in $(PERL_SCRIPTS); do \ + perl -Iperl-dummy/ -cw $${SCRIPT} || exit 1 ; \ + done; \ + rm -r perl-dummy ; \ + echo "-> perl check done."; \ + +pythoncheck: + @echo -n "Checking for python syntax errors: "; \ + for SCRIPT in $(PYTHON_SCRIPTS); do \ + python -m py_compile $${SCRIPT} || exit 1 ; \ + rm $${SCRIPT}c # get rid of pyc files ; \ + done; \ + echo "done."; \ + +shellcheck: + @echo -n "Checking for shell syntax errors: "; \ + for SCRIPT in $(BASH_SCRIPTS) $(SHELL_SCRIPTS); do \ + bash -n $${SCRIPT} || exit ; \ + done; \ + echo "done."; \ # python-junitxml 0.6 has this bug # https://bugs.launchpad.net/pyjunitxml/+bug/892293 diff --git a/debian/control b/debian/control index ad219271..a2b4112b 100644 --- a/debian/control +++ b/debian/control @@ -4,19 +4,30 @@ Priority: extra Maintainer: Sipwise Development Team Build-Depends: debhelper (>= 9), + devscripts, + libconfig-tiny-perl, + libgraphviz-perl, + libhash-merge-perl, + libjson-perl, + liblist-allutils-perl, + libtemplate-perl, + libtext-csv-perl, + libyaml-libyaml-perl, + python, Standards-Version: 3.9.8 Homepage: https://www.sipwise.com/ Package: kamailio-config-tests Architecture: all Depends: - ${misc:Depends}, - ${perl:Depends}, curl, + libconfig-tiny-perl, libfile-slurp-perl, libgraphviz-perl, + libhash-merge-perl, libio-compress-perl, libjson-perl, + liblist-allutils-perl, libtemplate-perl, libtext-csv-perl, libyaml-libyaml-perl, @@ -27,5 +38,7 @@ Depends: python-yaml, sip-tester (>= 1:3.3-1~), tcpdump, + ${misc:Depends}, + ${perl:Depends}, Description: Kamailio configuration tests Scripts and tests scenarios to check Kamailio configuration.