summaryrefslogtreecommitdiffstats
path: root/tests/run-unit-tests.sh
blob: d39351779bea92903f24669b63b6c1dfeb3a62b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
#
# Unit-testing script
#
# This script does the following:
#   1. Check whether any files were modified that would necessitate unit testing (using the `TRAVIS_COMMIT_RANGE` environment variable).
#   2. If there are no changed files that require unit testing, exit successfully.
#   3. Otherwise, run all the unit tests.
#
# We do things this way because our unit testing takes a rather long
# time (average 18-19 minutes as of the original creation of this script),
# so skipping it when we don't actually need it can significantly speed
# up the CI process.
#
# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
#
# Author: Austin S. Hemmelgarn <austin@netdata.cloud>
#
# shellcheck disable=SC2230

install_netdata() {
  echo "Installing Netdata"
  fakeroot ./netdata-installer.sh \
    --install-prefix "$HOME" \
    --dont-wait \
    --dont-start-it \
    --enable-plugin-nfacct \
    --enable-plugin-freeipmi \
    --disable-lto
}

c_unit_tests() {
  echo "Running C code unit tests"
  "$HOME"/netdata/usr/sbin/netdata -W unittest
}

install_netdata || exit 1

c_unit_tests || exit 1