X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Funit%2Ftest_action.cpp;h=ad323e9acc169592c68de995f4344fe6d6e0e997;hp=131a3af1d6aef3ef219e3183e3fdae0060b6522d;hb=HEAD;hpb=2460203ad4c64f0dcdb716e833abee10a79ec092 diff --git a/tests/unit/test_action.cpp b/tests/unit/test_action.cpp index 131a3af1d..52f6d26ca 100644 --- a/tests/unit/test_action.cpp +++ b/tests/unit/test_action.cpp @@ -9,6 +9,7 @@ * */ +#include #include #include @@ -103,9 +104,8 @@ static void test_action_list(void) { int ret, action_idx; struct lttng_action *list_action = NULL, *list_action_from_buffer = NULL, - *mut_inner_action = NULL, *stop_session_action = NULL, - *notify_action = NULL, *start_session_action = NULL; - const struct lttng_action *const_inner_action; + *stop_session_action = NULL, *notify_action = NULL, + *start_session_action = NULL; struct lttng_payload payload; lttng_payload_init(&payload); @@ -139,9 +139,8 @@ static void test_action_list(void) "Serialized and de-serialized list action are equal"); action_idx = 0; - for_each_action_const (const_inner_action, list_action) { - enum lttng_action_type inner_action_type = - lttng_action_get_type(const_inner_action); + for (auto action : lttng::ctl::const_action_list_view(list_action)) { + enum lttng_action_type inner_action_type = lttng_action_get_type(action); switch (action_idx) { case 0: ok(inner_action_type == LTTNG_ACTION_TYPE_START_SESSION, @@ -160,8 +159,8 @@ static void test_action_list(void) } action_idx = 0; - for_each_action_mutable (mut_inner_action, list_action) { - enum lttng_action_type inner_action_type = lttng_action_get_type(mut_inner_action); + for (auto action : lttng::ctl::action_list_view(list_action)) { + enum lttng_action_type inner_action_type = lttng_action_get_type(action); switch (action_idx) { case 0: ok(inner_action_type == LTTNG_ACTION_TYPE_START_SESSION, @@ -543,7 +542,7 @@ static void test_action_snapshot_session() lttng_payload_reset(&payload); } -int main() +static int _main() { plan_tests(NUM_TESTS); test_action_notify(); @@ -554,3 +553,13 @@ int main() test_action_snapshot_session(); return exit_status(); } + +int main() +{ + try { + return _main(); + } catch (const std::exception& e) { + ERR_FMT("Unhandled exception caught by action unit test: {}", e.what()); + abort(); + } +}