0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-27 14:16:20 +00:00
netdata_netdata/tests/run-unit-tests.sh
Austin S. Hemmelgarn 804fd4ce54
Prefer Protobuf’s own CMake config over CMake's FindProtobuf. ()
* Prefer Protobuf’s own CMake config over CMake's FindProtobuf.

The FindProtobuf CMake module shipped by upstream CMake is broken for
Protobuf version 22.0 and newer because it does not correctly pull in
the new Abseil dependencies. Protobuf itself sometimes ships a CMake
Package Configuration module that _does_ work correctly, so use that in
preference to the Find module shipped with CMake.

Upstream bug reference: https://gitlab.kitware.com/cmake/cmake/-/issues/24321

* Properly handle protoc executable.

* Restructure to explicitly handle fallback case ourselves.

This allows proper handling of compatibility code in a way that actually
works for us without us needing to ship a special module to handle the
compatibility case.

* Switch to bundling protobuf via CMake instead of an external script.

* Fix handling of Protobuf inclusion.

- Add correct include directories for protoc.
- Skip installing protobuf when installing the agent.

* Drop spurious quotation marks.

* Properly fix generator expression for protoc include paths.

* Properly default to bundling protobuf in installer code.

* Disable ASAN in unit tests.

It doesn’t work with the modified protobuf handling and per discussion
with the team is non-critical.

* Change comment based on review.

* Revert "Disable ASAN in unit tests."

This reverts commit 6cb98b1b59.

* Disable IPMI and NFACCT plugins for unit tests.

We don’t actually have any unit tests for them, and they cause issues
building reliably in the unit testing environment.

* Disable ASAN for Abseil and Protobuf when vendoring them.

* Switch to commit hashes for protobuf/abseil.

* Restructure to better encapsulate protobuf handling as it’s own module.

* Fix up bundled protobuf version handling.

Google has complicated rules for C++ build environment support, so we
really need to be checking compiler versions and not _just_ C++ standard
version.

* Fix warnings about invalid defines.
2024-03-20 07:13:44 -04:00

42 lines
1.2 KiB
Bash
Executable file

#!/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"
NETDATA_CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Debug -DENABLE_ADDRESS_SANITIZER=On" \
fakeroot ./netdata-installer.sh \
--install-prefix "$HOME" \
--dont-wait \
--dont-start-it \
--disable-lto \
--enable-logsmanagement-tests
}
c_unit_tests() {
echo "Running C code unit tests"
ASAN_OPTIONS=detect_leaks=0 \
"$HOME"/netdata/usr/sbin/netdata -W unittest
}
install_netdata || exit 1
c_unit_tests || exit 1