-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fault injection macro unit tests #27
Conversation
Signed-off-by: Stephen Brawner <brawner@gmail.com>
Signed-off-by: Stephen Brawner <brawner@gmail.com>
@@ -1550,3 +1551,64 @@ TEST(test_graph_cache, bad_arguments) | |||
rcutils_reset_error(); | |||
} | |||
} | |||
|
|||
TEST(test_graph_cache, get_writers_info_by_topic_maybe_fail) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brawner would it make sense to split this test case into three separate ones (i.e. one for each method being fault injected).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, done! I think I originally intended for that given the test name.
graph_cache, { | ||
{"participant1", "ns1", "node1"}, | ||
{"participant1", "ns1", "node2"}, | ||
{"participant1", "ns2", "node1"}}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brawner perhaps not an issue, but should the test fixture be setup outside the fault injection loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yah, created a test fixture class.
&allocator, | ||
&info); | ||
if (RMW_RET_OK == ret) { | ||
ret = rmw_topic_endpoint_info_array_fini(&info, &allocator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brawner should this be:
ret = rmw_topic_endpoint_info_array_fini(&info, &allocator); | |
EXPECT_EQ(RWM_RET_OK, rmw_topic_endpoint_info_array_fini(&info, &allocator)); |
instead? Also, what if fault injection occurs here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it will fail during a fault injection test because there will be at least one hook in there. I added a check on the return of fini just in case it needs be done a second time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor question
RCUTILS_FAULT_INJECTION_TEST( | ||
{ | ||
GraphCache graph_cache; | ||
add_participants(graph_cache, {"participant1"}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this init section be left out of the fault_injection test macro?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. I created a test fixture class and split this test into three separate TEST_Fs
@@ -1550,3 +1551,64 @@ TEST(test_graph_cache, bad_arguments) | |||
rcutils_reset_error(); | |||
} | |||
} | |||
|
|||
TEST(test_graph_cache, get_writers_info_by_topic_maybe_fail) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, done! I think I originally intended for that given the test name.
RCUTILS_FAULT_INJECTION_TEST( | ||
{ | ||
GraphCache graph_cache; | ||
add_participants(graph_cache, {"participant1"}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. I created a test fixture class and split this test into three separate TEST_Fs
graph_cache, { | ||
{"participant1", "ns1", "node1"}, | ||
{"participant1", "ns1", "node2"}, | ||
{"participant1", "ns2", "node1"}}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yah, created a test fixture class.
&allocator, | ||
&info); | ||
if (RMW_RET_OK == ret) { | ||
ret = rmw_topic_endpoint_info_array_fini(&info, &allocator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it will fail during a fault injection test because there will be at least one hook in there. I added a check on the return of fini just in case it needs be done a second time.
ret = rcutils_string_array_fini(&namespaces); | ||
ret = rcutils_string_array_fini(&enclaves); | ||
// rcutils_string_array_fini is not under test, so disable fault injection test here. | ||
int64_t fault_injection_count = rcutils_fault_injection_get_count(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hidmic This is the only location here that would make sense to disable fault injection testing because rcutils_string_array_fini
is out of scope for this test. Do you think it would make sense to submit a PR to rcutils to add in the disable fault injection testing macros?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine as-is for the time being. If it starts showing up more often, we can add a macro.
Trying again after merging ros2/rcutils#283 |
|
Why not first release |
That's reasonable. It will be my first release, so I was just unsure about the whole process. I'll work to figure it out. |
* Add fault injection macro unit tests Signed-off-by: Stephen Brawner <brawner@gmail.com> * target definitions Signed-off-by: Stephen Brawner <brawner@gmail.com> * PR Fixup Signed-off-by: Stephen Brawner <brawner@gmail.com>
* Add fault injection macro unit tests Signed-off-by: Stephen Brawner <brawner@gmail.com> * target definitions Signed-off-by: Stephen Brawner <brawner@gmail.com> * PR Fixup Signed-off-by: Stephen Brawner <brawner@gmail.com>
Adding fault injection unit tests to rmw_dds_common. This should get coverage to about 99%. I'll post CI results soon.
Signed-off-by: Stephen Brawner brawner@gmail.com