Fix: sessiond: instance uuid is not sufficiently unique
[lttng-tools.git] / tests / unit / test_uuid.cpp
index 2355084a51748fefd2137bb67e5745ce38f8822b..6357c3adf24e88a51b5f8ea64c1b6dfa692dc6a3 100644 (file)
@@ -9,9 +9,9 @@
 #include <stdbool.h>
 #include <string.h>
 
-#include <tap/tap.h>
+#include "common/uuid.hpp"
 
-#include "common/uuid.h"
+#include <tap/tap.h>
 
 #define NR_TESTS 21
 
@@ -41,6 +41,11 @@ static const char invalid_str_4[] = "2d-6c6d756574-470e-9142-a4e6ad03f143";
 static const char invalid_str_5[] = "4542ad19-9e4f-4931-8261-2101c3e089ae7";
 static const char invalid_str_6[] = "XX0123";
 
+/* For error.hpp */
+int lttng_opt_quiet = 1;
+int lttng_opt_verbose = 0;
+int lttng_opt_mi;
+
 static
 void run_test_lttng_uuid_from_str(void)
 {
@@ -108,24 +113,27 @@ void run_test_lttng_uuid_is_equal(void)
        int ret;
        lttng_uuid uuid1, uuid2;
 
-       lttng_uuid_from_str(valid_str_1, uuid1);
-       lttng_uuid_from_str(valid_str_1, uuid2);
-       ret = lttng_uuid_is_equal(uuid1, uuid2);
+       ret = lttng_uuid_from_str(valid_str_1, uuid1);
+       assert(ret == 0);
+       ret = lttng_uuid_from_str(valid_str_1, uuid2);
+       assert(ret == 0);
+       ret = uuid1 == uuid2;
        ok(ret == true, "lttng_uuid_is_equal - Compare same UUID, expect success");
 
-       lttng_uuid_from_str(valid_str_2, uuid2);
-       ret = lttng_uuid_is_equal(uuid1, uuid2);
+       ret = lttng_uuid_from_str(valid_str_2, uuid2);
+       assert(ret == 0);
+       ret = uuid1 == uuid2;
        ok(ret == false, "lttng_uuid_is_equal - Compare different UUID, expect failure");
 }
 
 static
 void run_test_lttng_uuid_copy(void)
 {
-       int ret;
+       bool ret;
        lttng_uuid uuid1;
 
-       lttng_uuid_copy(uuid1, valid_uuid_1);
-       ret = lttng_uuid_is_equal(uuid1, valid_uuid_1);
+       uuid1 = valid_uuid_1;
+       ret = uuid1 == valid_uuid_1;
 
        ok(ret == true, "lttng_uuid_copy - Compare copied UUID with source, expect success");
 }
@@ -139,7 +147,7 @@ void run_test_lttng_uuid_generate(void)
        lttng_uuid_generate(uuid1);
        lttng_uuid_generate(uuid2);
 
-       ok(lttng_uuid_is_equal(uuid1, uuid2) == false, "lttng_uuid_generate - Generated UUIDs are different");
+       ok(uuid1 != uuid2, "lttng_uuid_generate - Generated UUIDs are different");
 
        /*
         * Set the two most significant bits (bits 6 and 7) of the
This page took 0.024088 seconds and 4 git commands to generate.