summaryrefslogtreecommitdiffstats
path: root/tests/Dockerfiletest
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Dockerfiletest')
-rw-r--r--tests/Dockerfiletest/Dockerfile_faulty10
-rw-r--r--tests/Dockerfiletest/Makefile2
-rwxr-xr-xtests/Dockerfiletest/run.sh12
-rwxr-xr-xtests/Dockerfiletest/test_gluster_dockerfile.sh45
4 files changed, 69 insertions, 0 deletions
diff --git a/tests/Dockerfiletest/Dockerfile_faulty b/tests/Dockerfiletest/Dockerfile_faulty
new file mode 100644
index 0000000..b538995
--- /dev/null
+++ b/tests/Dockerfiletest/Dockerfile_faulty
@@ -0,0 +1,10 @@
+
+MAINTAINER Humble Chirammal hchiramm@redhat.com Mohamed Ashiq Liyazudeen mliyazud@redhat.com
+
+LABEL Name="faulty"
+
+RUNCMD 'echo "fail"'
+
+EXPOSE 3333
+
+CMD ["/usr/sbin/init"]
diff --git a/tests/Dockerfiletest/Makefile b/tests/Dockerfiletest/Makefile
new file mode 100644
index 0000000..13cf414
--- /dev/null
+++ b/tests/Dockerfiletest/Makefile
@@ -0,0 +1,2 @@
+test:
+ ./run.sh
diff --git a/tests/Dockerfiletest/run.sh b/tests/Dockerfiletest/run.sh
new file mode 100755
index 0000000..b82b810
--- /dev/null
+++ b/tests/Dockerfiletest/run.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+SCRIPT_DIR=$(cd $(dirname $0); pwd)
+
+echo "running tests in ${SCRIPT_DIR}"
+
+for test in ${SCRIPT_DIR}/test_*.sh ; do
+ $test
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+done
diff --git a/tests/Dockerfiletest/test_gluster_dockerfile.sh b/tests/Dockerfiletest/test_gluster_dockerfile.sh
new file mode 100755
index 0000000..fc52d44
--- /dev/null
+++ b/tests/Dockerfiletest/test_gluster_dockerfile.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+SCRIPT_DIR=$(cd $(dirname ${0}); pwd)
+TESTS_DIR="${SCRIPT_DIR}/.."
+INC_DIR="${TESTS_DIR}/common"
+BASE_DIR="${SCRIPT_DIR}/../.."
+FAULTY_DOCKERFILE="${SCRIPT_DIR}/Dockerfile_faulty"
+
+source "${INC_DIR}/subunit.sh"
+
+check_dockerfilelint_invalid() {
+ local file="${1}"
+ check_dockerfilelint ${file}
+ if [[ "x$?" == "x0" ]]; then
+ echo "ERROR: parsing invalid Dockerfile succeeded"
+ return 1
+ fi
+
+ return 0
+}
+
+check_dockerfilelint() {
+ local file="${1}"
+ if ! which dockerfile_lint ; then
+ echo "dockerfile_lint not found: skipping..."
+ return 0
+ fi
+
+ dockerfile_lint -p -f ${file}
+}
+
+failed=0
+
+ testit "check invalid Dockerfile" \
+ check_dockerfilelint_invalid ${FAULTY_DOCKERFILE} \
+ || ((failed++))
+
+ for Dockerfile in $(find ${BASE_DIR} -name "Dockerfile") ; do
+ testit "check Dockerfile_lint $(basename ${Dockerfile})" \
+ check_dockerfilelint ${Dockerfile} \
+ || ((failed++))
+ done
+
+
+testok $0 ${failed}