forked from openvinotoolkit/model_server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rununittest.sh
executable file
·54 lines (53 loc) · 1.83 KB
/
rununittest.sh
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
#!/bin/bash -x
# Copyright (c) 2023 Intel Corporation
#
# 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.
#
# This script should be used inside build image to run unit tests
TEST_FILTER="--test_filter=*"
SHARED_OPTIONS=" \
--jobs=$JOBS \
${debug_bazel_flags} \
--test_timeout=1800 \
--test_summary=detailed \
--test_output=streamed \
--test_env PYTHONPATH=${PYTHONPATH}"
test_success_procedure() {
grep -a " ms \| ms)" ${TEST_LOG}
tail -50 ${TEST_LOG}
}
generate_coverage_report() {
test_success_procedure
genhtml --output genhtml "$(bazel info output_path)/_coverage/_coverage_report.dat"
}
test_fail_procedure() {
test_success_procedure
cat ${TEST_LOG} && rm -rf ${TEST_LOG} && exit 1
}
echo "Run test: ${RUN_TESTS}"
echo "Run coverage: ${CHECK_COVERAGE}"
if [ "$RUN_TESTS" == "1" ] ; then
if [ "$CHECK_COVERAGE" == "1" ] ; then
{ bazel coverage --instrumentation_filter="-src/test" --combined_report=lcov \
${SHARED_OPTIONS} ${TEST_FILTER} \
//src:ovms_test ${BAZEL_OPTIONS} > ${TEST_LOG} 2>&1 || \
test_fail_procedure; } && \
generate_coverage_report;
fi
{ bazel test \
${SHARED_OPTIONS} "${TEST_FILTER}" \
//src:ovms_test ${BAZEL_OPTIONS} > ${TEST_LOG} 2>&1 || \
test_fail_procedure; } && \
test_success_procedure && \
rm -rf ${TEST_LOG};
fi