diff mbox

test: miscellaneous: Add CPP test

Message ID 1424284572-11367-1-git-send-email-mike.holmes@linaro.org
State New
Headers show

Commit Message

Mike Holmes Feb. 18, 2015, 6:36 p.m. UTC
From: Simon Kagstrom <simon.kagstrom@netinsight.net>

Add conditional test to link and run ODP from a cpp application.

Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 configure.ac                            | 16 ++++++++++++++++
 test/Makefile.am                        |  2 +-
 test/Makefile.inc                       |  5 +++--
 test/miscellaneous/.gitignore           |  2 ++
 test/miscellaneous/Makefile.am          | 12 ++++++++++++
 test/miscellaneous/gitignore            |  1 +
 test/miscellaneous/odp_api_from_cpp.cpp | 12 ++++++++++++
 7 files changed, 47 insertions(+), 3 deletions(-)
 create mode 100644 test/miscellaneous/.gitignore
 create mode 100644 test/miscellaneous/Makefile.am
 create mode 100644 test/miscellaneous/gitignore
 create mode 100644 test/miscellaneous/odp_api_from_cpp.cpp

Comments

Maxim Uvarov Feb. 19, 2015, 8:46 a.m. UTC | #1
On 02/18/2015 09:36 PM, Mike Holmes wrote:
> +test_cpp=no
> +AC_ARG_ENABLE([test-cpp],
> +    [  --enable-test-cpp       run basic test aginast cpp],
> +    [if test "x$enableval" = "xyes"; then
> +        test_cpp=yes
> +    fi])
> +
> +AM_CONDITIONAL([test_cpp], [test x$test_cpp = xyes ])
I think that by default test should be enabled.

Maxim.
Mike Holmes Feb. 19, 2015, 6:44 p.m. UTC | #2
On 19 February 2015 at 03:46, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> On 02/18/2015 09:36 PM, Mike Holmes wrote:
>
>> +test_cpp=no
>> +AC_ARG_ENABLE([test-cpp],
>> +    [  --enable-test-cpp       run basic test aginast cpp],
>> +    [if test "x$enableval" = "xyes"; then
>> +        test_cpp=yes
>> +    fi])
>> +
>> +AM_CONDITIONAL([test_cpp], [test x$test_cpp = xyes ])
>>
> I think that by default test should be enabled.
>
> Maxim.
>

I added a check against GXX = yes to default the test to on - but see reply
to Simon


>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Mike Holmes Feb. 19, 2015, 6:48 p.m. UTC | #3
On 19 February 2015 at 03:53, Simon Kågström <simon.kagstrom@netinsight.net>
wrote:

> On 2015-02-18 19:36, Mike Holmes wrote:
>
> > +++ b/test/miscellaneous/odp_api_from_cpp.cpp
> > @@ -0,0 +1,12 @@
> > +#include <cstdio>
> > +#include <odp.h>
> > +#include <odp/helper/linux.h>
> > +
>
> #include <odp/helper/eth.h>
>
> triggers some more errors, so it would be good to include. Probably
> other headers should be included as well, but these are the ones I've
> tested.
>


If I include the other helper headers at this point, the build breaks, we
need to fix them before we enable this C++ check support for the helpers I
think.

Patches to fix the helpers and add the check for them welcome as a follow
on to this one.


> // Simon
>
>
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index e5c1c56..68841b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,6 +13,8 @@  AM_SILENT_RULES([yes])
 AC_PROG_CC
 AM_PROG_CC_C_O
 
+AC_PROG_CXX
+
 AC_PROG_INSTALL
 AC_PROG_MAKE_SET
 
@@ -114,6 +116,18 @@  AC_ARG_ENABLE([test-perf],
 AM_CONDITIONAL([test_perf], [test x$test_perf = xyes ])
 
 ##########################################################################
+# Enable/disable test-cpp
+##########################################################################
+test_cpp=no
+AC_ARG_ENABLE([test-cpp],
+    [  --enable-test-cpp       run basic test aginast cpp],
+    [if test "x$enableval" = "xyes"; then
+        test_cpp=yes
+    fi])
+
+AM_CONDITIONAL([test_cpp], [test x$test_cpp = xyes ])
+
+##########################################################################
 # Set optional CUnit path
 ##########################################################################
 AC_ARG_WITH([cunit-path],
@@ -244,6 +258,7 @@  AC_CONFIG_FILES([Makefile
 		 test/api_test/Makefile
 		 test/performance/Makefile
 		 test/validation/Makefile
+		 test/miscellaneous/Makefile
 		 ])
 
 AC_SEARCH_LIBS([timer_create],[rt posix4])
@@ -284,4 +299,5 @@  AC_MSG_RESULT([
 	cunit:			${cunit_support}
 	test_vald:		${test_vald}
 	test_perf:		${test_perf}
+	test_cpp:		${test_cpp}
 ])
diff --git a/test/Makefile.am b/test/Makefile.am
index ec2b248..2ba8008 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,4 +1,4 @@ 
-SUBDIRS = api_test performance
+SUBDIRS = api_test performance miscellaneous
 
 if cunit_support
     SUBDIRS += validation
diff --git a/test/Makefile.inc b/test/Makefile.inc
index ebee80a..93ead25 100644
--- a/test/Makefile.inc
+++ b/test/Makefile.inc
@@ -2,12 +2,13 @@  include $(top_srcdir)/Makefile.inc
 include $(top_srcdir)/platform/@with_platform@/Makefile.inc
 LIB   = $(top_builddir)/lib
 LDADD = $(LIB)/libodp.la
-AM_CFLAGS += \
-	-I$(srcdir) \
+INCFLAGS = -I$(srcdir) \
 	-I$(top_srcdir)/test \
 	-I$(top_srcdir)/platform/@with_platform@/include \
 	-I$(top_srcdir)/platform/linux-generic/include \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/helper/include
+AM_CFLAGS += $(INCFLAGS)
+AM_CXXFLAGS = $(INCFLAGS)
 
 AM_LDFLAGS += -L$(LIB)
diff --git a/test/miscellaneous/.gitignore b/test/miscellaneous/.gitignore
new file mode 100644
index 0000000..328331d
--- /dev/null
+++ b/test/miscellaneous/.gitignore
@@ -0,0 +1,2 @@ 
+odp_api_from_cpp
+
diff --git a/test/miscellaneous/Makefile.am b/test/miscellaneous/Makefile.am
new file mode 100644
index 0000000..110b63c
--- /dev/null
+++ b/test/miscellaneous/Makefile.am
@@ -0,0 +1,12 @@ 
+include $(top_srcdir)/test/Makefile.inc
+
+if test_cpp
+bin_PROGRAMS =  odp_api_from_cpp
+TESTS = odp_api_from_cpp
+endif
+
+odp_api_from_cpp_CFLAGS = $(AM_CFLAGS)
+
+odp_api_from_cpp_LDFLAGS = $(AM_LDFLAGS) -static
+
+dist_odp_api_from_cpp_SOURCES = odp_api_from_cpp.cpp
diff --git a/test/miscellaneous/gitignore b/test/miscellaneous/gitignore
new file mode 100644
index 0000000..134df38
--- /dev/null
+++ b/test/miscellaneous/gitignore
@@ -0,0 +1 @@ 
+odp_api_from_cpp
diff --git a/test/miscellaneous/odp_api_from_cpp.cpp b/test/miscellaneous/odp_api_from_cpp.cpp
new file mode 100644
index 0000000..e62ef8d
--- /dev/null
+++ b/test/miscellaneous/odp_api_from_cpp.cpp
@@ -0,0 +1,12 @@ 
+#include <cstdio>
+#include <odp.h>
+#include <odp/helper/linux.h>
+
+int main(int argc, const char *argv[])
+{
+
+	printf("\tODP API version: %s\n", odp_version_api_str());
+	printf("\tODP implementation version: %s\n", odp_version_impl_str());
+
+	return 0;
+}