/tests/unit/test
/tests/unit/test-cxx
/tests/unit/statedump
+/tests/unit/test-sc
+/tests/unit/test-sc-cxx
#automake
/include/config.h
src/Makefile
src/libside.pc
tests/Makefile
+ tests/static-checker/Makefile
tests/utils/Makefile
])
AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
-SUBDIRS = utils
+SUBDIRS = utils static-checker
-TEST_EXTENSIONS = .tap
-TAP_LOG_DRIVER_FLAGS = --merge --comments
-TAP_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' \
+LOG_DRIVER_FLAGS = --merge --comments
+LOG_DRIVER = env AM_TAP_AWK='$(AWK)' \
SIDE_TESTS_SRCDIR='$(abs_top_srcdir)/tests' \
SIDE_TESTS_BUILDDIR='$(abs_top_builddir)/tests' \
$(SHELL) $(srcdir)/utils/tap-driver.sh
regression/side-rcu-test \
unit/test \
unit/test-cxx \
+ unit/test-sc \
+ unit/test-sc-cxx \
unit/demo \
unit/statedump
$(top_builddir)/tests/utils/libtap.la \
$(RSEQ_LIBS)
+unit_test_sc_SOURCES = unit/test-sc.c
+unit_test_sc_LDADD = \
+ $(top_builddir)/src/libside.la \
+ $(top_builddir)/tests/utils/libtap.la \
+ $(RSEQ_LIBS)
+
+unit_test_sc_cxx_SOURCES = unit/test-sc-cxx.cpp
+unit_test_sc_cxx_LDADD = \
+ $(top_builddir)/src/libside.la \
+ $(top_builddir)/tests/utils/libtap.la \
+ $(RSEQ_LIBS)
+
unit_demo_SOURCES = unit/demo.c
unit_demo_LDADD = \
$(top_builddir)/src/libside.la \
$(RSEQ_LIBS)
# Currently no tap tests to run
-TESTS =
+TESTS = static-checker/run-tests
--- /dev/null
+dist_check_SCRIPTS = run-tests
--- /dev/null
+int main(void)
+{
+ side_arg_define_array(my_array, side_arg_list(side_arg_u32(1), side_arg_u64(2)));
+
+ return 0;
+}
--- /dev/null
+int main(void)
+{
+ side_arg_define_vla(my_vla, side_arg_list(side_arg_u32(1), side_arg_u64(2)));
+
+ return 0;
+}
--- /dev/null
+side_static_event(event, "provider", "event", SIDE_LOGLEVEL_DEBUG,
+ side_field_list(
+ side_field_u32("a"),
+ side_field_u32("a"),
+ )
+);
+
+int main() { return 0; }
--- /dev/null
+side_static_event(event, "provider", "event", SIDE_LOGLEVEL_DEBUG,
+ side_field_list(
+ side_field_u32(""),
+ )
+);
+
+int main() { return 0; }
--- /dev/null
+side_static_event(event, "provider", "event", SIDE_LOGLEVEL_ERR,
+ side_field_list(
+ side_field_optional_literal("foo", side_elem(side_type_u32())),
+ )
+);
+
+int main()
+{
+ if (side_event_enabled(event)) {
+ side_arg_define_optional(my_optional, side_arg_u64(1),
+ SIDE_OPTIONAL_ENABLED);
+ side_event_call(event,
+ side_arg_list(
+ side_arg_optional(my_optional),
+ )
+ );
+ }
+}
--- /dev/null
+#define SIDE_STATIC_CHECK_ENABLE
+#include <side/trace.h>
--- /dev/null
+#!/usr/bin/env bash
+
+CURDIR=$(dirname "$0")/
+TESTDIR=$CURDIR/..
+SRCDIR=$CURDIR/../..
+
+SH_TAP=1
+source "$TESTDIR/utils/utils.sh"
+
+command -v gcc > /dev/null
+
+HAVE_GCC=$(($? == 0))
+
+command -v clang > /dev/null
+
+HAVE_CLANG=$(($? == 0))
+
+function run_test() {
+ if [ $HAVE_GCC -eq 1 ]; then
+ cat prologue.c "$1" | gcc -I "$SRCDIR/include" -xc /dev/stdin -o /dev/null 2>&1 | grep --quiet -E "$2"
+ ok $? "gcc $1"
+ cat prologue.c "$1" | gcc -I "$SRCDIR/include" -xc++ /dev/stdin -o /dev/null 2>&1 | grep --quiet -E "$2"
+ ok $? "g++ $1"
+ else
+ skip 0 "gcc not present" 2
+ fi
+
+ if [ $HAVE_CLANG -eq 1 ]; then
+ cat prologue.c "$1" | clang -I "$SRCDIR/include" -xc /dev/stdin -o /dev/null 2>&1 | grep --quiet -E "$2"
+ ok $? "clang $1"
+ cat prologue.c "$1" | clang -I "$SRCDIR/include" -xc++ /dev/stdin -o /dev/null 2>&1 | grep --quiet -E "$2"
+ ok $? "clang++ $1"
+ else
+ skip 0 "clang not present" 2
+ fi
+}
+
+cd "${TESTDIR}/static-checker"
+
+TEST=6
+
+plan_tests $((4*TEST))
+
+run_test null-field.c "Null field name"
+run_test duplicated-fields.c "Duplicated field names"
+run_test argument-array-types-incompatible.c "Types incompatible"
+run_test argument-vla-types-incompatible.c "Types incompatible"
+run_test static-event-call-mismatch.c "error: conflicting types | error: invalid conversion | error: cannot initialize a variable of type"
+run_test optional-mismatch.c "error: conflicting types | error: invalid conversion | error: cannot initialize a variable of type"
--- /dev/null
+side_static_event(event, "provider", "event", SIDE_LOGLEVEL_DEBUG,
+ side_field_list(
+ side_field_u32("a"),
+ side_field_u32("b"),
+ )
+);
+
+int main(void)
+{
+ side_event(event, side_arg_list(side_arg_u32(1), side_arg_u64(2)));
+ return 0;
+}
--- /dev/null
+#define SIDE_STATIC_CHECK_ENABLE
+#include "test-cxx.cpp"
--- /dev/null
+#define SIDE_STATIC_CHECK_ENABLE
+#include "test.c"