Clean-up: consumer.hpp: coding style indentation fix
[lttng-tools.git] / tests / unit / test_action.cpp
index 131a3af1d6aef3ef219e3183e3fdae0060b6522d..52f6d26ca66a70799db00cd135d90478d9b3a52a 100644 (file)
@@ -9,6 +9,7 @@
  *
  */
 
+#include <common/error.hpp>
 #include <common/payload-view.hpp>
 #include <common/payload.hpp>
 
@@ -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();
+       }
+}
This page took 0.024675 seconds and 4 git commands to generate.