ir: add public bt_ctf_field_path object
[babeltrace.git] / tests / lib / test_bt_ctf_field_type_validation.c
index 2a173e7de90b17b54df87be19d1128fa8e68b84d..e114eae25dbb277168edfd163e74a0590c71cbe5 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 #include <babeltrace/ctf-ir/event-types.h>
-#include <babeltrace/ctf-ir/event-types-internal.h>
+#include <babeltrace/ctf-ir/field-path.h>
 #include <babeltrace/ctf-ir/event.h>
 #include <babeltrace/ctf-ir/stream-class.h>
 #include <babeltrace/ctf-ir/trace.h>
@@ -1645,20 +1645,16 @@ int validate_field_path(struct bt_ctf_field_type *field_type,
        int expected_index;
        int actual_index;
        int i = 0;
-       const struct bt_ctf_field_path *field_path;
+       struct bt_ctf_field_path *field_path = NULL;
        va_list ap;
 
        va_start(ap, root);
-
        if (bt_ctf_field_type_is_sequence(field_type)) {
-               field_path = ((struct bt_ctf_field_type_sequence *)
-                       field_type)->length_field_path;
+               field_path = bt_ctf_field_type_sequence_get_length_field_path(
+                               field_type);
        } else if (bt_ctf_field_type_is_variant(field_type)) {
-               field_path = ((struct bt_ctf_field_type_variant *)
-                       field_type)->tag_path;
-       } else {
-               ret = -1;
-               goto end;
+               field_path = bt_ctf_field_type_variant_get_tag_field_path(
+                               field_type);
        }
 
        if (!field_path) {
@@ -1666,12 +1662,12 @@ int validate_field_path(struct bt_ctf_field_type *field_type,
                goto end;
        }
 
-       if (field_path->root != root) {
+       if (bt_ctf_field_path_get_root(field_path) != root) {
                ret = -1;
                goto end;
        }
 
-       len = field_path->path_indexes->len;
+       len = bt_ctf_field_path_get_index_count(field_path);
 
        while (true) {
                expected_index = va_arg(ap, int);
@@ -1684,9 +1680,9 @@ int validate_field_path(struct bt_ctf_field_type *field_type,
                        break;
                }
 
-               actual_index = g_array_index(field_path->path_indexes, int, i);
+               actual_index = bt_ctf_field_path_get_index(field_path, i);
 
-               if (actual_index != expected_index) {
+               if (actual_index == INT_MIN) {
                        ret = -1;
                        goto end;
                }
@@ -1699,6 +1695,7 @@ int validate_field_path(struct bt_ctf_field_type *field_type,
        }
 
 end:
+       BT_PUT(field_path);
        va_end(ap);
 
        return ret;
This page took 0.023566 seconds and 4 git commands to generate.