blob: f605efa1209b39caa67227441079c3d219bd0836 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
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
|