diff options
author | Kjell Winblad <[email protected]> | 2019-06-26 08:31:19 +0200 |
---|---|---|
committer | Kjell Winblad <[email protected]> | 2019-06-26 08:31:19 +0200 |
commit | 14944c65bada76cf246f885f7a146c7fd54cb3df (patch) | |
tree | da9368f155f49924d15db82506bfe0d9c8b26ffa | |
parent | c59148c2995d5ac63094ab2e39682f47671ee37e (diff) | |
parent | 2f246b551cca5ca7ca9187282e42650976a65cbb (diff) | |
download | otp-14944c65bada76cf246f885f7a146c7fd54cb3df.tar.gz otp-14944c65bada76cf246f885f7a146c7fd54cb3df.tar.bz2 otp-14944c65bada76cf246f885f7a146c7fd54cb3df.zip |
Merge branch 'kjell/make_test/OTP-15812'
44 files changed, 391 insertions, 2 deletions
diff --git a/HOWTO/TESTING.md b/HOWTO/TESTING.md index ad59319efa..020be0309c 100644 --- a/HOWTO/TESTING.md +++ b/HOWTO/TESTING.md @@ -130,6 +130,52 @@ i.e. Running [ct_run][] from the command line still requires you to do the `ts:install()` step above. +### Convenience for running tests without the release and configuration steps + +It can be convenient to run tests with a single command. This way, one +do not need to worry about missing to run `make release_tests` after +changing a test suite. The `make test` command can be used for this +purpose. The `make test` command works when the current directory +contains a directory called test and in the root directory of the +source code tree. + +*(Waring)* Some test cases do not run correctly or cannot be run at +all through the `make test` command (typically test cases that require +test specific C code to be compiled) because `make test` runs tests +directly by invoking the `ct_run` command instead of using the `ts` +wrapper. One has to follow the procedure described above to run test +cases that do not work with `make test`. + +Below are some examples that illustrate how `make test` can be +used: + + # ERL_TOP needs to be set correctly + cd /path/to/otp + export ERL_TOP=`pwd` + + # Build Erlang/OTP + # + # Note that make test will only compile test code except when + # make test is executed from $ERL_TOP. + ./otp_build setup -a + + # Run a test case (The ARGS variable is passed to ct_run) + (cd $ERL_TOP/erts/emulator && make ARGS="-suite binary_SUITE -case deep_bitstr_lists" test) + + # Run a test suite + (cd $ERL_TOP/lib/stdlib && make ARGS="-suite ets_SUITE" test) + + # Run all test suites for an application + (cd $ERL_TOP/lib/asn1 && make test) + + # Run all tests + # + # When executed from $ERL_TOP, "make test" will first release and + # configure all tests and then attempt to run all tests with `ts:run`. + # This will take several hours. + (cd $ERL_TOP && make test) + + Examining the results --------------------- diff --git a/Makefile.in b/Makefile.in index 25003f47a9..3c4a6da85e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1141,3 +1141,8 @@ bootstrap_clean: || $(MAKE) BOOTSTRAP_ROOT=$(BOOTSTRAP_ROOT) bootstrap_root_clean # ---------------------------------------------------------------------- + +.PHONY: test + +test: all release release_tests + $(ERL_TOP)/make/test_target_script.sh $(ERL_TOP) diff --git a/erts/Makefile b/erts/Makefile index e62c896170..12ac50f7d5 100644 --- a/erts/Makefile +++ b/erts/Makefile @@ -153,3 +153,5 @@ release_docs: .PHONY: xmllint xmllint: $(MAKE) -C doc/src $@ + +include $(ERL_TOP)/make/app_targets.mk diff --git a/erts/emulator/Makefile.in b/erts/emulator/Makefile.in index a9f3bb8e89..46df9b8bc3 100644 --- a/erts/emulator/Makefile.in +++ b/erts/emulator/Makefile.in @@ -1291,3 +1291,5 @@ ifndef VOID_EMULATOR endif endif endif + +include $(ERL_TOP)/make/app_targets.mk diff --git a/erts/epmd/Makefile b/erts/epmd/Makefile index d3308ddedc..e4b201bd88 100644 --- a/erts/epmd/Makefile +++ b/erts/epmd/Makefile @@ -31,3 +31,5 @@ SPECIAL_TARGETS = # Default Subdir Targets # ---------------------------------------------------- include $(ERL_TOP)/make/otp_subdir.mk + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/asn1/Makefile b/lib/asn1/Makefile index 26e7e37924..63cb770043 100644 --- a/lib/asn1/Makefile +++ b/lib/asn1/Makefile @@ -100,3 +100,5 @@ tar: $(APP_TAR_FILE) $(APP_TAR_FILE): $(APP_DIR) (cd $(APP_RELEASE_DIR); gtar zcf $(APP_TAR_FILE) $(DIR_NAME)) + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/common_test/Makefile b/lib/common_test/Makefile index f2065b8a0d..35739462c5 100644 --- a/lib/common_test/Makefile +++ b/lib/common_test/Makefile @@ -45,3 +45,4 @@ SPECIAL_TARGETS = # include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/compiler/Makefile b/lib/compiler/Makefile index b8b2f562a2..3678f48b7c 100644 --- a/lib/compiler/Makefile +++ b/lib/compiler/Makefile @@ -36,3 +36,4 @@ SPECIAL_TARGETS = # include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/crypto/Makefile b/lib/crypto/Makefile index afe56aa7d6..e5812bee15 100644 --- a/lib/crypto/Makefile +++ b/lib/crypto/Makefile @@ -38,3 +38,4 @@ SPECIAL_TARGETS = include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/debugger/Makefile b/lib/debugger/Makefile index 8c8b617831..f91b8bfa5e 100644 --- a/lib/debugger/Makefile +++ b/lib/debugger/Makefile @@ -34,3 +34,5 @@ SPECIAL_TARGETS = # Default Subdir Targets # ---------------------------------------------------- include $(ERL_TOP)/make/otp_subdir.mk + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/dialyzer/Makefile b/lib/dialyzer/Makefile index e4f681dcd9..ab0b94748e 100644 --- a/lib/dialyzer/Makefile +++ b/lib/dialyzer/Makefile @@ -42,3 +42,4 @@ SPECIAL_TARGETS = # include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/diameter/Makefile b/lib/diameter/Makefile index a0195a0988..8c3c0ff0cc 100644 --- a/lib/diameter/Makefile +++ b/lib/diameter/Makefile @@ -31,3 +31,5 @@ info: @echo "APP_VSN = $(APP_VSN)" .PHONY: info + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/edoc/Makefile b/lib/edoc/Makefile index 70bf1f3d48..6dfc6f51c7 100644 --- a/lib/edoc/Makefile +++ b/lib/edoc/Makefile @@ -124,3 +124,6 @@ tar: $(APP_TAR_FILE) $(APP_TAR_FILE): $(APP_DIR) (cd $(APP_RELEASE_DIR); gtar zcf $(APP_TAR_FILE) $(DIR_NAME)) + + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/eldap/Makefile b/lib/eldap/Makefile index 28f995e068..98b5203dfd 100644 --- a/lib/eldap/Makefile +++ b/lib/eldap/Makefile @@ -38,3 +38,4 @@ SPECIAL_TARGETS = # ---------------------------------------------------- include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/erl_docgen/Makefile b/lib/erl_docgen/Makefile index 30ff2bf16e..a13a3c4f94 100644 --- a/lib/erl_docgen/Makefile +++ b/lib/erl_docgen/Makefile @@ -37,3 +37,4 @@ SPECIAL_TARGETS = include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/erl_interface/Makefile b/lib/erl_interface/Makefile index 9471b0df18..633e705b3f 100644 --- a/lib/erl_interface/Makefile +++ b/lib/erl_interface/Makefile @@ -31,3 +31,5 @@ SPECIAL_TARGETS = # Default Subdir Targets # ---------------------------------------------------- include $(ERL_TOP)/make/otp_subdir.mk + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/et/Makefile b/lib/et/Makefile index f0bb7be211..98e15dc179 100644 --- a/lib/et/Makefile +++ b/lib/et/Makefile @@ -35,3 +35,4 @@ SPECIAL_TARGETS = # ---------------------------------------------------- include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/eunit/Makefile b/lib/eunit/Makefile index 15dae19896..acc765faf9 100644 --- a/lib/eunit/Makefile +++ b/lib/eunit/Makefile @@ -94,3 +94,5 @@ tar: $(APP_TAR_FILE) $(APP_TAR_FILE): $(APP_DIR) (cd $(APP_RELEASE_DIR); gtar zcf $(APP_TAR_FILE) $(DIR_NAME)) + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/ftp/Makefile b/lib/ftp/Makefile index e0c9de42e4..e6bceebe15 100644 --- a/lib/ftp/Makefile +++ b/lib/ftp/Makefile @@ -76,3 +76,5 @@ dialyzer: $(DIA_PLT) @dialyzer --plt $< \ ../$(APPLICATION)/ebin \ --verbose + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/hipe/Makefile b/lib/hipe/Makefile index 0676484fca..a1c5f9c83f 100644 --- a/lib/hipe/Makefile +++ b/lib/hipe/Makefile @@ -75,3 +75,4 @@ distclean: realclean: $(V_at)$(MAKE) MAKETARGET="realclean" all-subdirs all-subdirs-x +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/inets/Makefile b/lib/inets/Makefile index 872df9d055..9a03ee93df 100644 --- a/lib/inets/Makefile +++ b/lib/inets/Makefile @@ -76,3 +76,5 @@ dialyzer: $(DIA_PLT) @dialyzer --plt $< \ ../$(APPLICATION)/ebin \ --verbose + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/jinterface/Makefile b/lib/jinterface/Makefile index 9cf5f3e94c..dd22d743a5 100644 --- a/lib/jinterface/Makefile +++ b/lib/jinterface/Makefile @@ -39,3 +39,4 @@ SPECIAL_TARGETS = # ---------------------------------------------------- include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/kernel/Makefile b/lib/kernel/Makefile index b956f5eaf5..5ab8ac63b9 100644 --- a/lib/kernel/Makefile +++ b/lib/kernel/Makefile @@ -34,3 +34,5 @@ SPECIAL_TARGETS = # Default Subdir Targets # ---------------------------------------------------- include $(ERL_TOP)/make/otp_subdir.mk + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/megaco/Makefile b/lib/megaco/Makefile index 1d0bb6778c..c88327c615 100644 --- a/lib/megaco/Makefile +++ b/lib/megaco/Makefile @@ -219,3 +219,5 @@ dialyzer: $(DIA_PLT) @dialyzer --plt $< \ ../$(APPLICATION)/ebin \ --verbose + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/mnesia/Makefile b/lib/mnesia/Makefile index 810433c4d0..d0edd48af9 100644 --- a/lib/mnesia/Makefile +++ b/lib/mnesia/Makefile @@ -38,3 +38,4 @@ SPECIAL_TARGETS = # ---------------------------------------------------- include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/observer/Makefile b/lib/observer/Makefile index 8483922f76..4770a72ba8 100644 --- a/lib/observer/Makefile +++ b/lib/observer/Makefile @@ -37,3 +37,4 @@ SPECIAL_TARGETS = include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/odbc/Makefile b/lib/odbc/Makefile index f7816c25fc..dfa224ecd6 100644 --- a/lib/odbc/Makefile +++ b/lib/odbc/Makefile @@ -114,3 +114,5 @@ tar: $(APP_TAR_FILE) $(APP_TAR_FILE): $(APP_DIR) (cd $(APP_RELEASE_DIR); gtar zcf $(APP_TAR_FILE) $(DIR_NAME)) + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/os_mon/Makefile b/lib/os_mon/Makefile index 40ce94e0c7..f45065a79d 100644 --- a/lib/os_mon/Makefile +++ b/lib/os_mon/Makefile @@ -35,3 +35,4 @@ SPECIAL_TARGETS = # include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/parsetools/Makefile b/lib/parsetools/Makefile index e9de5c43cb..2ddb06feb1 100644 --- a/lib/parsetools/Makefile +++ b/lib/parsetools/Makefile @@ -37,3 +37,4 @@ SPECIAL_TARGETS = # ---------------------------------------------------- include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/public_key/Makefile b/lib/public_key/Makefile index 7a5c1c1443..3b6cb3ce6c 100644 --- a/lib/public_key/Makefile +++ b/lib/public_key/Makefile @@ -38,3 +38,4 @@ SPECIAL_TARGETS = # ---------------------------------------------------- include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/reltool/Makefile b/lib/reltool/Makefile index 4b6aad07b3..70c80e1c3c 100644 --- a/lib/reltool/Makefile +++ b/lib/reltool/Makefile @@ -36,3 +36,4 @@ SPECIAL_TARGETS = # ---------------------------------------------------- include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/runtime_tools/Makefile b/lib/runtime_tools/Makefile index eec1ff379b..9a0822b9b6 100644 --- a/lib/runtime_tools/Makefile +++ b/lib/runtime_tools/Makefile @@ -37,3 +37,4 @@ SPECIAL_TARGETS = include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/sasl/Makefile b/lib/sasl/Makefile index 065eb45fbb..1710606d3d 100644 --- a/lib/sasl/Makefile +++ b/lib/sasl/Makefile @@ -36,3 +36,4 @@ SPECIAL_TARGETS = # include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/snmp/Makefile b/lib/snmp/Makefile index 879f1b05c5..34ab309cfa 100644 --- a/lib/snmp/Makefile +++ b/lib/snmp/Makefile @@ -148,4 +148,6 @@ dialyzer: $(DIA_PLT) @echo "Running dialyzer on $(APPLICATION)" @dialyzer --plt $< \ ../$(APPLICATION)/ebin \ - --verbose
\ No newline at end of file + --verbose + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/ssh/Makefile b/lib/ssh/Makefile index dedc7ac3a6..ab3948df75 100644 --- a/lib/ssh/Makefile +++ b/lib/ssh/Makefile @@ -38,3 +38,4 @@ SPECIAL_TARGETS = include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/ssl/Makefile b/lib/ssl/Makefile index bd43794a36..c761979474 100644 --- a/lib/ssl/Makefile +++ b/lib/ssl/Makefile @@ -38,4 +38,4 @@ SPECIAL_TARGETS = # include $(ERL_TOP)/make/otp_subdir.mk - +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/stdlib/Makefile b/lib/stdlib/Makefile index 3086d85445..0444cedadb 100644 --- a/lib/stdlib/Makefile +++ b/lib/stdlib/Makefile @@ -35,3 +35,5 @@ SPECIAL_TARGETS = # Default Subdir Targets # include $(ERL_TOP)/make/otp_subdir.mk + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/syntax_tools/Makefile b/lib/syntax_tools/Makefile index 14ae6d4f97..d3e2aa9b2c 100644 --- a/lib/syntax_tools/Makefile +++ b/lib/syntax_tools/Makefile @@ -91,3 +91,5 @@ tar: $(APP_TAR_FILE) $(APP_TAR_FILE): $(APP_DIR) (cd $(APP_RELEASE_DIR); gtar zcf $(APP_TAR_FILE) $(DIR_NAME)) + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/tftp/Makefile b/lib/tftp/Makefile index a4559fbc2e..348a4a86b6 100644 --- a/lib/tftp/Makefile +++ b/lib/tftp/Makefile @@ -76,3 +76,5 @@ dialyzer: $(DIA_PLT) @dialyzer --plt $< \ ../$(APPLICATION)/ebin \ --verbose + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/tools/Makefile b/lib/tools/Makefile index e17e9cfd1e..811926e20d 100644 --- a/lib/tools/Makefile +++ b/lib/tools/Makefile @@ -36,3 +36,4 @@ SPECIAL_TARGETS = # ---------------------------------------------------- include $(ERL_TOP)/make/otp_subdir.mk +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/wx/Makefile b/lib/wx/Makefile index 2397950925..002887d9da 100644 --- a/lib/wx/Makefile +++ b/lib/wx/Makefile @@ -40,3 +40,5 @@ CLEANDIRS = $(SUBDIRS) api_gen SUB_DIRECTORIES=$(SUBDIRS) include $(ERL_TOP)/make/otp_subdir.mk + +include $(ERL_TOP)/make/app_targets.mk diff --git a/lib/xmerl/Makefile b/lib/xmerl/Makefile index a584aacbac..84b243fe68 100644 --- a/lib/xmerl/Makefile +++ b/lib/xmerl/Makefile @@ -97,3 +97,4 @@ tar: $(APP_TAR_FILE) $(APP_TAR_FILE): $(APP_DIR) (cd $(APP_RELEASE_DIR); gtar zcf $(APP_TAR_FILE) $(DIR_NAME)) +include $(ERL_TOP)/make/app_targets.mk diff --git a/make/app_targets.mk b/make/app_targets.mk new file mode 100644 index 0000000000..3f28a529d4 --- /dev/null +++ b/make/app_targets.mk @@ -0,0 +1,25 @@ +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 1997-2019. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# %CopyrightEnd% +# + + +.PHONY: test + +test: + $(ERL_TOP)/make/test_target_script.sh $(ERL_TOP) diff --git a/make/test_target_script.sh b/make/test_target_script.sh new file mode 100755 index 0000000000..f605efa120 --- /dev/null +++ b/make/test_target_script.sh @@ -0,0 +1,254 @@ +#!/bin/sh + +# +# %CopyrightBegin% +# +# Copyright Ericsson AB 1997-2019. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# %CopyrightEnd% +# + + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +LIGHT_CYAN='\033[1;36m' +BOLD='\033[1m' +NC='\033[0m' + + +print_highlighted_msg_with_printer () { + COLOR=$1 + MSG_PRINTER=$2 + printf "\n${COLOR}======================================================================${NC}\n" + echo + $MSG_PRINTER + echo + printf "${COLOR}======================================================================${NC}\n" +} + +print_highlighted_msg () { + COLOR=$1 + MSG=$2 + print_msg () { + echo "$MSG" + } + print_highlighted_msg_with_printer $COLOR print_msg +} + +print_all_tests_takes_long_time_warning () { + print_msg () { + cat << EOM + +WARNING + +All tests will require several hours to run. You may want to check the +following text file that describes how to run tests for a specific +application. + +EOM + echo $ERL_TOP/HOWTO/TESTING.md + } + print_highlighted_msg_with_printer $YELLOW print_msg +} + +print_all_tests_for_application_notes () { + print_msg () { + cat << EOM + +NOTE 1 + +ct_run will now attempt to execute tests in the test directory, which +may take a long time to do. One can pass arguments to ct_run by +setting the ARGS variable when invoking "make test". + +Example: + +make ARGS="-suite asn1_SUITE -case ticket_7407" test + +NOTE 2 + +You may want to look at the more established way of running tests that +is described in the following text file if you encounter strange +errors: + +EOM + echo "$ERL_TOP/HOWTO/TESTING.md" + } + print_highlighted_msg_with_printer $LIGHT_CYAN print_msg +} + +print_c_files_warning () { + print_msg () { + cat << EOM + +WARNING + +The test directory contains .c files which means that some test cases +will probably not work correctly when run through "make test". The +text file at the following location describes how one can compile and +run all test cases: + + +EOM + echo $ERL_TOP/HOWTO/TESTING.md + } + print_highlighted_msg_with_printer $YELLOW print_msg +} + + +print_on_error_note () { + print_msg () { + cat << EOM +NOTE: + +Some test cases do not work correctly when run through "make test" as +they are designed to be run through the method that is described in +the "$ERL_TOP/HOWTO/TESTING.md" text file. You may want to check this +text file if you encounter strange errors. Note also that you can +rerun a specific test case by passing parameters to ct_run as in the +example below: + +make ARGS="-suite asn1_SUITE -case ticket_7407" test + +EOM + } + print_highlighted_msg_with_printer $NC print_msg +} + +# Check ERL_TOP + +if [ -d "$1" ] +then + ERL_TOP="$1" + shift +fi + +if [ -z $ERL_TOP ] +then + ERL_TOP=`git rev-parse --show-toplevel` + if [ $? = 0 ] + then + print_highlighted_msg $LIGHT_CYAN "The environment variable ERL_TOP has been set to the git root" + else + echo "The ERL_TOP environment variable need to be set before this script is executed." + exit 1 + fi +fi + +export ERL_TOP=$ERL_TOP + + +if [ -z "${ARGS}" ] +then + ARGS="$@" +fi + +# make test in root +DIR=`pwd` +if [ "$DIR" -ef "$ERL_TOP" ] +then + TARGET_SYS=`$ERL_TOP/erts/autoconf/config.guess` + REL_DIR="$ERL_TOP/release/$TARGET_SYS" + cd "$REL_DIR" + ./Install -minimal "`pwd`" + export PATH="$REL_DIR/bin:$PATH" + cd "$ERL_TOP/release/tests/test_server" + print_all_tests_takes_long_time_warning + echo "The tests will start in a few seconds..." + sleep 45 + cd "$ERL_TOP/release/tests/test_server" + erl -eval "ts:install(),erlang:halt()" + erl -noinput -eval "ts:run([all_tests,batch]),erlang:halt()" + exit $? +fi + +# check that there is a test directory +if [ ! -d test ] +then + print_highlighted_msg $RED "This target only works in directories containing a test directory or\nin the root directory." + exit 1 +fi + + +APPLICATION="`basename $DIR`" +CT_RUN="$ERL_TOP/bin/ct_run" +MAKE_TEST_DIR="`pwd`/make_test_dir" +MAKE_TEST_REL_DIR="$MAKE_TEST_DIR/${APPLICATION}_test" +MAKE_TEST_CT_LOGS="$MAKE_TEST_DIR/ct_logs" +RELEASE_TEST_SPEC_LOG="$MAKE_TEST_CT_LOGS/release_tests_spec_log" + +cd test +echo "The tests in test directory for $APPLICATION will be executed with ct_run" +if [ -z "${ARGS}" ] +then + if [ ! -d "$MAKE_TEST_DIR" ] + then + print_all_tests_for_application_notes + fi + if find . -type f -name '*.c' | grep -q "." + then + print_c_files_warning + fi +fi + +mkdir -p "$MAKE_TEST_DIR" +mkdir -p "$MAKE_TEST_REL_DIR" +mkdir -p "$MAKE_TEST_CT_LOGS" +make RELSYSDIR=$MAKE_TEST_REL_DIR release_tests_spec > $RELEASE_TEST_SPEC_LOG 2>&1 + +if [ $? != 0 ] +then + cat $RELEASE_TEST_SPEC_LOG + print_highlighted_msg $RED "\"make RELSYSDIR="$MAKE_TEST_REL_DIR" release_tests_spec\" failed." + exit 1 +fi +SPEC_FLAG="" +SPEC_FILE="" +if [ -z "${ARGS}" ] +then + SPEC_FLAG="-spec" + SPEC_FILE="$MAKE_TEST_REL_DIR/$APPLICATION.spec" + ARGS="$SPEC_FLAG $SPEC_FILE" +fi +# Compile test server +(cd "$ERL_TOP/lib/common_test/test_server" && make) +# Run ct_run +cd $MAKE_TEST_REL_DIR +$CT_RUN -logdir $MAKE_TEST_CT_LOGS\ + -pa "$ERL_TOP/lib/common_test/test_server"\ + ${ARGS}\ + -erl_args\ + -env "$PATH"\ + -env ERL_CRASH_DUMP "$MAKE_TEST_DIR/${APPLICATION}_erl_crash.dump"\ + -boot start_sasl\ + -sasl errlog_type error\ + -pz "$ERL_TOP/lib/common_test/test_server"\ + -pz "."\ + -ct_test_vars "{net_dir,\"\"}"\ + -noshell\ + -sname test_server\ + -rsh ssh\ + ${ERL_ARGS} +CT_RUN_STATUS=$? +if [ $CT_RUN_STATUS = "0" ] +then + print_highlighted_msg $GREEN "The test(s) ran successfully (ct_run returned a success code)\nTest logs: file://$MAKE_TEST_CT_LOGS/index.html" + exit 0 +else + print_on_error_note + print_highlighted_msg $RED "ct_run returned the error code $CT_RUN_STATUS\nTest logs: file://$MAKE_TEST_CT_LOGS/index.html" + exit $CT_RUN_STATUS +fi |