run-unit-tests.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. #
  3. # Unit-testing script
  4. #
  5. # This script does the following:
  6. # 1. Check whether any files were modified that would necessitate unit testing (using the `TRAVIS_COMMIT_RANGE` environment variable).
  7. # 2. If there are no changed files that require unit testing, exit successfully.
  8. # 3. Otherwise, run all the unit tests.
  9. #
  10. # We do things this way because our unit testing takes a rather long
  11. # time (average 18-19 minutes as of the original creation of this script),
  12. # so skipping it when we don't actually need it can significantly speed
  13. # up the CI process.
  14. #
  15. # Copyright: SPDX-License-Identifier: GPL-3.0-or-later
  16. #
  17. # Author: Austin S. Hemmelgarn <austin@netdata.cloud>
  18. #
  19. # shellcheck disable=SC2230
  20. install_netdata() {
  21. echo "Installing Netdata"
  22. NETDATA_CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DENABLE_ADDRESS_SANITIZER=On" \
  23. fakeroot ./netdata-installer.sh \
  24. --install-prefix "$HOME" \
  25. --dont-wait \
  26. --dont-start-it \
  27. --disable-lto \
  28. --enable-logsmanagement-tests
  29. }
  30. c_unit_tests() {
  31. echo "Running C code unit tests"
  32. ASAN_OPTIONS=detect_leaks=0 \
  33. "$HOME"/netdata/usr/sbin/netdata -W unittest
  34. }
  35. install_netdata || exit 1
  36. c_unit_tests || exit 1