From f92e3d1e0cdaf0c63454814d7c12a65d73c698d0 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Tue, 31 Oct 2023 08:29:09 +1300 Subject: [PATCH] system_tests: try to avoid segfaults This is an attempt to avoid spurious segfaults happening in some of the CI tests for some of the system tests. Presumably they happen on the quick destruction of the objects right after construction. Signed-off-by: Julian Oes --- src/system_tests/action_arm_disarm.cpp | 3 +++ src/system_tests/camera_take_photo.cpp | 3 +++ src/system_tests/component_information.cpp | 3 +++ src/system_tests/ftp_compare_files.cpp | 3 +++ src/system_tests/ftp_create_dir.cpp | 3 +++ src/system_tests/ftp_download_file.cpp | 11 +++++++++++ src/system_tests/ftp_download_file_burst.cpp | 11 +++++++++++ src/system_tests/ftp_list_dir.cpp | 3 +++ src/system_tests/ftp_remove_dir.cpp | 5 +++++ src/system_tests/ftp_remove_file.cpp | 7 +++++++ src/system_tests/ftp_rename_file.cpp | 3 +++ src/system_tests/ftp_upload_file.cpp | 11 +++++++++++ src/system_tests/mission_raw_upload.cpp | 3 +++ src/system_tests/param_custom_set_and_get.cpp | 5 +++++ src/system_tests/param_get_all.cpp | 5 +++++ src/system_tests/param_set_and_get.cpp | 3 +++ src/system_tests/telemetry_subscription.cpp | 3 +++ 17 files changed, 85 insertions(+) diff --git a/src/system_tests/action_arm_disarm.cpp b/src/system_tests/action_arm_disarm.cpp index db2093126f..a1e46d37d3 100644 --- a/src/system_tests/action_arm_disarm.cpp +++ b/src/system_tests/action_arm_disarm.cpp @@ -3,6 +3,7 @@ #include "plugins/action/action.h" #include "plugins/action_server/action_server.h" #include +#include using namespace mavsdk; @@ -48,4 +49,6 @@ TEST(SystemTest, ActionArmDisarm) // And disarm again EXPECT_EQ(action.disarm(), Action::Result::Success); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/camera_take_photo.cpp b/src/system_tests/camera_take_photo.cpp index 0d5b24a365..05e3dd9422 100644 --- a/src/system_tests/camera_take_photo.cpp +++ b/src/system_tests/camera_take_photo.cpp @@ -4,6 +4,7 @@ #include "log.h" #include #include +#include #include using namespace mavsdk; @@ -69,4 +70,6 @@ TEST(SystemTest, CameraTakePhoto) ASSERT_EQ( received_captured_info_fut.wait_for(std::chrono::seconds(10)), std::future_status::ready); received_captured_info_fut.get(); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/component_information.cpp b/src/system_tests/component_information.cpp index b379fa0d2e..bb55ad84b0 100644 --- a/src/system_tests/component_information.cpp +++ b/src/system_tests/component_information.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "mavsdk.h" #include "log.h" @@ -67,4 +68,6 @@ TEST(SystemTest, DISABLED_ComponentInformationConnect) // Use another parameter to trigger the second callback. param_client.set_param_float("ANG_RATE_ACC_MAX", 6.0f); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/ftp_compare_files.cpp b/src/system_tests/ftp_compare_files.cpp index db4815ff66..ccbd7da8dd 100644 --- a/src/system_tests/ftp_compare_files.cpp +++ b/src/system_tests/ftp_compare_files.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "plugins/ftp/ftp.h" #include "plugins/ftp_server/ftp_server.h" #include "fs_helpers.h" @@ -73,4 +74,6 @@ TEST(SystemTest, FtpCompareFiles) (temp_dir_provided / temp_file).string(), temp_file_different.string()); EXPECT_EQ(result.first, Ftp::Result::Success); EXPECT_EQ(result.second, false); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/ftp_create_dir.cpp b/src/system_tests/ftp_create_dir.cpp index cf15c8bcc5..5e7c9495b7 100644 --- a/src/system_tests/ftp_create_dir.cpp +++ b/src/system_tests/ftp_create_dir.cpp @@ -7,6 +7,7 @@ #include #include #include +#include using namespace mavsdk; @@ -57,4 +58,6 @@ TEST(SystemTest, FtpCreateDir) EXPECT_EQ(ftp.create_directory(temp_dir.string()), Ftp::Result::Success); EXPECT_TRUE(file_exists(temp_dir_provided / temp_dir)); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/ftp_download_file.cpp b/src/system_tests/ftp_download_file.cpp index ea7d2341c5..71f55e29fb 100644 --- a/src/system_tests/ftp_download_file.cpp +++ b/src/system_tests/ftp_download_file.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "plugins/ftp/ftp.h" #include "plugins/ftp_server/ftp_server.h" #include "fs_helpers.h" @@ -92,6 +93,8 @@ TEST(SystemTest, FtpDownloadFile) EXPECT_TRUE( are_files_identical(temp_dir_provided / temp_file, temp_dir_downloaded / temp_file)); } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpDownloadBigFile) @@ -147,6 +150,8 @@ TEST(SystemTest, FtpDownloadBigFile) EXPECT_TRUE( are_files_identical(temp_dir_provided / temp_file, temp_dir_downloaded / temp_file)); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpDownloadBigFileLossy) @@ -213,6 +218,8 @@ TEST(SystemTest, FtpDownloadBigFileLossy) // drop_some callback which accesses the local counter variable. mavsdk_groundstation.intercept_incoming_messages_async(nullptr); mavsdk_groundstation.intercept_outgoing_messages_async(nullptr); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpDownloadStopAndTryAgain) @@ -302,6 +309,8 @@ TEST(SystemTest, FtpDownloadStopAndTryAgain) ASSERT_EQ(future_status, std::future_status::ready); EXPECT_EQ(fut.get(), Ftp::Result::Success); } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpDownloadFileOutsideOfRoot) @@ -352,4 +361,6 @@ TEST(SystemTest, FtpDownloadFileOutsideOfRoot) ASSERT_EQ(future_status, std::future_status::ready); EXPECT_EQ(fut.get(), Ftp::Result::ProtocolError); } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/ftp_download_file_burst.cpp b/src/system_tests/ftp_download_file_burst.cpp index 1269b4e4fd..cfcfed4acd 100644 --- a/src/system_tests/ftp_download_file_burst.cpp +++ b/src/system_tests/ftp_download_file_burst.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "plugins/ftp/ftp.h" #include "plugins/ftp_server/ftp_server.h" #include "fs_helpers.h" @@ -92,6 +93,8 @@ TEST(SystemTest, FtpDownloadBurstFile) EXPECT_TRUE( are_files_identical(temp_dir_provided / temp_file, temp_dir_downloaded / temp_file)); } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpDownloadBurstBigFile) @@ -147,6 +150,8 @@ TEST(SystemTest, FtpDownloadBurstBigFile) EXPECT_TRUE( are_files_identical(temp_dir_provided / temp_file, temp_dir_downloaded / temp_file)); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpDownloadBurstBigFileLossy) @@ -213,6 +218,8 @@ TEST(SystemTest, FtpDownloadBurstBigFileLossy) // drop_some callback which accesses the local counter variable. mavsdk_groundstation.intercept_incoming_messages_async(nullptr); mavsdk_groundstation.intercept_outgoing_messages_async(nullptr); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpDownloadBurstStopAndTryAgain) @@ -302,6 +309,8 @@ TEST(SystemTest, FtpDownloadBurstStopAndTryAgain) ASSERT_EQ(future_status, std::future_status::ready); EXPECT_EQ(fut.get(), Ftp::Result::Success); } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpDownloadBurstFileOutsideOfRoot) @@ -352,4 +361,6 @@ TEST(SystemTest, FtpDownloadBurstFileOutsideOfRoot) ASSERT_EQ(future_status, std::future_status::ready); EXPECT_EQ(fut.get(), Ftp::Result::ProtocolError); } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/ftp_list_dir.cpp b/src/system_tests/ftp_list_dir.cpp index 38683fab01..7541e12827 100644 --- a/src/system_tests/ftp_list_dir.cpp +++ b/src/system_tests/ftp_list_dir.cpp @@ -8,6 +8,7 @@ #include #include #include +#include using namespace mavsdk; @@ -73,4 +74,6 @@ TEST(SystemTest, FtpListDir) EXPECT_EQ(ret.first, Ftp::Result::Success); EXPECT_EQ(ret.second, truth_list); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/ftp_remove_dir.cpp b/src/system_tests/ftp_remove_dir.cpp index 4aae10a351..290a271f12 100644 --- a/src/system_tests/ftp_remove_dir.cpp +++ b/src/system_tests/ftp_remove_dir.cpp @@ -7,6 +7,7 @@ #include #include #include +#include using namespace mavsdk; @@ -58,6 +59,8 @@ TEST(SystemTest, FtpRemoveDir) EXPECT_EQ(ftp.remove_directory(temp_dir.string()), Ftp::Result::Success); EXPECT_FALSE(file_exists(temp_dir_provided / temp_dir)); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpRemoveDirNotEmpty) @@ -97,4 +100,6 @@ TEST(SystemTest, FtpRemoveDirNotEmpty) EXPECT_EQ(ftp.remove_directory(temp_dir.string()), Ftp::Result::ProtocolError); EXPECT_TRUE(file_exists(temp_dir_provided / temp_dir)); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/ftp_remove_file.cpp b/src/system_tests/ftp_remove_file.cpp index 944fa8439b..62214e5c24 100644 --- a/src/system_tests/ftp_remove_file.cpp +++ b/src/system_tests/ftp_remove_file.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "plugins/ftp/ftp.h" #include "plugins/ftp_server/ftp_server.h" #include "fs_helpers.h" @@ -58,6 +59,8 @@ TEST(SystemTest, FtpRemoveFile) EXPECT_EQ(ftp.remove_file(temp_file.string()), Ftp::Result::Success); EXPECT_FALSE(file_exists(temp_dir_provided / temp_file)); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpRemoveFileThatDoesNotExist) @@ -95,6 +98,8 @@ TEST(SystemTest, FtpRemoveFileThatDoesNotExist) EXPECT_EQ(ftp.remove_file(temp_file.string()), Ftp::Result::FileDoesNotExist); EXPECT_FALSE(file_exists(temp_dir_provided / temp_file)); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpRemoveFileOutsideOfRoot) @@ -130,4 +135,6 @@ TEST(SystemTest, FtpRemoveFileOutsideOfRoot) ftp_server.set_root_dir(temp_dir_provided.string()); EXPECT_EQ(ftp.remove_file((fs::path("..") / temp_file).string()), Ftp::Result::ProtocolError); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/ftp_rename_file.cpp b/src/system_tests/ftp_rename_file.cpp index 87a62813de..20e2ad5154 100644 --- a/src/system_tests/ftp_rename_file.cpp +++ b/src/system_tests/ftp_rename_file.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "plugins/ftp/ftp.h" #include "plugins/ftp_server/ftp_server.h" #include "fs_helpers.h" @@ -61,4 +62,6 @@ TEST(SystemTest, FtpRenameFile) EXPECT_EQ(ftp.rename(temp_file.string(), temp_file_renamed.string()), Ftp::Result::Success); EXPECT_TRUE(file_exists(temp_dir_provided / temp_file_renamed)); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/ftp_upload_file.cpp b/src/system_tests/ftp_upload_file.cpp index 04f9e1ed63..81e47b667a 100644 --- a/src/system_tests/ftp_upload_file.cpp +++ b/src/system_tests/ftp_upload_file.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "plugins/ftp/ftp.h" #include "plugins/ftp_server/ftp_server.h" #include "fs_helpers.h" @@ -94,6 +95,8 @@ TEST(SystemTest, FtpUploadFile) EXPECT_TRUE( are_files_identical(temp_dir_to_upload / temp_file, temp_dir_provided / temp_file)); } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpUploadBigFile) @@ -150,6 +153,8 @@ TEST(SystemTest, FtpUploadBigFile) EXPECT_TRUE( are_files_identical(temp_dir_to_upload / temp_file, temp_dir_provided / temp_file)); } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpUploadBigFileLossy) @@ -215,6 +220,8 @@ TEST(SystemTest, FtpUploadBigFileLossy) mavsdk_groundstation.intercept_incoming_messages_async(nullptr); mavsdk_groundstation.intercept_outgoing_messages_async(nullptr); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpUploadStopAndTryAgain) @@ -302,6 +309,8 @@ TEST(SystemTest, FtpUploadStopAndTryAgain) ASSERT_EQ(future_status, std::future_status::ready); EXPECT_EQ(fut.get(), Ftp::Result::Success); } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, FtpUploadFileOutsideOfRoot) @@ -354,4 +363,6 @@ TEST(SystemTest, FtpUploadFileOutsideOfRoot) ASSERT_EQ(future_status, std::future_status::ready); EXPECT_EQ(fut.get(), Ftp::Result::ProtocolError); } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/mission_raw_upload.cpp b/src/system_tests/mission_raw_upload.cpp index 474a919520..efc7dc60de 100644 --- a/src/system_tests/mission_raw_upload.cpp +++ b/src/system_tests/mission_raw_upload.cpp @@ -5,6 +5,7 @@ #include "plugins/mission_raw_server/mission_raw_server.h" #include #include +#include #include using namespace mavsdk; @@ -42,4 +43,6 @@ TEST(SystemTest, MissionRawUpload) EXPECT_EQ( mission_raw.upload_mission(result_pair.second.mission_items), MissionRaw::Result::Success); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/param_custom_set_and_get.cpp b/src/system_tests/param_custom_set_and_get.cpp index ecdab0635d..ace4fe5770 100644 --- a/src/system_tests/param_custom_set_and_get.cpp +++ b/src/system_tests/param_custom_set_and_get.cpp @@ -2,6 +2,7 @@ #include "mavsdk.h" #include "plugins/param/param.h" #include "plugins/param_server/param_server.h" +#include #include using namespace mavsdk; @@ -79,6 +80,8 @@ TEST(SystemTest, ParamCustomSetAndGet) auto server_result_pair = param_server.retrieve_param_custom(param_name); EXPECT_EQ(server_result_pair.first, ParamServer::Result::Success); EXPECT_EQ(server_result_pair.second, data_shorter); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, ParamCustomSetAndGetLossy) @@ -146,4 +149,6 @@ TEST(SystemTest, ParamCustomSetAndGetLossy) // drop_some callback which accesses the local counter variable. mavsdk_groundstation.intercept_incoming_messages_async(nullptr); mavsdk_groundstation.intercept_incoming_messages_async(nullptr); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/param_get_all.cpp b/src/system_tests/param_get_all.cpp index 1680f2290c..baf531078a 100644 --- a/src/system_tests/param_get_all.cpp +++ b/src/system_tests/param_get_all.cpp @@ -7,6 +7,7 @@ #include #include #include +#include using namespace mavsdk; @@ -115,6 +116,8 @@ TEST(SystemTest, ParamGetAll) assert_equal(test_float_params, all_params.float_params); assert_equal(test_string_params, all_params.custom_params); } + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, ParamGetAllLossy) @@ -187,4 +190,6 @@ TEST(SystemTest, ParamGetAllLossy) // drop_some callback which accesses the local counter variable. mavsdk_groundstation.intercept_incoming_messages_async(nullptr); mavsdk_groundstation.intercept_outgoing_messages_async(nullptr); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } diff --git a/src/system_tests/param_set_and_get.cpp b/src/system_tests/param_set_and_get.cpp index 2f302e5f31..2b43e844e3 100644 --- a/src/system_tests/param_set_and_get.cpp +++ b/src/system_tests/param_set_and_get.cpp @@ -3,6 +3,7 @@ #include "plugins/param/param.h" #include "plugins/param_server/param_server.h" #include +#include #include using namespace mavsdk; @@ -94,6 +95,8 @@ TEST(SystemTest, ParamSetAndGet) auto server_result_all_params = param_server.retrieve_all_params(); EXPECT_EQ(server_result_all_params.int_params.size(), 1); EXPECT_EQ(server_result_all_params.float_params.size(), 1); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } TEST(SystemTest, ParamSetAndGetLossy) diff --git a/src/system_tests/telemetry_subscription.cpp b/src/system_tests/telemetry_subscription.cpp index 9587baf29a..06962a2a8a 100644 --- a/src/system_tests/telemetry_subscription.cpp +++ b/src/system_tests/telemetry_subscription.cpp @@ -3,6 +3,7 @@ #include "plugins/telemetry/telemetry.h" #include "plugins/telemetry_server/telemetry_server.h" #include +#include #include using namespace mavsdk; @@ -74,4 +75,6 @@ TEST(SystemTest, TelemetrySubscription) EXPECT_EQ(num_subscription1_called, 2); EXPECT_EQ(num_subscription2_called, 3); + + std::this_thread::sleep_for(std::chrono::milliseconds(100)); }