blob: 286e95a63c6a9fee2a2b26dff1046fc62b4138f8 [file] [log] [blame]
Alexander Afanasyev4d4e7252014-10-25 12:21:53 -07001#!/usr/bin/env bash
Davide Pesavento69857c32020-04-05 16:36:26 -04002set -ex
Davide Pesaventoe0edc4c2016-09-13 18:29:52 +00003
Alexander Afanasyev4d4e7252014-10-25 12:21:53 -07004# Prepare environment
Davide Pesavento69857c32020-04-05 16:36:26 -04005rm -rf ~/.ndn
Alexander Afanasyev4d4e7252014-10-25 12:21:53 -07006
Alexander Afanasyevf22ebaf2015-12-17 21:23:05 -08007if has OSX $NODE_LABELS; then
Davide Pesavento231ddd72016-09-02 22:20:00 +00008 security unlock-keychain -p named-data
Alexander Afanasyev4d4e7252014-10-25 12:21:53 -07009fi
10
11ndnsec-keygen "/tmp/jenkins/$NODE_NAME" | ndnsec-install-cert -
12
Davide Pesavento69857c32020-04-05 16:36:26 -040013BOOST_VERSION=$(python3 -c "import sys; sys.path.append('build/c4che'); import _cache; print(_cache.BOOST_VERSION_NUMBER);")
Alexander Afanasyev4d4e7252014-10-25 12:21:53 -070014
Davide Pesaventoe0edc4c2016-09-13 18:29:52 +000015ut_log_args() {
Davide Pesaventoe0edc4c2016-09-13 18:29:52 +000016 if (( BOOST_VERSION >= 106200 )); then
Davide Pesavento7de04442016-10-13 14:41:20 +000017 echo --logger=HRF,test_suite,stdout:XML,all,build/xunit-${1:-report}.xml
Davide Pesavento231ddd72016-09-02 22:20:00 +000018 else
Davide Pesaventoe0edc4c2016-09-13 18:29:52 +000019 if [[ -n $XUNIT ]]; then
20 echo --log_level=all $( (( BOOST_VERSION >= 106000 )) && echo -- ) \
Davide Pesavento7de04442016-10-13 14:41:20 +000021 --log_format2=XML --log_sink2=build/xunit-${1:-report}.xml
Davide Pesaventoe0edc4c2016-09-13 18:29:52 +000022 else
23 echo --log_level=test_suite
24 fi
Davide Pesavento231ddd72016-09-02 22:20:00 +000025 fi
26}
Alexander Afanasyevf22ebaf2015-12-17 21:23:05 -080027
Davide Pesavento69857c32020-04-05 16:36:26 -040028# https://github.com/google/sanitizers/wiki/AddressSanitizerFlags
Davide Pesavento043c5012016-09-19 17:23:32 +000029ASAN_OPTIONS="color=always"
Davide Pesavento69857c32020-04-05 16:36:26 -040030ASAN_OPTIONS+=":check_initialization_order=1"
31ASAN_OPTIONS+=":detect_stack_use_after_return=1"
32ASAN_OPTIONS+=":strict_init_order=1"
33ASAN_OPTIONS+=":strict_string_checks=1"
Davide Pesavento043c5012016-09-19 17:23:32 +000034ASAN_OPTIONS+=":detect_invalid_pointer_pairs=1"
Davide Pesavento69857c32020-04-05 16:36:26 -040035ASAN_OPTIONS+=":detect_container_overflow=0"
36ASAN_OPTIONS+=":detect_leaks=0"
Davide Pesavento043c5012016-09-19 17:23:32 +000037ASAN_OPTIONS+=":strip_path_prefix=${PWD}/"
38export ASAN_OPTIONS
39
Davide Pesaventodda258a2018-09-06 02:43:10 -040040export BOOST_TEST_BUILD_INFO=1
41export BOOST_TEST_COLOR_OUTPUT=1
42
Davide Pesavento231ddd72016-09-02 22:20:00 +000043# First run all tests as unprivileged user
Davide Pesavento7de04442016-10-13 14:41:20 +000044./build/unit-tests-core $(ut_log_args core)
45./build/unit-tests-daemon $(ut_log_args daemon)
46./build/unit-tests-rib $(ut_log_args rib)
47./build/unit-tests-tools $(ut_log_args tools)
Alexander Afanasyevf22ebaf2015-12-17 21:23:05 -080048
Davide Pesavento231ddd72016-09-02 22:20:00 +000049# Then use sudo to run those tests that need superuser powers
Davide Pesaventodda258a2018-09-06 02:43:10 -040050sudo_preserve_env ASAN_OPTIONS BOOST_TEST_COLOR_OUTPUT -- \
Davide Pesavento2cae8ca2019-04-18 20:48:05 -040051 ./build/unit-tests-daemon -t TestPrivilegeHelper $(ut_log_args daemon-privilege-helper)
Davide Pesaventodda258a2018-09-06 02:43:10 -040052sudo_preserve_env ASAN_OPTIONS BOOST_TEST_COLOR_OUTPUT -- \
53 ./build/unit-tests-daemon -t Face/*Ethernet* $(ut_log_args daemon-ethernet)
54sudo_preserve_env ASAN_OPTIONS BOOST_TEST_COLOR_OUTPUT -- \
Davide Pesavento70156942018-09-15 18:40:21 -040055 ./build/unit-tests-daemon -t Face/TestUdpFactory $(ut_log_args daemon-udp)