+
+ status = lttng_event_field_value_unsigned_int_get_value(
+ event_field, &value);
+ if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
+ fail("lttng_event_field_value_unsigned_int_get_value returned an error: status = %d",
+ (int) status);
+ ret = 1;
+ goto end;
+ }
+
+ ok(value == expected_value,
+ "Expected unsigned integer value %u, got %" PRIu64,
+ expected_value, value);
+
+ ret = 0;
+end:
+ return ret;
+}
+
+/*
+ * Validate sequence for a string (seqfield1):
+ *
+ * Value: "test" encoded in UTF-8: [116, 101, 115, 116]
+ */
+static int validate_seqfield1(const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
+{
+ int ret;
+ enum lttng_event_field_value_status status;
+ unsigned int i, count;
+ const unsigned int expect[] = {116, 101, 115, 116};
+ const size_t array_count = sizeof(expect) / sizeof(*expect);
+
+ /* Unused. */
+ (void) iteration;
+
+ ret = validate_type(event_field, LTTNG_EVENT_FIELD_VALUE_TYPE_ARRAY);
+ if (ret) {
+ goto end;
+ }
+
+ status = lttng_event_field_value_array_get_length(event_field, &count);
+ if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
+ fail("lttng_event_field_value_array_get_length returned an error: status = %d",
+ (int) status);
+ ret = 1;
+ goto end;
+ }
+
+ ok(count == array_count, "Expected %zu array sub-elements, got %d",
+ array_count, count);
+ if (count != array_count) {
+ ret = 1;
+ goto end;
+ }
+
+ for (i = 0; i < count; i++) {
+ const struct lttng_event_field_value *value;
+
+ status = lttng_event_field_value_array_get_element_at_index(
+ event_field, i, &value);
+ if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
+ fail("lttng_event_field_value_array_get_element_at_index returned an error: status = %d",
+ (int) status);
+ ret = 1;
+ goto end;
+ }
+
+ ret = validate_unsigned_int_field(value, expect[i]);
+ if (ret) {
+ goto end;
+ }
+ }
+
+ ret = 0;
+end:
+ return ret;
+}
+
+static int validate_string(
+ const struct lttng_event_field_value *event_field,
+ const char *expect)
+{
+ int ret;
+ const char *value = NULL;
+ enum lttng_event_field_value_status status;
+
+ ret = validate_type(event_field, LTTNG_EVENT_FIELD_VALUE_TYPE_STRING);
+ if (ret) {
+ goto end;
+ }
+
+ status = lttng_event_field_value_string_get_value(event_field, &value);
+ if (!value) {
+ fail("lttng_event_field_value_array_get_length returned an error: status = %d",
+ (int) status);
+ ret = 1;
+ goto end;
+ }
+
+ ok(!strcmp(value, expect), "Expected string value \"%s\", got \"%s\"",
+ expect, value);
+
+ ret = 0;
+end:
+
+ return ret;
+}
+
+/*
+ * Validate string. Expected value is "test".
+ */
+static int validate_string_test(
+ const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
+{
+ const char * const expect = "test";
+
+ /* Unused. */
+ (void) iteration;
+
+ return validate_string(event_field, expect);
+}
+
+/*
+ * Validate escaped string. Expected value is "\*".
+ */
+static int validate_string_escaped(
+ const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
+{
+ const char * const expect = "\\*";
+
+ /* Unused. */
+ (void) iteration;
+
+ return validate_string(event_field, expect);
+}
+
+/*
+ * Validate real field.
+ */
+static int validate_real(
+ const struct lttng_event_field_value *event_field,
+ double expect)
+{
+ int ret;
+ double value;
+ enum lttng_event_field_value_status status;
+
+ ret = validate_type(event_field, LTTNG_EVENT_FIELD_VALUE_TYPE_REAL);
+ if (ret) {
+ goto end;
+ }
+
+ status = lttng_event_field_value_real_get_value(event_field, &value);
+ if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
+ fail("lttng_event_field_value_real_get_value returned an error: status = %d",
+ (int) status);
+ ret = 1;
+ goto end;
+ }
+
+ ok(value == expect, "Expected real value %f, got %f", expect, value);
+ ret = value != expect;
+end:
+ return ret;
+}
+
+/*
+ * Validate floatfield.
+ */
+static int validate_floatfield(
+ const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
+{
+ const double expect = 2222.0;
+
+ /* Unused. */
+ (void) iteration;
+
+ return validate_real(event_field, expect);
+}
+
+/*
+ * Validate doublefield.
+ */
+static int validate_doublefield(
+ const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
+{
+ const double expect = 2.0;
+
+ /* Unused. */
+ (void) iteration;
+
+ return validate_real(event_field, expect);
+}
+
+/*
+ * Validate enum0: enum0 = ( "AUTO: EXPECT 0" : container = 0 )
+ */
+static int validate_enum0(const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
+{
+ int ret;
+ enum lttng_event_field_value_status status;
+ uint64_t value;
+ const uint64_t expected_value = 0;
+
+ /* Unused. */
+ (void) iteration;
+
+ ret = validate_type(event_field,
+ LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM);
+ if (ret) {
+ goto end;
+ }
+
+ status = lttng_event_field_value_unsigned_int_get_value(
+ event_field, &value);
+ if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
+ fail("lttng_event_field_value_unsigned_int_get_value returned an error: status = %d",
+ (int) status);
+ ret = 1;
+ goto end;
+ }
+
+ ok(value == expected_value,
+ "Expected enum value %" PRIu64 ", got %" PRIu64,
+ expected_value, value);
+
+end:
+ return ret;
+}
+
+/*
+ * Validate enumnegative: enumnegative = ( "AUTO: EXPECT 0" : container = 0 )
+ *
+ * We expect 2 labels here.
+ */
+static int validate_enumnegative(
+ const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
+{
+ int ret;
+ enum lttng_event_field_value_status status;
+ int64_t value;
+ const int64_t expected_value = -1;
+
+ /* Unused. */
+ (void) iteration;
+
+ ret = validate_type(event_field,
+ LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM);
+ if (ret) {
+ goto end;
+ }
+
+ status = lttng_event_field_value_signed_int_get_value(
+ event_field, &value);
+ if (status != LTTNG_EVENT_FIELD_VALUE_STATUS_OK) {
+ fail("lttng_event_field_value_unsigned_int_get_value");
+ ret = 1;
+ goto end;
+ }
+
+ ok(value == expected_value,
+ "Expected enum value %" PRId64 ", got %" PRId64,
+ expected_value, value);
+
+end:
+ return ret;
+}
+
+static int validate_context_procname_ust(
+ const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
+{
+ /* Unused. */
+ (void) iteration;
+ return validate_string(event_field, "gen-ust-events");
+}
+
+static int validate_context_procname_kernel(
+ const struct lttng_event_field_value *event_field,
+ unsigned int iteration)
+{
+ /* Unused. */
+ (void) iteration;
+ return validate_string(event_field, "echo");
+}
+
+struct capture_base_field_tuple test_capture_base_fields[] = {
+ { "DOESNOTEXIST", FIELD_TYPE_PAYLOAD, false, false, NULL, NULL },
+ { "intfield", FIELD_TYPE_PAYLOAD, true, true, validate_unsigned_int_field, validate_unsigned_int_field },
+ { "longfield", FIELD_TYPE_PAYLOAD, true, true, validate_unsigned_int_field, validate_unsigned_int_field },
+ { "signedfield", FIELD_TYPE_PAYLOAD, true, true, validate_signed_int_field, validate_signed_int_field },
+ { "arrfield1", FIELD_TYPE_PAYLOAD, true, true, validate_array_unsigned_int_field, validate_array_unsigned_int_field },
+ { "arrfield2", FIELD_TYPE_PAYLOAD, true, true, validate_string_test, validate_string_test },
+ { "arrfield3", FIELD_TYPE_PAYLOAD, true, true, validate_array_unsigned_int_field, validate_array_unsigned_int_field },
+ { "seqfield1", FIELD_TYPE_PAYLOAD, true, true, validate_seqfield1, validate_seqfield1 },
+ { "seqfield2", FIELD_TYPE_PAYLOAD, true, true, validate_string_test, validate_string_test },
+ { "seqfield3", FIELD_TYPE_PAYLOAD, true, true, validate_array_unsigned_int_field, validate_array_unsigned_int_field },
+ { "seqfield4", FIELD_TYPE_PAYLOAD, true, true, validate_array_unsigned_int_field, validate_array_unsigned_int_field },
+ { "arrfield1[1]", FIELD_TYPE_ARRAY_FIELD, true, true, validate_array_unsigned_int_field_at_index, validate_array_unsigned_int_field_at_index },
+ { "stringfield", FIELD_TYPE_PAYLOAD, true, true, validate_string_test, validate_string_test },
+ { "stringfield2", FIELD_TYPE_PAYLOAD, true, true, validate_string_escaped, validate_string_escaped },
+ { "floatfield", FIELD_TYPE_PAYLOAD, true, false, validate_floatfield, validate_floatfield },
+ { "doublefield", FIELD_TYPE_PAYLOAD, true, false, validate_doublefield, validate_doublefield },
+ { "enum0", FIELD_TYPE_PAYLOAD, true, true, validate_enum0, validate_enum0 },
+ { "enumnegative", FIELD_TYPE_PAYLOAD, true, true, validate_enumnegative, validate_enumnegative },
+ { "$ctx.procname", FIELD_TYPE_CONTEXT, true, true, validate_context_procname_ust, validate_context_procname_kernel },
+};
+
+static const char *get_notification_trigger_name(
+ struct lttng_notification *notification)
+{
+ const char *trigger_name = NULL;
+ enum lttng_trigger_status trigger_status;
+ const struct lttng_trigger *trigger;
+
+ trigger = lttng_notification_get_trigger(notification);
+ if (!trigger) {
+ fail("Failed to get trigger from notification");
+ goto end;
+ }
+
+ trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
+ switch (trigger_status) {
+ case LTTNG_TRIGGER_STATUS_OK:
+ break;
+ case LTTNG_TRIGGER_STATUS_UNSET:
+ trigger_name = "(anonymous)";
+ break;