+ struct lttng_log_level_rule *log_level_rule = nullptr;
+ const struct lttng_log_level_rule *log_level_rule_return = nullptr;
+ struct lttng_payload payload;
+
+ diag("Testing lttng_event_rule_user_log4j2_logging.");
+
+ lttng_payload_init(&payload);
+
+ log_level_rule = lttng_log_level_rule_exactly_create(LTTNG_LOGLEVEL_INFO);
+ LTTNG_ASSERT(log_level_rule);
+
+ log4j2_logging = lttng_event_rule_log4j2_logging_create();
+ ok(log4j2_logging, "log4j2_logging object.");
+
+ status = lttng_event_rule_log4j2_logging_set_name_pattern(log4j2_logging, pattern);
+ ok(status == LTTNG_EVENT_RULE_STATUS_OK, "setting pattern.");
+ status = lttng_event_rule_log4j2_logging_get_name_pattern(log4j2_logging, &tmp);
+ ok(status == LTTNG_EVENT_RULE_STATUS_OK, "getting pattern.");
+ ok(!strncmp(pattern, tmp, strlen(pattern)), "pattern is equal.");
+
+ status = lttng_event_rule_log4j2_logging_set_filter(log4j2_logging, filter);
+ ok(status == LTTNG_EVENT_RULE_STATUS_OK, "setting filter.");
+ status = lttng_event_rule_log4j2_logging_get_filter(log4j2_logging, &tmp);
+ ok(status == LTTNG_EVENT_RULE_STATUS_OK, "getting filter.");
+ ok(!strncmp(filter, tmp, strlen(filter)), "filter is equal.");
+
+ status = lttng_event_rule_log4j2_logging_get_log_level_rule(log4j2_logging,
+ &log_level_rule_return);
+ ok(status == LTTNG_EVENT_RULE_STATUS_UNSET, "get unset log level rule.");
+
+ status = lttng_event_rule_log4j2_logging_set_log_level_rule(log4j2_logging, log_level_rule);
+ ok(status == LTTNG_EVENT_RULE_STATUS_OK, "setting log level rule.");
+ status = lttng_event_rule_log4j2_logging_get_log_level_rule(log4j2_logging,
+ &log_level_rule_return);
+ ok(status == LTTNG_EVENT_RULE_STATUS_OK, "get log level rule.");
+
+ ok(lttng_event_rule_serialize(log4j2_logging, &payload) == 0, "Serializing.");
+
+ {
+ struct lttng_payload_view view = lttng_payload_view_from_payload(&payload, 0, -1);
+
+ ok(lttng_event_rule_create_from_payload(&view, &log4j2_logging_from_buffer) > 0,
+ "Deserializing.");
+ }
+
+ ok(lttng_event_rule_is_equal(log4j2_logging, log4j2_logging_from_buffer),
+ "serialized and from buffer are equal.");
+
+ lttng_payload_reset(&payload);
+ lttng_event_rule_destroy(log4j2_logging);
+ lttng_event_rule_destroy(log4j2_logging_from_buffer);
+ lttng_log_level_rule_destroy(log_level_rule);
+}
+
+static void test_event_rule_python_logging()
+{
+ struct lttng_event_rule *python_logging = nullptr;
+ struct lttng_event_rule *python_logging_from_buffer = nullptr;
+ enum lttng_event_rule_status status;
+ const char *pattern = "my_event_*";
+ const char *filter = "msg_id == 23 && size >= 2048";
+ const char *tmp;
+ struct lttng_log_level_rule *log_level_rule = nullptr;
+ const struct lttng_log_level_rule *log_level_rule_return = nullptr;