Skip to content

Commit

Permalink
tests: Skip metrics_measurements under valgrind
Browse files Browse the repository at this point in the history
The test requires unreasonably large timeout when running on CI.

This commit adds a way to detect if tests are running under valgrind,
and uses TEST_SKIP() for the aforementioned test in this case.

This commit also add valgrind suppressions file for false positives
inside cpputest code.
  • Loading branch information
gavv committed Dec 20, 2024
1 parent b7a474e commit 264c175
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/ci_checks/linux-arm/run-tests-in-qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ find bin/"$toolchain" -name 'roc-test-*' | \
do
LD_LIBRARY_PATH="/opt/sysroot/lib:$(echo \
"$PWD/build/3rdparty/$toolchain/$compiler"/*/rpath | tr ' ' ':')" \
python3 scripts/scons_helpers/timeout-run.py 300 \
python3 scripts/scons_helpers/timeout-run.py 900 \
"$qemu_cmd" -L "/opt/sysroot" -cpu "$cpu" "$tst"
done
5 changes: 4 additions & 1 deletion scripts/ci_checks/linux-checks/run-tests-in-valgrind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

set -eux -o pipefail

export RUNNING_IN_VALGRIND=1

find bin/x86_64-pc-linux-gnu -name 'roc-test-*' |\
while read tst
do
python3 scripts/scons_helpers/timeout-run.py 3000 \
python3 scripts/scons_helpers/timeout-run.py 900 \
valgrind \
--suppressions=src/valgrind_suppressions.supp \
--max-stackframe=10475520 \
--error-exitcode=1 --exit-on-first-error=yes \
${tst}
Expand Down
6 changes: 5 additions & 1 deletion src/tests/public_api/test_loopback_sender_2_receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ TEST_GROUP(loopback_sender_2_receiver) {
bool is_ldpc_supported() {
return fec::CodecMap::instance().has_scheme(packet::FEC_LDPC_Staircase);
}

bool running_in_valgrind() {
return ExtTestRunner::getCurrent()->runningInValgrind();
}
};

TEST(loopback_sender_2_receiver, bare_rtp) {
Expand Down Expand Up @@ -630,7 +634,7 @@ TEST(loopback_sender_2_receiver, multitrack_separate_contexts) {

// Smoke test for various counters, durations, etc.
TEST(loopback_sender_2_receiver, metrics_measurements) {
if (!is_rs8m_supported()) {
if (!is_rs8m_supported() || running_in_valgrind()) {
TEST_SKIP();
}

Expand Down
14 changes: 13 additions & 1 deletion src/tests/test_harness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include "test_harness.h"

#include "roc_core/stddefs.h"

ExtTestOutput::ExtTestOutput()
: ConsoleTestOutput() {
}
Expand Down Expand Up @@ -36,8 +38,14 @@ ExtTestRunner* ExtTestRunner::getCurrent() {

ExtTestRunner::ExtTestRunner(int argc, const char* const* argv)
: CommandLineTestRunner(argc, argv, TestRegistry::getCurrentRegistry())
, test_skipped_(false) {
, test_skipped_(false)
, valgrind_detected_(false) {
current_runner_ = this;

const char* valgrind = getenv("RUNNING_IN_VALGRIND");
if (valgrind && valgrind[0] && strcmp(valgrind, "0") != 0) {
valgrind_detected_ = true;
}
}

void ExtTestRunner::markTestStarted() {
Expand All @@ -56,6 +64,10 @@ bool ExtTestRunner::isTestSkipped() const {
return test_skipped_;
}

bool ExtTestRunner::runningInValgrind() const {
return valgrind_detected_;
}

TestOutput* ExtTestRunner::createConsoleOutput() {
return new ExtTestOutput;
}
2 changes: 2 additions & 0 deletions src/tests/test_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ class ExtTestRunner : public CommandLineTestRunner {
void markTestEnded();

bool isTestSkipped() const;
bool runningInValgrind() const;

protected:
virtual TestOutput* createConsoleOutput();

private:
static ExtTestRunner* current_runner_;
bool test_skipped_;
bool valgrind_detected_;
};

#endif // ROC_TEST_HARNESS_H_
19 changes: 19 additions & 0 deletions src/valgrind_suppressions.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
cpputest_NormalTestTerminator_exitCurrentTest
Memcheck:Param
write(buf)
...
fun:_ZNK20NormalTestTerminator15exitCurrentTestEv
}
{
cpputest_PlatformSpecificSetJmpImplementation
Memcheck:Addr8
...
fun:PlatformSpecificSetJmpImplementation
}
{
cpputest_CommandLineTestRunner_dtor
Memcheck:Free
fun:_ZdlPvm
fun:_ZN21CommandLineTestRunnerD1Ev
}

0 comments on commit 264c175

Please sign in to comment.