From 9d4baefa68944dc0eba3d15661d50d7c7c9058c4 Mon Sep 17 00:00:00 2001 From: hhenry01 Date: Wed, 6 Mar 2024 20:18:39 -0800 Subject: [PATCH] temp commit to debug CI --- functions.cmake | 1 + .../src/local_transceiver.cpp | 6 ++--- .../test/test_local_transceiver.cpp | 22 ++++++++++++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/functions.cmake b/functions.cmake index 92d0408..ef704fb 100644 --- a/functions.cmake +++ b/functions.cmake @@ -50,5 +50,6 @@ function(make_unit_test module srcs link_libs inc_dirs compile_defs) add_dependencies(${test_module} ${AUTOGEN_TARGETS}) # Make the unit test runnable with CTest (invoked via test.sh) add_test(NAME ${test_module} COMMAND ${test_module}) + set_tests_properties(${test_module} PROPERTIES TIMEOUT 60) # 1 minute per test timeout endif() endfunction() diff --git a/projects/local_transceiver/src/local_transceiver.cpp b/projects/local_transceiver/src/local_transceiver.cpp index 5bc174a..43c74ec 100644 --- a/projects/local_transceiver/src/local_transceiver.cpp +++ b/projects/local_transceiver/src/local_transceiver.cpp @@ -85,9 +85,9 @@ void LocalTransceiver::updateSensor(msg::GenericSensors msg) void LocalTransceiver::updateSensor(msg::LPathData localData) { sensors_.clear_local_path_data(); + Sensors::Path * new_local = sensors_.mutable_local_path_data(); for (const msg::HelperLatLon & local_data : localData.local_path.waypoints) { - Sensors::Path * new_local = sensors_.mutable_local_path_data(); - Polaris::Waypoint * waypoint = new_local->add_waypoints(); + Polaris::Waypoint * waypoint = new_local->add_waypoints(); waypoint->set_latitude(local_data.latitude); waypoint->set_longitude(local_data.longitude); } @@ -135,7 +135,7 @@ bool LocalTransceiver::send() throw std::length_error(err_string); } - std::string write_bin_cmd_str = AT::write_bin::CMD + std::to_string(data.size()); //according to specs + std::string write_bin_cmd_str = AT::write_bin::CMD + std::to_string(data.size()); //according to specs AT::Line at_write_cmd(write_bin_cmd_str); static constexpr int MAX_NUM_RETRIES = 20; // allow retries because the connection is imperfect diff --git a/projects/local_transceiver/test/test_local_transceiver.cpp b/projects/local_transceiver/test/test_local_transceiver.cpp index c3b0002..aa727db 100644 --- a/projects/local_transceiver/test/test_local_transceiver.cpp +++ b/projects/local_transceiver/test/test_local_transceiver.cpp @@ -36,15 +36,25 @@ class TestLocalTransceiver : public ::testing::Test protected: static void SetUpTestSuite() { http_echo_server_proc_ = bp::child(RUN_HTTP_ECHO_SERVER_CMD); } - static void TearDownTestSuite() { http_echo_server_proc_.terminate(); } + static void TearDownTestSuite() + { + std::error_code e; + http_echo_server_proc_.terminate(e); + if (e) { + throw std::runtime_error("Failed to terminate HTTP Echo Server! " + e.message()); + } + } TestLocalTransceiver() { try { lcl_trns_ = new LocalTransceiver(LOCAL_TRANSCEIVER_TEST_PORT, SATELLITE_BAUD_RATE); - } catch (boost::system::system_error & /**/) { - std::cerr << "Failed to create Local Transceiver for tests, is only one instance of: \"" - << RUN_VIRTUAL_IRIDIUM_SCRIPT_PATH << "\" running?" << std::endl; + } catch (boost::system::system_error & e) { + std::stringstream ss; + ss << "Failed to create Local Transceiver for tests, is only one instance of: \"" + << RUN_VIRTUAL_IRIDIUM_SCRIPT_PATH << "\" running?" << std::endl; + ss << e.what() << std::endl; + throw std::runtime_error(ss.str()); } } ~TestLocalTransceiver() override @@ -162,5 +172,7 @@ TEST_F(TestLocalTransceiver, sendData) lcl_trns_->updateSensor(batteries); lcl_trns_->updateSensor(sensors); lcl_trns_->updateSensor(local_paths); - lcl_trns_->send(); + + std::cout << "Sending data" << std::endl; + // EXPECT_TRUE(lcl_trns_->send()); }