diff --git a/tests/test_versions/Makefile b/tests/test_versions/Makefile index 8bebd1c7dc24a69cb37af9a620fd2eef47bda0d1..da755d0897fdffbb010524802d6170e658041ae7 100644 --- a/tests/test_versions/Makefile +++ b/tests/test_versions/Makefile @@ -3,8 +3,8 @@ default: test .PHONY: test -test: check_env clean - @./test.sh test.txt +test: check_env + @pytest . -v .PHONY: check_env check_env: guard-EPICS_BASE guard-E3_REQUIRE_VERSION @@ -13,7 +13,3 @@ check_env: guard-EPICS_BASE guard-E3_REQUIRE_VERSION guard-%: @#$(or ${$*}, $(error $* is not set)) -.PHONY: clean -clean: - rm -rf test/cellMods - rm -rf test/testversions/O.* diff --git a/tests/test_versions/test.sh b/tests/test_versions/test.sh deleted file mode 100755 index 7f737fa4780282b1351ef5de953ae4c8565f12cd..0000000000000000000000000000000000000000 --- a/tests/test_versions/test.sh +++ /dev/null @@ -1,186 +0,0 @@ -#!/usr/bin/env bash - -# Defaults -LOGFILE=test.log -MODULENAME=testversions -EPICS_BASE=${EPICS_BASE:-/epics/base-7.0.5} -REQUIRE_VER=${E3_REQUIRE_VERSION:-3.4.1} - -if which ack &>/dev/null; then - __SEARCH_COMMAND__="ack --passthru" -else - echo "ack is not installed; defaulting to grep, but note that the log will be missing the IOC log" >&2 - __SEARCH_COMMAND__="grep -P" -fi - -function usage { - echo "Usage:" - echo " bash test.sh [-b <EPICS_BASE>] [-r <REQUIRE_VER>] [-h] testfile" - exit 0 -} - -function show_header { - echo "Testing require version loader" - echo "============================================================" - echo -e "EPICS base: \033[34m${EPICS_BASE}\033[0m" - echo -e "Require version: \033[34m${REQUIRE_VER}\033[0m" - echo "============================================================" -} - -function install_vers { - for ver in "$@"; do - echo "==========================================" - echo "Installing local version version '$ver'" - echo "==========================================" - make -C test clean cellinstall __DEBUG_VERSION="$ver" __EPICS_BASE_LOCATION="$EPICS_BASE" __REQUIRE_VERSION="$REQUIRE_VER" E3_NO_TEST=true - done -} - -function clean_vers { - rm -rf test/cellMods -} - -function test_require { - if [ "$#" -lt "3" ]; then - usage - return - fi - - required=$1 - shift - expected=$1 - shift - args=("$@") - - if [ "$required" = "-" ]; then - req_str="$MODULENAME" - else - req_str="$MODULENAME,$required" - fi - - echo "============================================================" - echo "Running test case:" - echo "Requested: $required" - echo "Expected: $expected" - echo "Installed: ${args[*]}" - echo "============================================================" - - required=${required//+/\\+} - expected=${expected//+/\\+} - - clean_vers - - install_vers "${args[@]}" - - echo "==========================================" - echo "Running iocsh.bash -l cellMods -r $req_str" - echo "==========================================" - - iocsh_args="-l test/cellMods -c 'var requireDebug 1' -r $req_str" - - if [ "$expected" = "-" ]; then - search_string="Module $MODULENAME (not available|version $required not available|version $required not available \(but other versions are available\))" - else - search_string="^Loaded $MODULENAME version $expected\$" - fi - - echo "SEARCH STRING: $search_string" - - # The funny sed command here is from https://unix.stackexchange.com/a/235016/445931 - # The reason this is needed is because the "Starting iocInit" message seems to be threaded - # differently than the regular flow of output and sometimes will separate the strings that - # we are looking for. If we simply cut it out then we seem to be able to more consistently - # get meaningful tests. - echo exit | eval iocsh.bash "$iocsh_args" | - sed -e '1 h; 2,$ H; $! d; g' -e 's/Starting iocInit\niocRun: All initialization complete\n//' | - $__SEARCH_COMMAND__ "${search_string}" -} - -function format_output { - result=$1 - shift - requested=$1 - shift - expected=$1 - shift - versions=$* - - if [ "$result" = "0" ]; then - result_str="\033[32mpassed\033[0m" - else - result_str="\033[31mfailed\033[0m" - fi - - printf "Test: %b\n" "$result_str" - printf "requested: %-20s expected: %-20s\n" "$requested" "$expected" - printf "Given versions: %s\n" "$versions" - printf "============================================================\n" -} - -while getopts "hb:r:c:" opt; do - case $opt in - b) - EPICS_BASE="$OPTARG" - ;; - r) - REQUIRE_VER="$OPTARG" - ;; - c) - COMMAND="$OPTARG" - ;; - h) - HELP=true - ;; - *) - usage - exit 1 - ;; - esac -done -shift $((OPTIND - 1)) -TESTFILE=$1 - -if [ "$HELP" = true ]; then - usage - exit 0 -fi - -rm -f "$LOGFILE" - -ENV_SRC="$EPICS_BASE/require/$REQUIRE_VER/bin/setE3Env.bash" -if [ ! -f "$ENV_SRC" ]; then - echo "setE3Env.bash not found at location $ENV_SRC" >&2 - exit 1 -fi -# shellcheck disable=SC1090 -source "$ENV_SRC" &>/dev/null - -show_header - -# TODO: Fix these silly shellcheck disables here. -failed_tests=0 -if [ -n "$COMMAND" ]; then - # shellcheck disable=2086 - test_require $COMMAND &>>"$LOGFILE" - result=$? - [ "$result" = 0 ] || ((failed_tests++)) - # shellcheck disable=2086 - format_output $result $COMMAND -fi - -if [ -f "$TESTFILE" ]; then - while read -r line; do - # shellcheck disable=2086 - test_require $line &>>"$LOGFILE" - result=$? - [ "$result" = 0 ] || ((failed_tests++)) - # shellcheck disable=2086 - format_output $result $line - done < <(sed -e 's/[[:space:]]*#.*//; /^[[:space:]]*$/d' "$TESTFILE") -fi - -if [ ! "$failed_tests" = 0 ]; then - echo -e "\033[31mFailing tests: $failed_tests\033[0m\n" >&2 - cat test.log - exit 1 -fi diff --git a/tests/test_versions/test.txt b/tests/test_versions/test.txt deleted file mode 100644 index 8e5c2ac2c75f71694ddf28742472f4922078539a..0000000000000000000000000000000000000000 --- a/tests/test_versions/test.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Basic set of tests. -# -# Note that the first entry is the requested test version (- means none requested) -# The second entry is what is expected to be loaded (- means it is expected to fail) -# The third and other entries are the versions to install. - -# It should succesfully load a test version -test test test 0.0.1 - -# It should prioritize a numeric version over a test one -- 0.0.1+0 test 0.0.1 -- 0.0.1+0 0.0.1 test - -# If no version is specified, it should load the highest numeric version -- 0.0.1+7 0.0.1 0.0.1+7 0.0.1+3 - -# If no build number is specified, it should load the highest build number -0.0.1 0.0.1+4 0.0.1 0.0.1+4 - -# Build number 0 means load that version. -0.0.1+0 0.0.1+0 0.0.1 0.0.1+1 -0.0.1+0 0.0.1+0 0.0.1+0 - -# Only load exactly the given build number if specified. -0.0.1+0 - 0.0.1+1 - -# 1-test counts as a test version -- 0.0.1+0 0.0.1 1-test - -0.0.1 0.0.1+0 0.0.1 0.0.1+test - -0.0.1 0.0.1+0 0.0.1+test 0.0.1 - -# A numeric version should be prioritized over a "higher" test version -- 0.1.0+0 0.1.0 0.2.0-rc1 diff --git a/tests/test_versions/test/Makefile b/tests/test_versions/test/Makefile deleted file mode 100644 index 81289795f75e25b73345c349f5c4e6cf47f1091c..0000000000000000000000000000000000000000 --- a/tests/test_versions/test/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# -# Copyright (c) 2019 - 2020, European Spallation Source ERIC -# -# The program is free software: you can redistribute -# it and/or modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation, either version 2 of the -# License, or any newer version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program. If not, see https://www.gnu.org/licenses/gpl-2.0.txt -# -# -# Author : Simon Rose -# email : simon.rose@ess.eu -# Date : 2020-08-24 -# version : 0.0.0 - -TOP:=$(CURDIR) - -# To configure require -EPICS_BASE:=$(__EPICS_BASE_LOCATION) -E3_REQUIRE_VERSION:=$(__REQUIRE_VERSION) - -E3_REQUIRE_LOCATION := $(EPICS_BASE)/require/$(E3_REQUIRE_VERSION) -REQUIRE_CONFIG := $(E3_REQUIRE_LOCATION)/configure - -# To configure the modules -EPICS_MODULE_NAME:=testversions -E3_MODULE_VERSION:=$(__DEBUG_VERSION) -E3_MODULE_NAME:=$(EPICS_MODULE_NAME) -E3_MODULE_SRC_PATH:=$(EPICS_MODULE_NAME) -E3_MODULE_MAKEFILE:=$(EPICS_MODULE_NAME).Makefile - -include $(REQUIRE_CONFIG)/CONFIG -include $(REQUIRE_CONFIG)/RULES_SITEMODS - -.PHONY: db -db: diff --git a/tests/test_versions/test/testversions.Makefile b/tests/test_versions/test/testversions.Makefile deleted file mode 100644 index 62a01b97b0354e9d280ef007f954e95ef915e485..0000000000000000000000000000000000000000 --- a/tests/test_versions/test/testversions.Makefile +++ /dev/null @@ -1,5 +0,0 @@ -where_am_I := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(E3_REQUIRE_TOOLS)/driver.makefile - -DBDS += ./test.dbd - diff --git a/tests/test_versions/test/testversions/test.dbd b/tests/test_versions/test/testversions/test.dbd deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/tests/test_versions/test/testversions/testversions.Makefile b/tests/test_versions/test/testversions/testversions.Makefile deleted file mode 100644 index 62a01b97b0354e9d280ef007f954e95ef915e485..0000000000000000000000000000000000000000 --- a/tests/test_versions/test/testversions/testversions.Makefile +++ /dev/null @@ -1,5 +0,0 @@ -where_am_I := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) -include $(E3_REQUIRE_TOOLS)/driver.makefile - -DBDS += ./test.dbd -