Module: check_mk
Branch: master
Commit: e7a8d5baaf322368d079acd3c91467edf16d985e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e7a8d5baaf3223…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 7 13:05:42 2017 +0100
Add some static code checking for shell scripts (agents / plugins)
Change-Id: I65a6044723e99df223772caf4ff97b1fc4359e6c
---
tests/Makefile | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/tests/Makefile b/tests/Makefile
index ae97b53..87a546e 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,12 +1,14 @@
SHELL=/bin/bash -e
help:
- @echo "test - Run integration and git tests"
- @echo "test-pylint - Run pylint based tests"
- @echo "test-pylint-ci - Run pylint based tests within Jenkins"
- @echo "test-bandit - Run bandit (security) tests"
- @echo "test-bandit-ci - Run bandit (security) tests within Jenkins"
- @echo "setup - Install dependencies"
+ @echo "test - Run integration and git tests"
+ @echo "test-pylint - Run pylint based tests"
+ @echo "test-pylint-ci - Run pylint based tests from Jenkins"
+ @echo "test-bandit - Run bandit (security) tests"
+ @echo "test-bandit-ci - Run bandit (security) tests from Jenkins"
+ @echo "test-shellcheck - Run shellcheck tests"
+ @echo "test-shellcheck-ci - Run shellcheck tests from Jenkins"
+ @echo "setup - Install dependencies"
test:
py.test
@@ -44,10 +46,27 @@ test-bandit-ci:
$(MAKE) test-bandit || true
+test-shellcheck:
+ @CMK_DIR="$(realpath ..)" ; \
+ ENTERPRISE_DIR="$(realpath ../enterprise)" ; \
+ shellcheck \
+ $(OUTPUT_ARGS) \
+ $$(grep -l '^#!/.*sh' $$CMK_DIR/agents/* $$CMK_DIR/agents/plugins/*
$$CMK_DIR/agents/special/* 2>/dev/null) \
+ "$$ENTERPRISE_DIR/agents/mk-remote-alert-handler" | tee $$REDIRECT
+
+
+test-shellcheck-ci:
+ OUTPUT_ARGS="-f checkstyle" \
+ REDIRECT="$$WORKDIR/results.xml" \
+ $(MAKE) test-shellcheck || true
+
+
+
setup:
sudo apt-get install \
python-pip \
chrpath
+ cabal-install
sudo pip install --upgrade pip
sudo pip install --upgrade --ignore-installed -r requirements.txt
$(MAKE) -C pylint setup