Fix: change method used by _rcu_dereference to strip type constness
[userspace-rcu.git] / tests / unit / test_build.c
index 4c3392d6779e884fe5f5e08d49b0060bef6ed778..f6b667ce2b3d9ab08dc64704337f9960d923ab68 100644 (file)
 
 #include "tap.h"
 
+struct my_tls_struct {
+       int int1;
+       char char1;
+       void *void1;
+};
+
+static DEFINE_URCU_TLS(int, my_tls_int);
+static DEFINE_URCU_TLS(struct my_tls_struct, my_tls_struct);
+
 static void test_lfstack(void)
 {
        struct cds_lfs_stack s;
 
        cds_lfs_init(&s);
-       if (!cds_lfs_empty(&s))
-               fail("cds_lfs_empty");
-       else
-               ok(1, "cds_lfs_empty");
+       ok(cds_lfs_empty(&s), "cds_lfs_empty");
 }
 
 static void test_wfstack(void)
@@ -75,10 +81,7 @@ static void test_wfstack(void)
        struct cds_wfs_stack s;
 
        cds_wfs_init(&s);
-       if (!cds_wfs_empty(&s))
-               fail("cds_lfs_empty");
-       else
-               ok(1, "cds_lfs_empty");
+       ok(cds_wfs_empty(&s), "cds_lfs_empty");
 }
 
 static void test_wfcqueue(void)
@@ -87,10 +90,7 @@ static void test_wfcqueue(void)
        struct cds_wfcq_tail tail;
 
        cds_wfcq_init(&head, &tail);
-       if (!cds_wfcq_empty(&head, &tail))
-               fail("cds_wfcq_empty");
-       else
-               ok(1, "cds_wfcq_empty");
+       ok(cds_wfcq_empty(&head, &tail), "cds_wfcq_empty");
 }
 
 static
@@ -106,16 +106,45 @@ void test_build_cds_list_head_init(void)
        };
 }
 
+static
+void test_urcu_tls(void)
+{
+       URCU_TLS(my_tls_int) = 1;
+       URCU_TLS(my_tls_struct).int1 = 1;
+       URCU_TLS(my_tls_struct).char1 = 'a';
+       URCU_TLS(my_tls_struct).void1 = NULL;
+}
+
+struct an_opaque_struct;
+struct a_clear_struct
+{
+       int x;
+};
+
+static
+void test_build_rcu_dereference(void)
+{
+       static struct an_opaque_struct *opaque = NULL;
+       static struct an_opaque_struct *const opaque_const = NULL;
+       static struct a_clear_struct *clear = NULL;
+       static struct a_clear_struct *const clear_const = NULL;
+
+       rcu_dereference(opaque);
+       rcu_dereference(opaque_const);
+       rcu_dereference(clear);
+       rcu_dereference(clear_const);
+}
+
 int main(void)
 {
-       /* Need at least 1 test to make a valid TAP test plan. */
        plan_tests(3);
-       ok(1, "dummy");
 
        test_lfstack();
        test_wfstack();
        test_wfcqueue();
        test_build_cds_list_head_init();
+       test_urcu_tls();
+       test_build_rcu_dereference();
 
        return exit_status();
 }
This page took 0.025347 seconds and 4 git commands to generate.