test multiflavor single compile unit
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 30 Nov 2018 19:20:33 +0000 (14:20 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 12 Dec 2018 15:18:49 +0000 (10:18 -0500)
Test multiple liburcu flavors within a compile unit.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
.gitignore
tests/unit/Makefile.am
tests/unit/test_urcu_multiflavor_single_unit.c [new file with mode: 0644]

index 4daa824..e54aefd 100644 (file)
@@ -7,6 +7,8 @@ tests/unit/urcu-asm.S
 tests/unit/test_uatomic
 tests/unit/test_urcu_multiflavor
 tests/unit/test_urcu_multiflavor_dynlink
+tests/unit/test_urcu_multiflavor_single_unit
+tests/unit/test_urcu_multiflavor_single_unit_dynlink
 
 tests/utils/libtap.a
 
index ade3555..1cc9da3 100644 (file)
@@ -6,7 +6,9 @@ LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
 
 noinst_PROGRAMS = test_uatomic \
        test_urcu_multiflavor \
-       test_urcu_multiflavor_dynlink
+       test_urcu_multiflavor_dynlink \
+       test_urcu_multiflavor_single_unit \
+       test_urcu_multiflavor_single_unit_dynlink
 
 TESTS = $(noinst_PROGRAMS)
 
@@ -43,6 +45,15 @@ test_urcu_multiflavor_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS)
 test_urcu_multiflavor_dynlink_LDADD = $(URCU_LIB) $(URCU_MB_LIB) \
        $(URCU_SIGNAL_LIB) $(URCU_QSBR_LIB) $(URCU_BP_LIB) $(TAP_LIB)
 
+test_urcu_multiflavor_single_unit_SOURCES = test_urcu_multiflavor_single_unit.c
+test_urcu_multiflavor_single_unit_LDADD = $(URCU_LIB) $(URCU_MB_LIB) \
+       $(URCU_SIGNAL_LIB) $(URCU_QSBR_LIB) $(URCU_BP_LIB) $(TAP_LIB)
+
+test_urcu_multiflavor_single_unit_dynlink_SOURCES = test_urcu_multiflavor_single_unit.c
+test_urcu_multiflavor_single_unit_dynlink_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS)
+test_urcu_multiflavor_single_unit_dynlink_LDADD = $(URCU_LIB) $(URCU_MB_LIB) \
+       $(URCU_SIGNAL_LIB) $(URCU_QSBR_LIB) $(URCU_BP_LIB) $(TAP_LIB)
+
 all-local:
        @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
                for script in $(SCRIPT_LIST); do \
diff --git a/tests/unit/test_urcu_multiflavor_single_unit.c b/tests/unit/test_urcu_multiflavor_single_unit.c
new file mode 100644 (file)
index 0000000..909d4d2
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * test_urcu_multiflavor.c
+ *
+ * Userspace RCU library - test multiple RCU flavors into one program
+ *
+ * Copyright February 2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef DYNAMIC_LINK_TEST
+#define _LGPL_SOURCE
+#endif
+
+#include <urcu/urcu-mb.h>
+#include <urcu/urcu-bp.h>
+#include <urcu/urcu-memb.h>
+#include <urcu/urcu-signal.h>
+#include <urcu/urcu-qsbr.h>
+
+#include <stdlib.h>
+#include "tap.h"
+
+static int test_mf_mb(void)
+{
+       urcu_mb_register_thread();
+       urcu_mb_read_lock();
+       urcu_mb_read_unlock();
+       urcu_mb_synchronize_rcu();
+       urcu_mb_unregister_thread();
+       return 0;
+}
+
+static int test_mf_bp(void)
+{
+       urcu_bp_register_thread();
+       urcu_bp_read_lock();
+       urcu_bp_read_unlock();
+       urcu_bp_synchronize_rcu();
+       urcu_bp_unregister_thread();
+       return 0;
+}
+
+static int test_mf_memb(void)
+{
+       urcu_memb_register_thread();
+       urcu_memb_read_lock();
+       urcu_memb_read_unlock();
+       urcu_memb_synchronize_rcu();
+       urcu_memb_unregister_thread();
+       return 0;
+}
+
+static int test_mf_signal(void)
+{
+       urcu_signal_register_thread();
+       urcu_signal_read_lock();
+       urcu_signal_read_unlock();
+       urcu_signal_synchronize_rcu();
+       urcu_signal_unregister_thread();
+       return 0;
+}
+
+static int test_mf_qsbr(void)
+{
+       urcu_qsbr_register_thread();
+       urcu_qsbr_read_lock();
+       urcu_qsbr_read_unlock();
+       urcu_qsbr_synchronize_rcu();
+       urcu_qsbr_unregister_thread();
+       return 0;
+}
+
+int main(int argc, char **argv)
+{
+       plan_tests(5);
+
+       ok1(!test_mf_mb());
+       ok1(!test_mf_bp());
+       ok1(!test_mf_memb());
+       ok1(!test_mf_signal());
+       ok1(!test_mf_qsbr());
+
+       return exit_status();
+}
This page took 0.045788 seconds and 4 git commands to generate.