Allow having C++ test cases for C backend
Support compiling and running either _runme.c or _runme.cxx files for the given test (but not both). Add a simple C++ test file to check that it actually works.
This commit is contained in:
parent
5219338160
commit
3765a08743
7 changed files with 35 additions and 12 deletions
|
|
@ -1375,9 +1375,14 @@ c_cpp: $(SRCDIR_SRCS)
|
|||
$(CXX) -c $(CCSHARED) -I$(SRCDIR) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_CXXSRCS) $(INCLUDES)
|
||||
$(CXX_LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(CLIBPREFIX)$(TARGET)$(C_SO)
|
||||
|
||||
c_compile: $(SRCDIR)$(RUNME).c
|
||||
c_compile_c: $(SRCDIR)$(RUNME).c
|
||||
$(COMPILETOOL) $(CC) $(CFLAGS) -o $(RUNME) -I. -I.. $< -L. -l$(TARGET)
|
||||
|
||||
c_compile_cxx: $(SRCDIR)$(RUNME).cxx
|
||||
$(COMPILETOOL) $(CXX) $(CXXFLAGS) -o $(RUNME) -I. -I.. $< -L. -l$(TARGET)
|
||||
|
||||
$(eval c_compile: c_compile_$(RUNME_EXT))
|
||||
|
||||
# This target is used for the unit tests: if we don't have any test code to
|
||||
# run, we at least can check that the generated header can be included without
|
||||
# giving any syntax errors.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ INTERFACE = example.i
|
|||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c_run
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' RUNME_EXT=c c_run
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ INTERFACE = example.i
|
|||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c_run
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' RUNME_EXT=c c_run
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ INTERFACE = example.i
|
|||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c_run
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' RUNME_EXT=c c_run
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ INTERFACE = example.i
|
|||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' c_run
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' RUNME_EXT=c c_run
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
LANGUAGE = c
|
||||
C = gcc
|
||||
CXX = g++
|
||||
SCRIPTSUFFIX = _runme.c
|
||||
RUNMESUFFIX = _runme
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = ../@top_srcdir@
|
||||
top_builddir = ../@top_builddir@
|
||||
|
|
@ -108,6 +108,11 @@ SWIGOPT += -w524 # Suppress SWIGWARN_LANG_EXPERIMENTAL warning
|
|||
|
||||
SRCDIR = ../$(srcdir)/
|
||||
|
||||
# Make function to check if we have an executable test for the given test base name.
|
||||
define has_runme
|
||||
-f $(srcdir)/$1$(RUNMESUFFIX).c -o -f $(srcdir)/$1$(RUNMESUFFIX).cxx
|
||||
endef
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
$(setup)
|
||||
|
|
@ -122,7 +127,7 @@ SRCDIR = ../$(srcdir)/
|
|||
%.multicpptest:
|
||||
$(setup)
|
||||
+(cd $* && $(swig_and_compile_multi_cpp))
|
||||
+if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
+if [ $(call has_runme,$*) ]; then \
|
||||
$(do_run_testcase); \
|
||||
else \
|
||||
cd $* && for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; do \
|
||||
|
|
@ -132,7 +137,7 @@ SRCDIR = ../$(srcdir)/
|
|||
|
||||
# Makes a directory for the testcase if it does not exist
|
||||
setup = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
if [ $(call has_runme,$*) ]; then \
|
||||
$(ECHO_PROGRESS) "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
|
||||
else \
|
||||
$(ECHO_PROGRESS) "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
|
||||
|
|
@ -153,14 +158,15 @@ syntax_check_testcase = \
|
|||
do_run_testcase = \
|
||||
cd $* && $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
SRCDIR='$(SRCDIR)' \
|
||||
RUNME=$*_runme \
|
||||
RUNME=$*$(RUNMESUFFIX) \
|
||||
RUNME_EXT=$(patsubst .%,%,$(suffix $(wildcard $(srcdir)/$*$(RUNMESUFFIX).c*))) \
|
||||
TARGET='$*' \
|
||||
c_run
|
||||
|
||||
# Only compile and run testcase if a file with _rume.c appended to the testcase
|
||||
# name is found, otherwise only check the syntax of the generated files.
|
||||
# Only compile and run testcase if we have a runme for it, otherwise only check
|
||||
# the syntax of the generated files.
|
||||
run_testcase = \
|
||||
+if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
+if [ $(call has_runme,$*) ]; then \
|
||||
$(do_run_testcase); \
|
||||
else \
|
||||
cd $* && $(call syntax_check_testcase,$*); \
|
||||
|
|
|
|||
12
Examples/test-suite/c/abstract_inherit_ok_runme.cxx
Normal file
12
Examples/test-suite/c/abstract_inherit_ok_runme.cxx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include "abstract_inherit_ok_wrap.h"
|
||||
#include <assert.h>
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
abstract_inherit_ok_Foo* const spam = (abstract_inherit_ok_Foo*)abstract_inherit_ok_Spam_new();
|
||||
|
||||
assert(abstract_inherit_ok_Foo_blah(spam) == 0);
|
||||
|
||||
abstract_inherit_ok_Foo_delete(spam);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue