ci: Run bsim_bt tests and collect coverage results

Compile and run the tests avaliable in bsim_bt
and collect the coverage results into the coverage report.

Also, detect if bsim's component folder already contains the
nRF52 HW models, and if it does instead of trying to fetch
them again (which will fail) check that the right versio is
present. This should ease testing locally.

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
This commit is contained in:
Alberto Escolar Piedras 2018-11-13 12:05:05 +01:00 committed by Anas Nashif
commit 917711fd8a
2 changed files with 44 additions and 7 deletions

View file

@ -13,6 +13,7 @@ env:
- MATRIX_BUILDS_EXTRA="5"
- BSIM_OUT_PATH=/opt/bsim/
- BSIM_COMPONENTS_PATH=${BSIM_OUT_PATH}/components/
- BSIM_BT_TEST_RESULTS_FILE="./bsim_bt_out/bsim_results.xml"
matrix:
- MATRIX_BUILD="1"
- MATRIX_BUILD="2"
@ -52,7 +53,7 @@ build:
- >
if [ "$MATRIX_BUILD" = "1" ]; then
gcovr -r ${ZEPHYR_BASE} -x > shippable/codecoverage/coverage.xml;
lcov --capture --directory sanity-out/native_posix/ --directory sanity-out/nrf52_bsim/ --directory sanity-out/unit_testing/ --output-file lcov.pre.info -q --rc lcov_branch_coverage=1;
lcov --capture --directory sanity-out/native_posix/ --directory sanity-out/nrf52_bsim/ --directory sanity-out/unit_testing/ --directory bsim_bt_out/ --output-file lcov.pre.info -q --rc lcov_branch_coverage=1;
lcov -q --remove lcov.pre.info mylib.c --remove lcov.pre.info tests/\* --remove lcov.pre.info samples/\* --remove lcov.pre.info ext/\* --remove lcov.pre.info *generated* -o lcov.info --rc lcov_branch_coverage=1;
rm lcov.pre.info;
rm -rf sanity-out out-2nd-pass;
@ -69,6 +70,10 @@ build:
if [ -e ./scripts/sanity_chk/last_sanity.xml ]; then
cp ./scripts/sanity_chk/last_sanity.xml shippable/testresults/;
fi;
- >
if [ -e ${BSIM_BT_TEST_RESULTS_FILE} ]; then
cp ${BSIM_BT_TEST_RESULTS_FILE} shippable/testresults/;
fi;
on_success:
- rm -rf ccache $HOME/.cache/zephyr
- mkdir -p shippable/testresults
@ -77,7 +82,7 @@ build:
- >
if [ "$MATRIX_BUILD" = "1" ]; then
gcovr -r ${ZEPHYR_BASE} -x > shippable/codecoverage/coverage.xml;
lcov --capture --directory sanity-out/native_posix/ --directory sanity-out/nrf52_bsim/ --directory sanity-out/unit_testing/ --output-file lcov.pre.info -q --rc lcov_branch_coverage=1;
lcov --capture --directory sanity-out/native_posix/ --directory sanity-out/nrf52_bsim/ --directory sanity-out/unit_testing/ --directory bsim_bt_out/ --output-file lcov.pre.info -q --rc lcov_branch_coverage=1;
lcov -q --remove lcov.pre.info mylib.c --remove lcov.pre.info tests/\* --remove lcov.pre.info samples/\* --remove lcov.pre.info ext/\* --remove lcov.pre.info *generated* -o lcov.info --rc lcov_branch_coverage=1;
rm lcov.pre.info;
rm -rf sanity-out out-2nd-pass;
@ -94,6 +99,10 @@ build:
if [ -e ./scripts/sanity_chk/last_sanity.xml ]; then
cp ./scripts/sanity_chk/last_sanity.xml shippable/testresults/;
fi;
- >
if [ -e ${BSIM_BT_TEST_RESULTS_FILE} ]; then
cp ${BSIM_BT_TEST_RESULTS_FILE} shippable/testresults/;
fi;
integrations:
notifications:

View file

@ -74,12 +74,31 @@ function build_btsim() {
NRF_HW_MODELS_VERSION=`cat boards/posix/nrf52_bsim/hw_models_version`
pushd . ;
cd ${BSIM_COMPONENTS_PATH} ;
git clone -b ${NRF_HW_MODELS_VERSION} https://github.com/BabbleSim/ext_NRF52_hw_models.git;
cd /opt/bsim/ ;
make everything -j 8;
if [ -d ext_NRF52_hw_models ]; then
cd ext_NRF52_hw_models
git describe --tags --abbrev=0 ${NRF52_HW_MODELS_TAG}\
> /dev/null
if [ "$?" != "0" ]; then
echo "`pwd` seems to contain the nRF52 HW\
models but they are out of date"
exit 1;
fi
else
git clone -b ${NRF_HW_MODELS_VERSION} \
https://github.com/BabbleSim/ext_NRF52_hw_models.git
fi
cd ${BSIM_OUT_PATH}
make everything -j 8 -s
popd ;
}
function run_bsim_bt_tests() {
WORK_DIR=${ZEPHYR_BASE}/bsim_bt_out tests/bluetooth/bsim_bt/compile.sh
RESULTS_FILE=${ZEPHYR_BASE}/${BSIM_BT_TEST_RESULTS_FILE} \
SEARCH_PATH=tests/bluetooth/bsim_bt/bsim_test_app/tests_scripts \
tests/bluetooth/bsim_bt/run_parallel.sh
}
function build_docs() {
echo "- Building Documentation";
make htmldocs
@ -107,8 +126,17 @@ function get_tests_to_run() {
rm -f modified_tests.args modified_boards.args;
}
# Build BT Simulator
test -z ${BSIM_OUT_PATH} || build_btsim
if [ ! -z "${BSIM_OUT_PATH}" ]; then
# Build BT Simulator
build_btsim
# Run BLE tests in simulator on the 1st CI instance:
if [ "$MATRIX" = "1" ]; then
run_bsim_bt_tests
fi
else
echo "Skipping BT simulator tests"
fi
# Build Docs on matrix 5 in a pull request
if [ "${MATRIX}" = "${DOC_MATRIX}" -a -n "${PULL_REQUEST}" ]; then