-
Notifications
You must be signed in to change notification settings - Fork 6
/
run_tests.sh
executable file
·103 lines (91 loc) · 3.65 KB
/
run_tests.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
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
#!/bin/bash
# This script runs various CTF tests:
# - Static Code Analysis (SCA)
# - Unit Tests & Coverage (UTC)
# - Functional Tests (FT)
# - Verification & Validation Tests (VV)
# -----------------------------------------------------------------------------------
function usage()
{
echo ""
echo "USAGE: ./run_tests <arg1>"
echo ""
echo " where arg1 can be [sca|utc|ft|vv]"
echo " sca = static code analysis"
echo " utc = unit tests & code coverage"
echo " ft = functional tests"
echo " vv = requirement verification tests"
echo ""
}
# -----------------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------------
if [ "$#" -ne 1 ]; then
usage
exit
fi
# Make a directory to store various test output
OUT_DIR="runtests_output"
mkdir -p $OUT_DIR
if [ "$1" == "sca" ]; then
# Make a sub-dir for SCA output
OUT_SUBDIR="$OUT_DIR/sca"
mkdir -p $OUT_SUBDIR
# Run static code analysis on the CTF code base
cd .. && pylint --rcfile=ctf/.pylintrc ctf | tee ctf/$OUT_SUBDIR/ctf_sca.log
elif [ "$1" == "utc" ]; then
# Make a sub-dir for UTC output
OUT_SUBDIR="$OUT_DIR/utc"
mkdir -p $OUT_SUBDIR
# Run the unit test suite and code coverage
pytest -v ./unit_tests/ \
--workspace=open_source \
-W ignore::pytest.PytestCollectionWarning \
-W ignore::DeprecationWarning:invoke.loader \
--cov-config=.ctf_coveragerc \
--cov=plugins --cov=lib \
--cov-report=html | tee $OUT_SUBDIR/ctf_ut_results.log
# Convert coverage report in HTML to PDF
wkhtmltopdf --enable-local-file-access UnitTests_Coverage/index.html $OUT_SUBDIR/ctf_ut_coverage.pdf
# Move the generated output to UTC sub-dir
mv -f *.log $OUT_SUBDIR
mv -f UnitTests_Coverage plugin_info_output temp_log_dir local $OUT_SUBDIR
mv -f CTF_Results/Run* $OUT_SUBDIR/ut_run
# Remove un-needed files/dirs
rm -rf CTF_Results
elif [ "$1" == "ft" ]; then
# Make a sub-dir for FT output
OUT_SUBDIR="$OUT_DIR/ft"
mkdir -p $OUT_SUBDIR
# Run functional tests written in CTF scripts
./ctf --config_file vv_tests/configs/ctf_vv_config.ini \
./functional_tests/Test_StartCfsEnableOutput.json functional_tests/plugin_tests \
functional_tests/cfe_6_7_tests ./functional_tests/Test_StopCfs.json
# Move the generated output to FT sub-dir
mv CTF_Results/Run_* $OUT_SUBDIR/ft_run
# Remove un-needed files/dirs
rm -rf CTF_Results
elif [ "$1" == "vv" ]; then
# Make a sub-dir for VV output
OUT_SUBDIR="$OUT_DIR/vv"
mkdir -p $OUT_SUBDIR
# Run requirement verification tests writtent in CTF scripts - set 1
./ctf --config_file vv_tests/configs/ctf_vv_config.ini \
./vv_tests/scripts/CTF_VV_StartCfsEnableOutput.json \
vv_tests/scripts/ci_pass &&
# Move the generated output to VV sub-dir
mv -f CTF_Results/Run_* $OUT_SUBDIR/vv_run_ci &&
# Run requirement verification tests written in CTF scripts - set 2
./ctf --config_file vv_tests/configs/ci_vv_lx1_config.ini \
vv_tests/scripts/CTF_VV_14.json \
vv_tests/scripts/CTF_VV_15.json \
vv_tests/scripts/CTF_VV_19.json &&
# Move the generated output to VV sub-dir
mv -f CTF_Results/Run_* $OUT_SUBDIR/vv_run_tc
# Remove un-needed files/dirs
rm -rf CTF_Results
else
echo "Bad command line argument - $1"
exit
fi
# -----------------------------------------------------------------------------------