Use bt_clock_class_priority_map_add_clock_class() to change a priority
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 26 Apr 2017 01:33:22 +0000 (21:33 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:41 +0000 (12:57 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/graph/clock-class-priority-map.c
tests/lib/test_cc_prio_map.c

index 2d4fac11937037dc6bda3e233b711f8d87b36d4b..7e6543b4701d0739904be17fdbf1ba890dfdcec3 100644 (file)
@@ -234,12 +234,12 @@ int bt_clock_class_priority_map_add_clock_class(
                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);
@@ -253,6 +253,8 @@ int bt_clock_class_priority_map_add_clock_class(
        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);
index 23305c2abff9e840a26d34a6a66808c8b6cc6dec..d2d128a88c88f1fe12815ba93405deba2e3a9925 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "tap/tap.h"
 
-#define NR_TESTS       18
+#define NR_TESTS       21
 
 static void test_clock_class_priority_map(void)
 {
@@ -100,7 +100,17 @@ 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);
This page took 0.026727 seconds and 4 git commands to generate.