From bbc9abdcfe7d034965894d6cffc94c74478e4f59 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Fri, 7 May 2021 12:05:38 -0400 Subject: [PATCH] tests: Add a simple compile test for caa_get_cycles Change-Id: Id2dbaf5f250a5e6e135700dabed5832e75ca7ce9 Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- .gitignore | 1 + tests/unit/Makefile.am | 7 +++++- tests/unit/test_arch.c | 52 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/unit/test_arch.c diff --git a/.gitignore b/.gitignore index be01a12..eeb5465 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ tests/api.h tests/unit/urcu-asm.S +tests/unit/test_arch tests/unit/test_uatomic tests/unit/test_urcu_multiflavor tests/unit/test_urcu_multiflavor_dynlink diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index f3ab670..ef73127 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -4,7 +4,9 @@ LOG_DRIVER_FLAGS = --merge --comments LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \ $(top_srcdir)/tests/utils/tap-driver.sh -noinst_PROGRAMS = test_uatomic \ +noinst_PROGRAMS = \ + test_arch \ + test_uatomic \ test_urcu_multiflavor \ test_urcu_multiflavor_dynlink \ test_urcu_multiflavor_single_unit \ @@ -23,6 +25,9 @@ URCU_BP_LIB=$(top_builddir)/src/liburcu-bp.la URCU_CDS_LIB=$(top_builddir)/src/liburcu-cds.la TAP_LIB=$(top_builddir)/tests/utils/libtap.a +test_arch_SOURCES = test_arch.c +test_arch_LDADD = $(URCU_COMMON_LIB) $(TAP_LIB) + test_uatomic_SOURCES = test_uatomic.c test_uatomic_LDADD = $(URCU_COMMON_LIB) $(TAP_LIB) diff --git a/tests/unit/test_arch.c b/tests/unit/test_arch.c new file mode 100644 index 0000000..fb447d6 --- /dev/null +++ b/tests/unit/test_arch.c @@ -0,0 +1,52 @@ +/* + * test_arch.c + * + * Userspace RCU library - test arch headers + * + * Copyright February 2021 Michael Jeanson + * + * 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. + */ + +#include +#include + +#include "tap.h" + +#define NR_TESTS 1 + + +/* + * This is only to make sure the static inline caa_get_cycles() in the public + * headers builds properly. + */ +static +void test_caa_get_cycles(void) { + caa_cycles_t cycles = 0; + + + cycles = caa_get_cycles(); + + ok(cycles != 0, "caa_get_cycles works"); +} + +int main(void) +{ + plan_tests(NR_TESTS); + + test_caa_get_cycles(); + + return exit_status(); +} -- 2.34.1