diff mbox

[v2] test: miscellaneous: Add CPP test

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

Commit Message

Mike Holmes Feb. 19, 2015, 10:32 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>
---
v2
Automatically enable cpp test if the compiler supports it

 configure.ac                            | 20 ++++++++++++++++++++
 test/Makefile.am                        |  2 +-
 test/Makefile.inc                       |  5 +++--
 test/miscellaneous/.gitignore           |  1 +
 test/miscellaneous/Makefile.am          | 12 ++++++++++++
 test/miscellaneous/gitignore            |  1 +
 test/miscellaneous/odp_api_from_cpp.cpp | 12 ++++++++++++
 7 files changed, 50 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. 24, 2015, 8:46 a.m. UTC | #1
On 02/20/2015 01:32 AM, Mike Holmes wrote:
> +if test "$GXX" = "yes"; then
> +test_cpp=yes
> +else
> +test_cpp=no
> +fi
> +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 ])
On my machine I have some old version g++ and new version of gcc. System 
finds g++ turns on tests but compilation
fails due to atomic not supported in old gcc 4.6.

I think that right check has to be: if GXX - turn on. But there has to 
be option to disable. Not to enable. (it's enabled by default.).

Maxim.
Mike Holmes Feb. 24, 2015, 1:44 p.m. UTC | #2
Ok, let me add a disable.

On 24 February 2015 at 03:46, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> On 02/20/2015 01:32 AM, Mike Holmes wrote:
>
>> +if test "$GXX" = "yes"; then
>> +test_cpp=yes
>> +else
>> +test_cpp=no
>> +fi
>> +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 ])
>>
> On my machine I have some old version g++ and new version of gcc. System
> finds g++ turns on tests but compilation
> fails due to atomic not supported in old gcc 4.6.
>
> I think that right check has to be: if GXX - turn on. But there has to be
> option to disable. Not to enable. (it's enabled by default.).
>
> Maxim.
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index e5c1c56..396ab16 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,22 @@  AC_ARG_ENABLE([test-perf],
 AM_CONDITIONAL([test_perf], [test x$test_perf = xyes ])
 
 ##########################################################################
+# Enable/disable test-cpp
+##########################################################################
+if test "$GXX" = "yes"; then
+test_cpp=yes
+else
+test_cpp=no
+fi
+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 +262,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 +303,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..134df38
--- /dev/null
+++ b/test/miscellaneous/.gitignore
@@ -0,0 +1 @@ 
+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;
+}