mavsdk_tests: don't block inside of callback

This is required with MAVSDK v0.29.0 and later!
This commit is contained in:
Julian Oes 2020-07-29 15:02:51 +02:00 committed by Daniel Agar
parent 8d3f1e63f0
commit 4eb1ea10f0
2 changed files with 22 additions and 10 deletions

View File

@ -7,6 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(MAVSDK REQUIRED)
find_package(Threads REQUIRED)
if(MAVSDK_FOUND)
add_executable(mavsdk_tests
@ -27,6 +28,7 @@ if(MAVSDK_FOUND)
MAVSDK::mavsdk_offboard
MAVSDK::mavsdk_param
MAVSDK::mavsdk_telemetry
${CMAKE_THREAD_LIBS_INIT}
)
target_compile_options(mavsdk_tests

View File

@ -238,8 +238,10 @@ void AutopilotTester::execute_mission_and_lose_gps()
std::cout << "Progress: " << progress.current << "/" << progress.total;
if (progress.current == 1) {
CHECK(_failure->inject(Failure::FailureUnit::SensorGps, Failure::FailureType::Off, 0)
== Failure::Result::Success);
std::thread([this]() {
CHECK(_failure->inject(Failure::FailureUnit::SensorGps, Failure::FailureType::Off, 0)
== Failure::Result::Success);
}).detach();
}
});
@ -267,8 +269,10 @@ void AutopilotTester::execute_mission_and_lose_mag()
std::cout << "Progress: " << progress.current << "/" << progress.total;
if (progress.current == 1) {
CHECK(_failure->inject(Failure::FailureUnit::SensorMag, Failure::FailureType::Off, 0)
== Failure::Result::Success);
std::thread([this]() {
CHECK(_failure->inject(Failure::FailureUnit::SensorMag, Failure::FailureType::Off, 0)
== Failure::Result::Success);
}).detach();
}
});
@ -297,8 +301,10 @@ void AutopilotTester::execute_mission_and_lose_baro()
std::cout << "Progress: " << progress.current << "/" << progress.total;
if (progress.current == 1) {
CHECK(_failure->inject(Failure::FailureUnit::SensorBaro, Failure::FailureType::Off, 0)
== Failure::Result::Success);
std::thread([this]() {
CHECK(_failure->inject(Failure::FailureUnit::SensorBaro, Failure::FailureType::Off, 0)
== Failure::Result::Success);
}).detach();
}
});
@ -326,8 +332,10 @@ void AutopilotTester::execute_mission_and_get_baro_stuck()
std::cout << "Progress: " << progress.current << "/" << progress.total;
if (progress.current == 1) {
CHECK(_failure->inject(Failure::FailureUnit::SensorBaro, Failure::FailureType::Stuck, 0)
== Failure::Result::Success);
std::thread([this]() {
CHECK(_failure->inject(Failure::FailureUnit::SensorBaro, Failure::FailureType::Stuck, 0)
== Failure::Result::Success);
}).detach();
}
});
@ -355,8 +363,10 @@ void AutopilotTester::execute_mission_and_get_mag_stuck()
std::cout << "Progress: " << progress.current << "/" << progress.total;
if (progress.current == 1) {
CHECK(_failure->inject(Failure::FailureUnit::SensorMag, Failure::FailureType::Stuck, 0)
== Failure::Result::Success);
std::thread([this]() {
CHECK(_failure->inject(Failure::FailureUnit::SensorMag, Failure::FailureType::Stuck, 0)
== Failure::Result::Success);
}).detach();
}
});