Alexander Afanasyev | 4d4e725 | 2014-10-25 12:21:53 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Davide Pesavento | 69857c3 | 2020-04-05 16:36:26 -0400 | [diff] [blame] | 2 | set -ex |
Davide Pesavento | e0edc4c | 2016-09-13 18:29:52 +0000 | [diff] [blame] | 3 | |
Alexander Afanasyev | 4d4e725 | 2014-10-25 12:21:53 -0700 | [diff] [blame] | 4 | # Prepare environment |
Davide Pesavento | 69857c3 | 2020-04-05 16:36:26 -0400 | [diff] [blame] | 5 | rm -rf ~/.ndn |
Alexander Afanasyev | 4d4e725 | 2014-10-25 12:21:53 -0700 | [diff] [blame] | 6 | |
Alexander Afanasyev | f22ebaf | 2015-12-17 21:23:05 -0800 | [diff] [blame] | 7 | if has OSX $NODE_LABELS; then |
Davide Pesavento | 231ddd7 | 2016-09-02 22:20:00 +0000 | [diff] [blame] | 8 | security unlock-keychain -p named-data |
Alexander Afanasyev | 4d4e725 | 2014-10-25 12:21:53 -0700 | [diff] [blame] | 9 | fi |
| 10 | |
| 11 | ndnsec-keygen "/tmp/jenkins/$NODE_NAME" | ndnsec-install-cert - |
| 12 | |
Davide Pesavento | 69857c3 | 2020-04-05 16:36:26 -0400 | [diff] [blame] | 13 | BOOST_VERSION=$(python3 -c "import sys; sys.path.append('build/c4che'); import _cache; print(_cache.BOOST_VERSION_NUMBER);") |
Alexander Afanasyev | 4d4e725 | 2014-10-25 12:21:53 -0700 | [diff] [blame] | 14 | |
Davide Pesavento | e0edc4c | 2016-09-13 18:29:52 +0000 | [diff] [blame] | 15 | ut_log_args() { |
Davide Pesavento | e0edc4c | 2016-09-13 18:29:52 +0000 | [diff] [blame] | 16 | if (( BOOST_VERSION >= 106200 )); then |
Davide Pesavento | 7de0444 | 2016-10-13 14:41:20 +0000 | [diff] [blame] | 17 | echo --logger=HRF,test_suite,stdout:XML,all,build/xunit-${1:-report}.xml |
Davide Pesavento | 231ddd7 | 2016-09-02 22:20:00 +0000 | [diff] [blame] | 18 | else |
Davide Pesavento | e0edc4c | 2016-09-13 18:29:52 +0000 | [diff] [blame] | 19 | if [[ -n $XUNIT ]]; then |
| 20 | echo --log_level=all $( (( BOOST_VERSION >= 106000 )) && echo -- ) \ |
Davide Pesavento | 7de0444 | 2016-10-13 14:41:20 +0000 | [diff] [blame] | 21 | --log_format2=XML --log_sink2=build/xunit-${1:-report}.xml |
Davide Pesavento | e0edc4c | 2016-09-13 18:29:52 +0000 | [diff] [blame] | 22 | else |
| 23 | echo --log_level=test_suite |
| 24 | fi |
Davide Pesavento | 231ddd7 | 2016-09-02 22:20:00 +0000 | [diff] [blame] | 25 | fi |
| 26 | } |
Alexander Afanasyev | f22ebaf | 2015-12-17 21:23:05 -0800 | [diff] [blame] | 27 | |
Davide Pesavento | 69857c3 | 2020-04-05 16:36:26 -0400 | [diff] [blame] | 28 | # https://github.com/google/sanitizers/wiki/AddressSanitizerFlags |
Davide Pesavento | 043c501 | 2016-09-19 17:23:32 +0000 | [diff] [blame] | 29 | ASAN_OPTIONS="color=always" |
Davide Pesavento | 69857c3 | 2020-04-05 16:36:26 -0400 | [diff] [blame] | 30 | ASAN_OPTIONS+=":check_initialization_order=1" |
| 31 | ASAN_OPTIONS+=":detect_stack_use_after_return=1" |
| 32 | ASAN_OPTIONS+=":strict_init_order=1" |
| 33 | ASAN_OPTIONS+=":strict_string_checks=1" |
Davide Pesavento | 043c501 | 2016-09-19 17:23:32 +0000 | [diff] [blame] | 34 | ASAN_OPTIONS+=":detect_invalid_pointer_pairs=1" |
Davide Pesavento | 69857c3 | 2020-04-05 16:36:26 -0400 | [diff] [blame] | 35 | ASAN_OPTIONS+=":detect_container_overflow=0" |
| 36 | ASAN_OPTIONS+=":detect_leaks=0" |
Davide Pesavento | 043c501 | 2016-09-19 17:23:32 +0000 | [diff] [blame] | 37 | ASAN_OPTIONS+=":strip_path_prefix=${PWD}/" |
| 38 | export ASAN_OPTIONS |
| 39 | |
Davide Pesavento | dda258a | 2018-09-06 02:43:10 -0400 | [diff] [blame] | 40 | export BOOST_TEST_BUILD_INFO=1 |
| 41 | export BOOST_TEST_COLOR_OUTPUT=1 |
| 42 | |
Davide Pesavento | 231ddd7 | 2016-09-02 22:20:00 +0000 | [diff] [blame] | 43 | # First run all tests as unprivileged user |
Davide Pesavento | 7de0444 | 2016-10-13 14:41:20 +0000 | [diff] [blame] | 44 | ./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 Afanasyev | f22ebaf | 2015-12-17 21:23:05 -0800 | [diff] [blame] | 48 | |
Davide Pesavento | 231ddd7 | 2016-09-02 22:20:00 +0000 | [diff] [blame] | 49 | # Then use sudo to run those tests that need superuser powers |
Davide Pesavento | dda258a | 2018-09-06 02:43:10 -0400 | [diff] [blame] | 50 | sudo_preserve_env ASAN_OPTIONS BOOST_TEST_COLOR_OUTPUT -- \ |
Davide Pesavento | 2cae8ca | 2019-04-18 20:48:05 -0400 | [diff] [blame] | 51 | ./build/unit-tests-daemon -t TestPrivilegeHelper $(ut_log_args daemon-privilege-helper) |
Davide Pesavento | dda258a | 2018-09-06 02:43:10 -0400 | [diff] [blame] | 52 | sudo_preserve_env ASAN_OPTIONS BOOST_TEST_COLOR_OUTPUT -- \ |
| 53 | ./build/unit-tests-daemon -t Face/*Ethernet* $(ut_log_args daemon-ethernet) |
| 54 | sudo_preserve_env ASAN_OPTIONS BOOST_TEST_COLOR_OUTPUT -- \ |
Davide Pesavento | 7015694 | 2018-09-15 18:40:21 -0400 | [diff] [blame] | 55 | ./build/unit-tests-daemon -t Face/TestUdpFactory $(ut_log_args daemon-udp) |