run-unit-tests.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. fakeroot ./netdata-installer.sh \
  23. --install-prefix "$HOME" \
  24. --dont-wait \
  25. --dont-start-it \
  26. --enable-plugin-nfacct \
  27. --enable-plugin-freeipmi \
  28. --disable-lto \
  29. --enable-logsmanagement-tests
  30. }
  31. c_unit_tests() {
  32. echo "Running C code unit tests"
  33. "$HOME"/netdata/usr/sbin/netdata -W unittest
  34. }
  35. install_netdata || exit 1
  36. c_unit_tests || exit 1