aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJere Leppänen <jere.leppanen@nokia.com>2022-09-20 17:01:30 +0300
committerMatias Elo <matias.elo@nokia.com>2022-10-19 13:29:08 +0300
commitb00b8c06310602cc34bdebf6f3eed978ea95864d (patch)
treeccc29419930cb70d6e6e847709841116e636c06c /test
parentb0aac4a0fcb21a7ddaa7a3540857878df6197ecb (diff)
test: misc: build and run a test application during installcheck
During installcheck, build and run a test application (odp_api_headers), to verify the install. When cross compiling, the application is built, but not run. Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com> Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com> Reviewed-by: Matias Elo <matias.elo@nokia.com>
Diffstat (limited to 'test')
-rw-r--r--test/miscellaneous/Makefile.am32
-rw-r--r--test/miscellaneous/odp_api_headers.c25
2 files changed, 57 insertions, 0 deletions
diff --git a/test/miscellaneous/Makefile.am b/test/miscellaneous/Makefile.am
index 2932457ff..9f9038f87 100644
--- a/test/miscellaneous/Makefile.am
+++ b/test/miscellaneous/Makefile.am
@@ -10,3 +10,35 @@ odp_api_from_cpp_SOURCES = odp_api_from_cpp.cpp
noinst_PROGRAMS = odp_api_headers
odp_api_headers_CFLAGS = $(AM_CFLAGS) -Wconversion
odp_api_headers_SOURCES = odp_api_headers.c
+
+PKGCONFIG = PKG_CONFIG_PATH=$(libdir)/pkgconfig:$$PKG_CONFIG_PATH pkg-config --cflags --libs
+
+if enable_shared
+
+PROGRAM_shared = odp_api_headers_shared
+
+installcheck-local: $(PROGRAM_shared)
+
+$(PROGRAM_shared): $(srcdir)/$(odp_api_headers_SOURCES)
+ $(CC) $(AM_CFLAGS) $(CFLAGS) $^ -o $@ \
+ `$(PKGCONFIG) libodphelper` `$(PKGCONFIG) lib$(ODP_LIB_NAME)`
+if ! cross_compile
+ LD_LIBRARY_PATH=$(libdir) ./$@
+endif
+endif
+
+if enable_static
+
+PROGRAM_static = odp_api_headers_static
+
+installcheck-local: $(PROGRAM_static)
+
+$(PROGRAM_static): $(srcdir)/$(odp_api_headers_SOURCES)
+ $(CC) $(AM_CFLAGS) $(CFLAGS) $^ -o $@ \
+ `$(PKGCONFIG) --static libodphelper` `$(PKGCONFIG) --static lib$(ODP_LIB_NAME)`
+if ! cross_compile
+ ./$@
+endif
+endif
+
+DISTCLEANFILES = $(PROGRAM_shared) $(PROGRAM_static)
diff --git a/test/miscellaneous/odp_api_headers.c b/test/miscellaneous/odp_api_headers.c
index f81a9c58b..843de2a02 100644
--- a/test/miscellaneous/odp_api_headers.c
+++ b/test/miscellaneous/odp_api_headers.c
@@ -10,5 +10,30 @@
int main(void)
{
+ odp_instance_t inst;
+
+ if (odp_init_global(&inst, NULL, NULL)) {
+ ODPH_ERR("Global init failed.\n");
+ return -1;
+ }
+
+ if (odp_init_local(inst, ODP_THREAD_CONTROL)) {
+ ODPH_ERR("Local init failed.\n");
+ return -1;
+ }
+
+ odp_sys_info_print();
+ printf("Helper library version: %s\n", odph_version_str());
+
+ if (odp_term_local()) {
+ ODPH_ERR("Local term failed.\n");
+ return -1;
+ }
+
+ if (odp_term_global(inst)) {
+ ODPH_ERR("Global term failed.\n");
+ return -1;
+ }
+
return 0;
}