Commit graph

779 commits

Author SHA1 Message Date
Dirk Thomas
6bbe229fac increase timeouts in test_services fixtures for Connext (#745)
Signed-off-by: Dirk Thomas <dirk-thomas@users.noreply.github.com>
2020-11-02 16:22:11 +01:00
Chris Lalancette
90ce16dfd8 Add a semicolon to RCUTILS_LOGGING_AUTOINIT. (#816)
This makes it look like a C statement.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
2020-11-02 16:22:11 +01:00
Chris Lalancette
1f7baf2ee5 Make sure to always check return values. (#840)
* Make sure to always check return values.

Pointed out by clang static analysis, we should always
check these return values.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
2020-11-02 16:22:11 +01:00
Jacob Perron
fd2f427563 Zero initialize events an size_of_events members of rcl_wait_set_t (#841)
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
2020-11-02 16:22:11 +01:00
Jacob Perron
675dbac13f Return OK when finalizing zero-initialized contexts (#842)
Resolves #814

This is consistent behavior with finalizing other types of zero-initialized objects.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
2020-11-02 16:22:11 +01:00
Chris Lalancette
885fa21a89 Make sure to check the return value of rcl APIs. (#838)
This is just a further check to ensure the test is correct,
and also gets rid of a slew of dead store warnings from
clang static analysis.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
2020-11-02 16:22:11 +01:00
Chen Lihui
0d353dde87 Fix memory leak because of mock test (#800)
* Fix memory leak because of mock test

Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>
2020-11-02 16:22:11 +01:00
Chen Lihui
22d4eee1a7 Fix that not to deallocate event impl in some failure case (#790)
* Fix that not to deallocate event impl in some failure case

Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
Co-authored-by: Chris Lalancette <clalancette@openrobotics.org>
2020-11-02 16:22:11 +01:00
Chen Lihui
5dc097b9bb calling fini functions to avoid memory leak (#791)
* Fix test memory leaks

1.  calling rcutils_string_map_fini to avoid memory leak
2.  Fix memory leak that not to call rcutils_string_array_fini for enclaves
3.  Fix that not to rcutils_string_array_fini for node_names_2 and node_namespaces_2
4.  Fix that not to rcl_log_levels_fini for copied_log_levels
5.  Fix that not to call rmw_security_options_fini for options
6.  Call test_msgs__srv__BasicTypes_Request__fini for service_request in the end

Signed-off-by: Chen Lihui <Lihui.Chen@sony.com>
2020-11-02 16:22:11 +01:00
ahcorde
2746f51f37 Fixed log level in backported foxy tests
Signed-off-by: ahcorde <ahcorde@gmail.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
424296b153 Bump rcl arguments' API test coverage. (#777)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
4271bcf2dd Fix rcl arguments' API memory leaks and bugs. (#778)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
0613045684 Add coverage tests wait module (#769)
* Add coverage tests wait module
* Add fault injection test
* Add zero_init allocator test to init
* Remove bomb allocator test
* Add better handling fault injection
* Add comment to fault injection tests
* Move test to another section

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
af60a36853 Fix wait allocation cleanup (#770)
* Add fix wait.c init/fini allocation on error
* Add test for the fix
* Remove unit tests

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
907a93dacc Bump test coverage. (#764)
* init/shutdown API
* context fini API
* node init/fini API
* guard condition init/fini API
* security APIs

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
14ef8e02f8 Check rcutils_strdup() outcome immediately. (#768)
Within rcl_node_init() implementation.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
9be4fe9e43 Cleanup rcl_get_secure_root() implementation. (#762)
* Do not assume allocation will succeed.
* Do not leak allocated memory on failure.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
brawner
97e066ff64 Add fault injection macros to rcl functions (#727)
* Add fault injection macros to rcl functions

Signed-off-by: Stephen Brawner <brawner@gmail.com>

* PR fixup

Signed-off-by: Stephen Brawner <brawner@gmail.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
13ded97050 Yield rcl_context_fini() error codes. (#763)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
4476c92dd4 Do not invalidate context before successful shutdown. (#761)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
6d32b6767e Zero initialize guard condition on failed init. (#760)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
8d7bb9fe65 Adding tests to arguments.c (#752)
* Add nullptr tests get_param_files
* Add bad alloc tests
* Add missing tests
* Add bad alloc tests rcl_arguments_copy
* Remove repeated test
* Remove spaces
* Restore erased test
* Relocate test
* Refactor bomb allocator test
* Add missing rcl_reset_error() checks

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
31f5c9963d Extend rcl_expand_topic_name() API test coverage. (#758)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
6d95545a9f Add coverage tests 94% service.c (#756)
* Add tests for fail init
* Add fini tests
* Add tests rcl_take_request_with_info
* Add tests send_response
* Change const strings to constexpr
* Improve test descriptions
* Remove test

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
04210ebdc2 Clean up rcl_expand_topic_name() implementation. (#757)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
ahcorde
0698835633 Added path_to_fail to mocking_utils in rcl
Signed-off-by: ahcorde <ahcorde@gmail.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
7669ced71b Complete rcl enclave validation API coverage. (#751)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
fe2d89d0e1 Fix allocation arguments copy (#748)
* Change allocation method for copied parameter files
* Add bad allocator test

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
316765b2e0 Fix rcl package's logging API error specs and handling. (#746)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
184e3320e3 Fix bug error handling get_param_files (#743)
* Add bomb allocator
* Fix memory checked for error
* Add tests for bad alloc
* Fix break statement
* Add static keyword to methods added

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
2fabe16d9c Complete subscription API test coverage (#734)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
72837b77c6 Add deallocate calls to free strdup allocated memory (#737)
* Add deallocate calls to free strdup allocated memory
* Add variables to know if free is required
* Reformat not use extra booleans
* Address peer review comments

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
f3a8bb0127 Add missing calls to rcl_convert_rmw_ret_to_rcl_ret (#738)
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
c1bf050bff Add mock tests, publisher 95% coverage (#732)
* Add mimick test for rcl_publisher_get_subscription_count
* Remove const qualifiers
* Add missing mock suffix
* Improve test description
* Add mock test for rcl_publisher_assert_liveliness
* Add class to init publisher tests
* Add test for mocked rmw_publish
* Add mock test for rcl_publish_serialized
* Mock rcutils_string_map_init to make init fail
* Add mock test making rmw_publisher_get_actual_qos fail
* Add class to ease mimick usage
* Reformat tests to use helper class
* Add mocked rcutils_string_map_init to make init fail
* Add tests mocking loaned functions
* Add mock fail tests for publisher_init
* Add publisher fini fail mock tests
* Add nullptr tests
* Update mocking utilities
* Reformat with macro utility
* Add comments for mocked tests
* Check count_size value after test
* Reformat to use constexpr where possible
* Add variable making clear bad param test
* Add link to original file to help tracking changes

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
e4004955ad Reformat rmw_impl_id_check to call a testable function (#725)
* Reformat rmw_impl_id_check to call a testable function
* Reformat to expose the function in the public header
* Reformat style return result
* Expose macro names to be tested with the function checker
* Add test for failing cases of the function
* Set error variable and log in the main caller
* Use format string for logging
* Change name of checker function
* Reset rcl error to avoid overwrite

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Chris Lalancette
c8889f2363 Make sure to call rcl_arguments_fini at the end of the test.
This just prevents a memory leak.

Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
2020-11-02 16:22:11 +01:00
Jorge Perez
4e14874cf4 Add remap needed null check (#711)
* Add needed extra null check
* Add test for added check
* Add tests for nullptrs

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
0d411f518e Make public ini/fini rosout publisher (#704)
* Add bad param tests ini/fini rosout publisher
* Make ini/fini_publisher_for_node public

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
01927e52ac Move rcl_remap_copy to public header (#709)
* Add test for remap internal functions
* Add function headers
* Make local function public
* Move rcl_remap_copy to public header

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
563a61cbc6 Add coverage tests for rcl (#703)
* Add tests not empty names_and_types
* Add tests graph.c module
* Add tests remap basic usage
* Add more tests remap module
* Add tests ini/fini publisher_node
* Refactor style and naming
* Add nullptr bad arg
* Add tests bad args
* Add test bad_alloc
* Add missing source file
* Remove not working test
* Remove extra rcl_reset_error
* Change ASSERT to EXPECT when fini scope
* Add const for const arguments
* Add missing fini parsed arguments
* Add error string to output
* Add invalid usage comments to test
* Fix lint line length issues
* Fix uncrustify lint
* Modify test to save alloc struct
* Remove internal source file
* Remove case requiring internal def

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Jorge Perez
3d6c2e90ba Add bad arguments tests for coverage (#698)
* Add test context bad_fini
* Add bad name service tests
* Add default case validation result
* Add bad_arg tests rcl_lexer_lookahead2_accept
* Add bad_arg test rcl_trigger_guard_condition
* Add bad arguments events test
* Add message_lost event test
* Disable failing test
* Address peer review comments
* Remove failing test
* Separate non related API tests
* Add comments to explain error causes
* Use test fixture without params
* Replace nullptr with NULL

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-11-02 16:22:11 +01:00
Michel Hidalgo
7cc97f48f3 Improve error checking and handling in subscription APIs. (#739)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-10-23 19:36:19 +02:00
brawner
a270de6825 Add fault injection macros and unit tests to rcl_action (#730)
* Add fault injection macros and unit tests to rcl_action

Signed-off-by: Stephen Brawner <brawner@gmail.com>

* Addressing  feedback

Signed-off-by: Stephen Brawner <brawner@gmail.com>

* PR Fixup

Signed-off-by: Stephen Brawner <brawner@gmail.com>

* PR Fixup

Signed-off-by: Stephen Brawner <brawner@gmail.com>
2020-10-23 19:36:19 +02:00
Jacob Perron
76a706db9b
Fix memory leak in rcl_subscription_init()/rcl_publisher_init() (#794, #834) (#832)
* Fix memory leak in rcl_subscription_init()/rcl_publisher_init() (#794)

* Fix memory leak in rcl_subscription_init()/rcl_publisher_init()

In rcl_subscription_init(), while rmw_subscription_get_actual_qos()
return failure, created rmw subscription handle isn't freed.
In rcl_publisher_init(), while rmw_publisher_get_actual_qos()
return failure, created rmw publisher handle isn't freed.

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Remove codes on the cascading errors.

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Change code style

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Output error message to stderr

Signed-off-by: Barry Xu <barry.xu@sony.com>

* Remove format string

This version of the macro is not available in Foxy.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Print new line

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

Co-authored-by: Barry Xu <barry.xu@sony.com>
2020-10-16 13:42:49 -07:00
Michel Hidalgo
6ec0c6cfa2 Improve rcl init test coverage. (#684)
* Improve rcl init test coverage.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Address peer review comments.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-10-16 19:28:54 +02:00
Jorge Perez
dda5103935 Remove unused check context.c (#691)
* Remove unused check context.c
* Add test for functionality removed
* Add rcl_reset_error() statement

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-10-16 19:28:54 +02:00
Jorge Perez
91dad10c1e Improve subscription coverage (#681)
* Add bad argument tests for subscription.c
* Add missing rcl_reset_error()
* Add test failing cyclone
* Disable test not working for rmw_cyclone_cpp
* Add simple bad alloc test
* Add tests enclave_name
* Revert "Add tests enclave_name"
* Move init/fini tests
* Add auxiliar testing class
* Reformat into smaller tests
* Add checks ini/fini rmw messages
* Add issue report for disabled test
* Add assert for msg init
* Add bad_allocator test

Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
2020-10-16 19:28:54 +02:00
Michel Hidalgo
c52a938b9e Improve rcl timer test coverage. (#680)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-10-16 19:28:54 +02:00
Michel Hidalgo
b254630a6a Improve wait sets test coverage. (#683)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-10-16 19:28:54 +02:00
Michel Hidalgo
a4aa379d35 Minor fixes to rcl clock implementation. (#688)
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2020-10-16 19:28:54 +02:00