Move test_action to its own file
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 9 Apr 2021 14:58:34 +0000 (10:58 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 17 Apr 2021 21:18:02 +0000 (17:18 -0400)
Further unit testing on action objects will be conducted in the
test_action.c file.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib17aed9eb02592d5c13bc2875d4203b81ab04cf3

.gitignore
tests/unit/Makefile.am
tests/unit/test_action.c [new file with mode: 0644]
tests/unit/test_notification.c

index 0fe7c47742827549e9070885ef6953788062a4e7..fb4c020621d0cdf18a271164c5752ef2907748ef 100644 (file)
@@ -92,6 +92,7 @@ compile_commands.json
 /tests/unit/test_payload
 /tests/unit/test_event_rule
 /tests/unit/test_condition
+/tests/unit/test_action
 /tests/unit/test_unix_socket
 /tests/regression/ust/multi-session/gen-nevents
 /tests/regression/ust/low-throughput/gen-events
index 5cf4d31ca37fa7fd1541bc75912c295a1377bc78..10dbd3a608d3b68ecab77e808725ecda1b786b26 100644 (file)
@@ -10,6 +10,7 @@ LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
 
 TESTS = \
        ini_config/test_ini_config \
+       test_action \
        test_buffer_view \
        test_directory_handle \
        test_event_expr_to_bytecode \
@@ -45,6 +46,7 @@ LIBLTTNG_CTL=$(top_builddir)/src/lib/lttng-ctl/liblttng-ctl.la
 
 # Define test programs
 noinst_PROGRAMS = \
+       test_action \
        test_buffer_view \
        test_condition \
        test_directory_handle \
@@ -268,3 +270,7 @@ test_event_expr_to_bytecode_LDADD = $(LIBTAP) $(LIBLTTNG_CTL) $(LIBCOMMON)
 # Log level rule api
 test_log_level_rule_SOURCES = test_log_level_rule.c
 test_log_level_rule_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBLTTNG_CTL) $(DL_LIBS)
+
+# Action api
+test_action_SOURCES = test_action.c
+test_action_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBLTTNG_CTL) $(DL_LIBS)
diff --git a/tests/unit/test_action.c b/tests/unit/test_action.c
new file mode 100644 (file)
index 0000000..697f1a7
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * test_action.c
+ *
+ * Unit tests for the notification API.
+ *
+ * Copyright (C) 2017 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#include <assert.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <tap/tap.h>
+
+#include <common/payload-view.h>
+#include <common/payload.h>
+#include <lttng/action/action-internal.h>
+#include <lttng/action/action.h>
+#include <lttng/action/firing-policy-internal.h>
+#include <lttng/action/firing-policy.h>
+#include <lttng/action/notify.h>
+
+/* For error.h */
+int lttng_opt_quiet = 1;
+int lttng_opt_verbose;
+int lttng_opt_mi;
+
+#define NUM_TESTS 2
+
+static void test_action_notify(void)
+{
+       struct lttng_action *notify_action = NULL;
+
+       notify_action = lttng_action_notify_create();
+       ok(notify_action, "Create notify action");
+       ok(lttng_action_get_type(notify_action) == LTTNG_ACTION_TYPE_NOTIFY,
+                       "Action has type LTTNG_ACTION_TYPE_NOTIFY");
+       lttng_action_destroy(notify_action);
+}
+
+int main(int argc, const char *argv[])
+{
+       plan_tests(NUM_TESTS);
+       test_action_notify();
+       return exit_status();
+}
index 5e50eaa4c7e831f754c6f6ceac12c442f2497657..6c57c21df1ea65de73d3641d7719167bb9f4a544 100644 (file)
@@ -30,7 +30,7 @@ int lttng_opt_quiet = 1;
 int lttng_opt_verbose;
 int lttng_opt_mi;
 
-#define NUM_TESTS 182
+#define NUM_TESTS 180
 
 static void test_condition_buffer_usage(
                struct lttng_condition *buffer_usage_condition)
@@ -277,16 +277,6 @@ static void test_condition_buffer_usage_high(void)
        lttng_condition_destroy(buffer_usage_high);
 }
 
-static void test_action(void)
-{
-       struct lttng_action *notify_action = NULL;
-
-       notify_action = lttng_action_notify_create();
-       ok(notify_action, "Create notify action");
-       ok(lttng_action_get_type(notify_action) == LTTNG_ACTION_TYPE_NOTIFY, "Action has type LTTNG_ACTION_TYPE_NOTIFY");
-       lttng_action_destroy(notify_action);
-}
-
 static void test_trigger(void)
 {
        struct lttng_action *notify_action = NULL;
@@ -317,7 +307,6 @@ int main(int argc, const char *argv[])
        plan_tests(NUM_TESTS);
        test_condition_buffer_usage_low();
        test_condition_buffer_usage_high();
-       test_action();
        test_trigger();
        return exit_status();
 }
This page took 0.027071 seconds and 4 git commands to generate.