mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 02:36:37 +08:00
fix unit tests: do not stub pthread_cond_wait
and fix the tests instead. Some unit tests depend on pthread_cond_wait to work as expected.
This commit is contained in:
@@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
set(SRCS
|
set(SRCS
|
||||||
stub_daemon.cpp
|
stub_daemon.cpp
|
||||||
stub_parameter.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
px4_add_library(test_stubs ${SRCS})
|
px4_add_library(test_stubs ${SRCS})
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
#include "stub_parameter.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
/* This function blocks forever in tests, so override it with a version that can be customized */
|
|
||||||
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
|
|
||||||
{
|
|
||||||
return stub_pthread_cond_wait_callback(cond, mutex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
std::function<int(pthread_cond_t *, pthread_mutex_t *)> stub_pthread_cond_wait_callback =
|
|
||||||
[](pthread_cond_t *, pthread_mutex_t *) {return 0;};
|
|
||||||
@@ -49,6 +49,7 @@ public:
|
|||||||
void SetUp() override
|
void SetUp() override
|
||||||
|
|
||||||
{
|
{
|
||||||
|
param_control_autosave(false);
|
||||||
param_reset_all();
|
param_reset_all();
|
||||||
pos_sp = Vector3f(1.f, 1.2f, 0.1f);
|
pos_sp = Vector3f(1.f, 1.2f, 0.1f);
|
||||||
vel_sp = Vector3f(0.3f, 0.4f, 0.1f);
|
vel_sp = Vector3f(0.3f, 0.4f, 0.1f);
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class CollisionPreventionTest : public ::testing::Test
|
|||||||
public:
|
public:
|
||||||
void SetUp() override
|
void SetUp() override
|
||||||
{
|
{
|
||||||
|
param_control_autosave(false);
|
||||||
param_reset_all();
|
param_reset_all();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class ParameterTest : public ::testing::Test
|
|||||||
public:
|
public:
|
||||||
void SetUp() override
|
void SetUp() override
|
||||||
{
|
{
|
||||||
|
param_control_autosave(false);
|
||||||
param_reset_all();
|
param_reset_all();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user