From 5d0e16c417f511a4e28755467f2e728071daad7e Mon Sep 17 00:00:00 2001 From: Anders Lindh Olsson <anders.lindholsson@ess.eu> Date: Wed, 27 Jan 2021 10:22:16 +0100 Subject: [PATCH] remove inclusion of the run_iocsh script and change tests and targets accordingly; idea is that run-iocsh is a required package but not part of require per se --- CHANGELOG.md | 2 ++ configure/E3/RULES_REQUIRE | 1 + configure/modules/CONFIG | 1 + configure/modules/CONFIG_TEST | 4 +++ configure/modules/RULES_SITEMODS | 1 + configure/modules/RULES_TEST | 29 +++++++++++++++++++++ tools/test_installed_modules.sh | 43 ++++++++++++++++++++++++++++++++ 7 files changed, 81 insertions(+) create mode 100644 configure/modules/CONFIG_TEST create mode 100644 configure/modules/RULES_TEST create mode 100644 tools/test_installed_modules.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b62aed6..f3b2c10d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * Added back `promptE3Env.bash`, which runs `setE3Env.bash` and then sets the bash prompt. * Added descriptions for more targets when running `make help` +* Added a new test target for individual modules, available as `make test` +* Added script in `tools/test_installed_modules.sh` that tests all modules in an installation ## Bugfixes diff --git a/configure/E3/RULES_REQUIRE b/configure/E3/RULES_REQUIRE index f7244b85..b9391ceb 100644 --- a/configure/E3/RULES_REQUIRE +++ b/configure/E3/RULES_REQUIRE @@ -12,6 +12,7 @@ IOCSH_HASH_VERSION?=$(EPICS_MODULE_TAG) FILE_FILTER:= %~ %\# E3_ESSENVCFG_FILE := $(TOP)/tools/ess-env.conf E3_CONFIG_FILE := $(TOP)/tools/e3.cfg +E3_TEST_SCRIPT := $(TOP)/tools/test_installed_modules.sh # E3_SHELL_FILES := $(wildcard $(E3_MODULE_SRC_PATH)/tools/iocsh*.bash) E3_IOC_CFG_FILES := $(E3_MODULE_SRC_PATH)/tools/iocsh_functions diff --git a/configure/modules/CONFIG b/configure/modules/CONFIG index db968061..7031b025 100644 --- a/configure/modules/CONFIG +++ b/configure/modules/CONFIG @@ -5,6 +5,7 @@ include $(REQUIRE_CONFIG)/CONFIG_REQUIRE include $(REQUIRE_CONFIG)/CONFIG_CELL include $(REQUIRE_CONFIG)/CONFIG_E3_PATH include $(REQUIRE_CONFIG)/CONFIG_E3_MAKEFILE +include $(REQUIRE_CONFIG)/CONFIG_TEST include $(REQUIRE_CONFIG)/CONFIG_EPICS include $(REQUIRE_CONFIG)/CONFIG_DKMS include $(REQUIRE_CONFIG)/CONFIG_EXPORT diff --git a/configure/modules/CONFIG_TEST b/configure/modules/CONFIG_TEST new file mode 100644 index 00000000..2dc8de63 --- /dev/null +++ b/configure/modules/CONFIG_TEST @@ -0,0 +1,4 @@ + +RUN_IOCSH_TEST_COMMAND = run-iocsh --name "${EPICS_BASE}/require/${E3_REQUIRE_VERSION}/bin/iocsh.bash" -r "$(E3_MODULE_NAME),$(E3_MODULE_VERSION)" -l $(TEMP_CELL_PATH) +TEMP_CELL_PATH := $(TOP)/testMods-$(shell date +"%y%m%d%H%M%S") +RMDIR = $(RM) -rf diff --git a/configure/modules/RULES_SITEMODS b/configure/modules/RULES_SITEMODS index d8f7faef..a461663a 100644 --- a/configure/modules/RULES_SITEMODS +++ b/configure/modules/RULES_SITEMODS @@ -5,6 +5,7 @@ include $(REQUIRE_CONFIG)/RULES_CELL include $(REQUIRE_CONFIG)/DEFINES_FT include $(REQUIRE_CONFIG)/RULES_PATCH include $(REQUIRE_CONFIG)/RULES_E3_SITELIBS +include $(REQUIRE_CONFIG)/RULES_TEST include $(REQUIRE_CONFIG)/RULES_VLIBS include $(REQUIRE_CONFIG)/RULES_DKMS diff --git a/configure/modules/RULES_TEST b/configure/modules/RULES_TEST new file mode 100644 index 00000000..95b8b88a --- /dev/null +++ b/configure/modules/RULES_TEST @@ -0,0 +1,29 @@ +.PHONY: test +## Tests the current build +test: + +ifeq ($(shell command -v run-iocsh > /dev/null 2>&1 ; echo $$?),0) + +test: temp_install run_test module_tests cleanup_test + +.PHONY: temp_install +temp_install: + $(MAKE) cellinstall E3_CELL_PATH=$(TEMP_CELL_PATH) + +.PHONY: run_test +run_test: + $(RUN_IOCSH_TEST_COMMAND) + +.PHONY: module_tests +module_tests: + +.PHONY: cleanup_test +cleanup_test: + $(RMDIR) $(TEMP_CELL_PATH) + +else # if the if-run-iocsh-exists test fails + +test: + $(error run-iocsh must be installed to use the test capability. Please install run-iocsh from PyPI.) + +endif \ No newline at end of file diff --git a/tools/test_installed_modules.sh b/tools/test_installed_modules.sh new file mode 100644 index 00000000..ed878b32 --- /dev/null +++ b/tools/test_installed_modules.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# Copyright (c) 2020 European Spallation Source ERIC +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +REQUIRE_DIR=$(cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/.. || exit; pwd) +REQUIRE_VERSION=${REQUIRE_DIR##*/} +BASE_LOCATION=$(cd "${REQUIRE_DIR}"/../.. || exit; pwd) + +if ! $(command -v run-iocsh > /dev/null 2>&1); then + echo "You need to install run-iocsh to use this script" >&2 && exit 1 +fi + +for d in "$REQUIRE_DIR"/siteMods/*/*; do + mod=$(dirname "$d" | xargs basename) + ver=$(basename "$d") + echo "Running test: $mod,$ver" + echo "=======================================================" + + if run-iocsh --base_location "${BASE_LOCATION}" --require_version "${REQUIRE_VERSION}" --delay 2 --timeout 5 "$mod,$ver"; then + echo -e "Module $mod, version $ver: \e[32mTEST PASSED\e[0m" + else + echo -e "Module $mod, version $ver: \e[31mFAILED\e[0m" >&2 + fi + echo "=======================================================" + echo "" +done \ No newline at end of file -- GitLab