mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 15:07:34 +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:
@@ -395,4 +395,27 @@ CDev::remove_poll_waiter(px4_pollfd_struct_t *fds)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int CDev::unregister_driver_and_memory()
|
||||
{
|
||||
int retval = PX4_OK;
|
||||
|
||||
if (_registered) {
|
||||
unregister_driver(_devname);
|
||||
_registered = false;
|
||||
|
||||
} else {
|
||||
retval = -ENODEV;
|
||||
}
|
||||
|
||||
if (_devname != nullptr) {
|
||||
free((void *)_devname);
|
||||
_devname = nullptr;
|
||||
|
||||
} else {
|
||||
retval = -ENODEV;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
} // namespace cdev
|
||||
|
||||
@@ -264,6 +264,17 @@ protected:
|
||||
|
||||
px4_sem_t _lock; /**< lock to protect access to all class members (also for derived classes) */
|
||||
|
||||
|
||||
/**
|
||||
* First, unregisters the driver. Next, free the memory for the devname,
|
||||
* in case it was expected to have ownership. Sets devname to nullptr.
|
||||
*
|
||||
* This is only needed if the ownership of the devname was passed to the CDev, otherwise ~CDev handles it.
|
||||
*
|
||||
* @return PX4_OK on success, -ENODEV if the devname is already nullptr
|
||||
*/
|
||||
int unregister_driver_and_memory();
|
||||
|
||||
private:
|
||||
const char *_devname{nullptr}; /**< device node name */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user