mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-18 07:57:35 +08:00
GTest functional tests that include parameters and uORB messaging (#12521)
* Add kdevelop to gitignore * Add test stubs * Rename px4_add_gtest to px4_add_unit_gtest * Add infrastructure to run functional tests * Add example tests with parameters and uorb messages * Fix memory issues in destructors in uORB manager and CDev * Add a more real-world test of the collision prevention
This commit is contained in:
@@ -39,4 +39,4 @@ target_include_directories(AttitudeControl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
px4_add_gtest(SRC AttitudeControlTest.cpp LINKLIBS AttitudeControl)
|
||||
px4_add_unit_gtest(SRC AttitudeControlTest.cpp LINKLIBS AttitudeControl)
|
||||
|
||||
@@ -39,4 +39,4 @@ target_include_directories(Takeoff
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
px4_add_gtest(SRC TakeoffTest.cpp LINKLIBS Takeoff)
|
||||
px4_add_unit_gtest(SRC TakeoffTest.cpp LINKLIBS Takeoff)
|
||||
|
||||
@@ -102,10 +102,10 @@ uORB::DeviceMaster::advertise(const struct orb_metadata *meta, int *instance, in
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* construct the new node */
|
||||
/* construct the new node, passing the ownership of path to it */
|
||||
uORB::DeviceNode *node = new uORB::DeviceNode(meta, group_tries, devpath, priority);
|
||||
|
||||
/* if we didn't get a device, that's bad */
|
||||
/* if we didn't get a device, that's bad, free the path too */
|
||||
if (node == nullptr) {
|
||||
free((void *)devpath);
|
||||
return -ENOMEM;
|
||||
@@ -133,9 +133,6 @@ uORB::DeviceMaster::advertise(const struct orb_metadata *meta, int *instance, in
|
||||
}
|
||||
}
|
||||
|
||||
/* also discard the name now */
|
||||
free((void *)devpath);
|
||||
|
||||
} else {
|
||||
// add to the node map;.
|
||||
_node_list.add(node);
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
|
||||
#include "uORBDeviceNode.hpp"
|
||||
|
||||
#include "uORBDeviceNode.hpp"
|
||||
#include "uORBUtils.hpp"
|
||||
#include "uORBManager.hpp"
|
||||
|
||||
@@ -70,6 +69,8 @@ uORB::DeviceNode::~DeviceNode()
|
||||
if (_data != nullptr) {
|
||||
delete[] _data;
|
||||
}
|
||||
|
||||
CDev::unregister_driver_and_memory();
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
@@ -56,7 +56,7 @@ class uORB::DeviceNode : public cdev::CDev, public ListNode<uORB::DeviceNode *>
|
||||
public:
|
||||
DeviceNode(const struct orb_metadata *meta, const uint8_t instance, const char *path, uint8_t priority,
|
||||
uint8_t queue_size = 1);
|
||||
~DeviceNode();
|
||||
virtual ~DeviceNode();
|
||||
|
||||
// no copy, assignment, move, move assignment
|
||||
DeviceNode(const DeviceNode &) = delete;
|
||||
|
||||
@@ -55,6 +55,17 @@ bool uORB::Manager::initialize()
|
||||
return _Instance != nullptr;
|
||||
}
|
||||
|
||||
bool uORB::Manager::terminate()
|
||||
{
|
||||
if (_Instance != nullptr) {
|
||||
delete _Instance;
|
||||
_Instance = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
uORB::Manager::Manager()
|
||||
{
|
||||
#ifdef ORB_USE_PUBLISHER_RULES
|
||||
|
||||
@@ -75,6 +75,12 @@ public:
|
||||
*/
|
||||
static bool initialize();
|
||||
|
||||
/**
|
||||
* Terminate the singleton. Call this after everything else.
|
||||
* @return true on success
|
||||
*/
|
||||
static bool terminate();
|
||||
|
||||
/**
|
||||
* Method to get the singleton instance for the uORB::Manager.
|
||||
* Make sure initialize() is called first.
|
||||
@@ -416,7 +422,7 @@ private: // data members
|
||||
|
||||
private: //class methods
|
||||
Manager();
|
||||
~Manager();
|
||||
virtual ~Manager();
|
||||
|
||||
#ifdef ORB_COMMUNICATOR
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user