goto end;
}
- /* Check for duplicate clock classes */
+ /* Check for existing clock class */
prio_ptr = g_hash_table_lookup(cc_prio_map->prios, clock_class);
if (prio_ptr) {
+ *prio_ptr = priority;
prio_ptr = NULL;
- ret = -1;
- goto end;
+ goto set_highest_prio;
}
prio_ptr = g_new(uint64_t, 1);
g_ptr_array_add(cc_prio_map->entries, clock_class);
g_hash_table_insert(cc_prio_map->prios, clock_class, prio_ptr);
prio_ptr = NULL;
+
+set_highest_prio:
cc_prio = bt_ctf_clock_class_priority_map_current_highest_prio(
cc_prio_map);
assert(cc_prio.clock_class);
#include "tap/tap.h"
-#define NR_TESTS 18
+#define NR_TESTS 21
static void test_clock_class_priority_map(void)
{
"bt_clock_class_priority_map_get_clock_class_priority() returns the expected priority (3, copy)");
cc = bt_clock_class_priority_map_get_highest_priority_clock_class(cc_prio_map_copy);
ok(cc == cc3,
- "bt_clock_class_priority_map_get_highest_priority_clock_class() returns the expected clock class (3, copy)");
+ "bt_clock_class_priority_map_get_highest_priority_clock_class() returns the expected clock class (copy)");
+ BT_PUT(cc);
+ ret = bt_clock_class_priority_map_add_clock_class(cc_prio_map_copy, cc3, 253);
+ ok(ret == 0, "bt_clock_class_priority_map_add_clock_class() succeeds for an existing clock class");
+ ret = bt_clock_class_priority_map_get_clock_class_priority(cc_prio_map_copy, cc3, &prio);
+ assert(ret == 0);
+ ok(prio == 253,
+ "bt_clock_class_priority_map_get_clock_class_priority() returns the expected priority (updated, copy)");
+ cc = bt_clock_class_priority_map_get_highest_priority_clock_class(cc_prio_map_copy);
+ ok(cc == cc2,
+ "bt_clock_class_priority_map_get_highest_priority_clock_class() returns the expected clock class (updated, copy)");
BT_PUT(cc);
BT_PUT(cc3);