Message ID | 1478517324-11324-6-git-send-email-christophe.milard@linaro.org |
---|---|
State | New |
Headers | show |
On 11/07/16 14:15, Christophe Milard wrote: > Trying to fix a proper structure for driver tests in the hard world > of autotools: > Staticaly linked drivers fails with autotools as the linker would need the > "--whole-archive" option which autotools cannot handle. > Trying to used ltdl lib does not seem to help the nedd for rpath otpion > (which is surprising). > So this patch just point at the .so path usiong rpath. > > Signed-off-by: Christophe Milard <christophe.milard@linaro.org> > --- > test/.gitignore | 1 + > test/Makefile.inc | 3 +- > test/common_plat/m4/configure.m4 | 1 + > test/common_plat/validation/Makefile.inc | 1 - > test/common_plat/validation/drv/Makefile.am | 1 + > test/common_plat/validation/drv/drvinit/.gitignore | 1 + > .../common_plat/validation/drv/drvinit/Makefile.am | 25 ++++++++++ > test/common_plat/validation/drv/drvinit/drvinit.c | 58 ++++++++++++++++++++++ > test/common_plat/validation/drv/drvinit/drvinit.h | 24 +++++++++ > .../validation/drv/drvinit/drvinit_main.c | 12 +++++ > .../validation/drv/drvinit/empty_driver.c | 12 +++++ > test/linux-generic/Makefile.am | 1 + > test/m4/configure.m4 | 3 ++ > test/test_config.h.in | 13 +++++ > 14 files changed, 154 insertions(+), 2 deletions(-) > create mode 100644 test/.gitignore > create mode 100644 test/common_plat/validation/drv/drvinit/.gitignore > create mode 100644 test/common_plat/validation/drv/drvinit/Makefile.am > create mode 100644 test/common_plat/validation/drv/drvinit/drvinit.c > create mode 100644 test/common_plat/validation/drv/drvinit/drvinit.h > create mode 100644 test/common_plat/validation/drv/drvinit/drvinit_main.c > create mode 100644 test/common_plat/validation/drv/drvinit/empty_driver.c > create mode 100644 test/test_config.h.in > > diff --git a/test/.gitignore b/test/.gitignore > new file mode 100644 > index 0000000..4be1df5 > --- /dev/null > +++ b/test/.gitignore > @@ -0,0 +1 @@ > +test_config.h > diff --git a/test/Makefile.inc b/test/Makefile.inc > index 1ebc047..923ca21 100644 > --- a/test/Makefile.inc > +++ b/test/Makefile.inc > @@ -12,7 +12,8 @@ INCFLAGS = \ > -I$(top_srcdir)/include \ > -I$(top_srcdir)/platform/@with_platform@/include \ > -I$(top_srcdir)/test \ > - -I$(top_builddir)/include > + -I$(top_builddir)/include \ > + -I$(top_builddir)/test > > AM_CFLAGS += $(INCFLAGS) > AM_CXXFLAGS = $(INCFLAGS) > diff --git a/test/common_plat/m4/configure.m4 b/test/common_plat/m4/configure.m4 > index 1fc350d..32ac8c4 100644 > --- a/test/common_plat/m4/configure.m4 > +++ b/test/common_plat/m4/configure.m4 > @@ -33,4 +33,5 @@ AC_CONFIG_FILES([test/common_plat/Makefile > test/common_plat/validation/api/traffic_mngr/Makefile > test/common_plat/validation/drv/Makefile > test/common_plat/validation/drv/drvatomic/Makefile > + test/common_plat/validation/drv/drvinit/Makefile > test/common_plat/validation/drv/drvshmem/Makefile]) > diff --git a/test/common_plat/validation/Makefile.inc b/test/common_plat/validation/Makefile.inc > index ffba620..36c9899 100644 > --- a/test/common_plat/validation/Makefile.inc > +++ b/test/common_plat/validation/Makefile.inc > @@ -8,7 +8,6 @@ COMMON_DIR = $(top_builddir)/test/common_plat/common > AUTOMAKE_OPTIONS = nostdinc > > AM_CFLAGS += -I$(top_srcdir)/test/common_plat/common > -AM_LDFLAGS += -static > > LIBCUNIT_COMMON = $(COMMON_DIR)/libcunit_common.la > LIBCPUMASK_COMMON = $(COMMON_DIR)/libcpumask_common.la > diff --git a/test/common_plat/validation/drv/Makefile.am b/test/common_plat/validation/drv/Makefile.am > index bcdb92e..1574f3d 100644 > --- a/test/common_plat/validation/drv/Makefile.am > +++ b/test/common_plat/validation/drv/Makefile.am > @@ -1,4 +1,5 @@ > ODPDRV_MODULES = drvatomic \ > + drvinit \ > drvshmem > > SUBDIRS = $(ODPDRV_MODULES) > diff --git a/test/common_plat/validation/drv/drvinit/.gitignore b/test/common_plat/validation/drv/drvinit/.gitignore > new file mode 100644 > index 0000000..d630ef5 > --- /dev/null > +++ b/test/common_plat/validation/drv/drvinit/.gitignore > @@ -0,0 +1 @@ > +drvinit_main > diff --git a/test/common_plat/validation/drv/drvinit/Makefile.am b/test/common_plat/validation/drv/drvinit/Makefile.am > new file mode 100644 > index 0000000..8ccf2aa > --- /dev/null > +++ b/test/common_plat/validation/drv/drvinit/Makefile.am > @@ -0,0 +1,25 @@ > +include ../Makefile.inc > +include $(top_srcdir)/platform/@with_platform@/Makefile.inc > + > +ABS_TEST_BUILDDIR = $(abs_top_builddir)/test/common_plat/validation/drv/drvinit > + > +noinst_LTLIBRARIES = libtestdrvinit.la > +libtestdrvinit_la_SOURCES = drvinit.c > + > +# the minimalist driver: > +lib_LTLIBRARIES = empty_driver.la > +empty_driver_la_SOURCES = empty_driver.c > +empty_driver_la_LDFLAGS = $(AM_LDFLAGS) -module -shared -export-dynamic \ > + -avoid-version > + > +# the program trying to load the driver: > +# autotools ack: poking straight into .libs to find the ".so" file... > +# and hardcoding rpath... > +test_PROGRAMS = drvinit_main$(EXEEXT) > +drvinit_main_SOURCES = drvinit_main.c > +drvinit_main_LDADD = libtestdrvinit.la $(LIBCUNIT_COMMON) $(LIBODP) > +drvinit_main_LDFLAGS = $(AM_LDFLAGS) \ > + -rpath $(ABS_TEST_BUILDDIR)/.libs \ > + -rpath $(libdir) > + > +EXTRA_DIST = drvinit.h > diff --git a/test/common_plat/validation/drv/drvinit/drvinit.c b/test/common_plat/validation/drv/drvinit/drvinit.c > new file mode 100644 > index 0000000..e79d68a > --- /dev/null > +++ b/test/common_plat/validation/drv/drvinit/drvinit.c > @@ -0,0 +1,58 @@ > +/* Copyright (c) 2016, Linaro Limited > + * All rights reserved. > + * > + * SPDX-License-Identifier: BSD-3-Clause > + */ > + > +#include <test_config.h> > +#include <odp_drv.h> > +#include <odp_api.h> > +#include <odp_cunit_common.h> > +#include "drvinit.h" > +#include <stdlib.h> > + > +#define TEST_SKIPPED 77 > + > +/* > + * basic tests > + */ > +void drvinit_test_load(void) > +{ > +#if HAVE_DLFCN_H > + CU_ASSERT(odp_load_driver("empty_driver.so") == 0); > +#endif > +} > + > +odp_testinfo_t drvinit_suite[] = { > + ODP_TEST_INFO(drvinit_test_load), > + ODP_TEST_INFO_NULL, > +}; > + > +odp_suiteinfo_t drvinit_suites[] = { > + {"Driver load", NULL, NULL, drvinit_suite}, > + ODP_SUITE_INFO_NULL, > +}; > + > +int drvinit_main(int argc, char *argv[]) > +{ > + int ret; > + > + /* > + * none of the following can be performed if we don't have > + * some kind of dynamic loading (currentely: dlopen) > + */ > +#if !HAVE_DLFCN_H > + return TEST_SKIPPED; > +#endif > + > + /* parse common options: */ > + if (odp_cunit_parse_options(argc, argv)) > + return -1; > + > + ret = odp_cunit_register(drvinit_suites); > + > + if (ret == 0) > + ret = odp_cunit_run(); > + > + return ret; > +} > diff --git a/test/common_plat/validation/drv/drvinit/drvinit.h b/test/common_plat/validation/drv/drvinit/drvinit.h > new file mode 100644 > index 0000000..1c9f9a6 > --- /dev/null > +++ b/test/common_plat/validation/drv/drvinit/drvinit.h > @@ -0,0 +1,24 @@ > +/* Copyright (c) 2016, Linaro Limited > + * All rights reserved. > + * > + * SPDX-License-Identifier: BSD-3-Clause > + */ > + > +#ifndef _ODP_TEST_DRVINIT_H_ > +#define _ODP_TEST_DRVINIT_H_ > + > +#include <odp_cunit_common.h> > + > +/* test functions: */ > +void drvinit_test_load(void); > + > +/* test arrays: */ > +extern odp_testinfo_t drvinit_suite[]; > + > +/* test registry: */ > +extern odp_suiteinfo_t drvinit_suites[]; > + > +/* main test program: */ > +int drvinit_main(int argc, char *argv[]); > + > +#endif > diff --git a/test/common_plat/validation/drv/drvinit/drvinit_main.c b/test/common_plat/validation/drv/drvinit/drvinit_main.c > new file mode 100644 > index 0000000..2abfd20 > --- /dev/null > +++ b/test/common_plat/validation/drv/drvinit/drvinit_main.c > @@ -0,0 +1,12 @@ > +/* Copyright (c) 2016, Linaro Limited > + * All rights reserved. > + * > + * SPDX-License-Identifier: BSD-3-Clause > + */ > + > +#include "drvinit.h" > + > +int main(int argc, char *argv[]) > +{ > + return drvinit_main(argc, argv); > +} > diff --git a/test/common_plat/validation/drv/drvinit/empty_driver.c b/test/common_plat/validation/drv/drvinit/empty_driver.c > new file mode 100644 > index 0000000..c70b6dd > --- /dev/null > +++ b/test/common_plat/validation/drv/drvinit/empty_driver.c > @@ -0,0 +1,12 @@ > +#include <odp_drv.h> > + > +static void __attribute__ ((constructor)) basic_driver_init(void) > +{ > + odpdrv_driver_param_t params; > + odpdrv_driver_param_init(¶m); is missing here to match others odp api passing parameters. > + params.name = "basic_driver"; > + params.bus = ODPDRV_BUS_PCI; > + params.type = ODPDRV_PCI_VIRTIO; > + > + odpdrv_driver_register(¶ms); > +} > diff --git a/test/linux-generic/Makefile.am b/test/linux-generic/Makefile.am > index 2b7cbc3..93b14cb 100644 > --- a/test/linux-generic/Makefile.am > +++ b/test/linux-generic/Makefile.am > @@ -35,6 +35,7 @@ TESTS = validation/api/pktio/pktio_run.sh \ > $(ALL_API_VALIDATION_DIR)/shmem/shmem_main$(EXEEXT) \ > $(ALL_API_VALIDATION_DIR)/system/system_main$(EXEEXT) \ > $(ALL_DRV_VALIDATION_DIR)/drvatomic/drvatomic_main$(EXEEXT) \ > + $(ALL_DRV_VALIDATION_DIR)/drvinit/drvinit_main$(EXEEXT) \ > $(ALL_DRV_VALIDATION_DIR)/drvshmem/drvshmem_main$(EXEEXT) \ > ring/ring_main$(EXEEXT) > > diff --git a/test/m4/configure.m4 b/test/m4/configure.m4 > index 460e844..a7661d6 100644 > --- a/test/m4/configure.m4 > +++ b/test/m4/configure.m4 > @@ -1,3 +1,6 @@ > m4_include([test/common_plat/m4/configure.m4]) > > AC_CONFIG_FILES([test/Makefile]) > + > +#expose the OS variations that tests needs to know in test/test_config.h > +AC_CONFIG_FILES([test/test_config.h]) > diff --git a/test/test_config.h.in b/test/test_config.h.in > new file mode 100644 > index 0000000..d5850b6 > --- /dev/null > +++ b/test/test_config.h.in > @@ -0,0 +1,13 @@ > +/* Copyright (c) 2016, Linaro Limited > + * All rights reserved. > + * > + * SPDX-License-Identifier: BSD-3-Clause > + */ > + > +/* config.h.in is parsed by automake which performs substitutions > + * according to the AC_SUBST macro given in m4 files. > + */ > + > +/* The driver test needs to know which file to load (.so for dlopen...) > + * the test will return 77 (SKIP) if no file can be loaded */ > +#define HAVE_DLFCN_H @HAVE_DLFCN_H@
diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..4be1df5 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +test_config.h diff --git a/test/Makefile.inc b/test/Makefile.inc index 1ebc047..923ca21 100644 --- a/test/Makefile.inc +++ b/test/Makefile.inc @@ -12,7 +12,8 @@ INCFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/platform/@with_platform@/include \ -I$(top_srcdir)/test \ - -I$(top_builddir)/include + -I$(top_builddir)/include \ + -I$(top_builddir)/test AM_CFLAGS += $(INCFLAGS) AM_CXXFLAGS = $(INCFLAGS) diff --git a/test/common_plat/m4/configure.m4 b/test/common_plat/m4/configure.m4 index 1fc350d..32ac8c4 100644 --- a/test/common_plat/m4/configure.m4 +++ b/test/common_plat/m4/configure.m4 @@ -33,4 +33,5 @@ AC_CONFIG_FILES([test/common_plat/Makefile test/common_plat/validation/api/traffic_mngr/Makefile test/common_plat/validation/drv/Makefile test/common_plat/validation/drv/drvatomic/Makefile + test/common_plat/validation/drv/drvinit/Makefile test/common_plat/validation/drv/drvshmem/Makefile]) diff --git a/test/common_plat/validation/Makefile.inc b/test/common_plat/validation/Makefile.inc index ffba620..36c9899 100644 --- a/test/common_plat/validation/Makefile.inc +++ b/test/common_plat/validation/Makefile.inc @@ -8,7 +8,6 @@ COMMON_DIR = $(top_builddir)/test/common_plat/common AUTOMAKE_OPTIONS = nostdinc AM_CFLAGS += -I$(top_srcdir)/test/common_plat/common -AM_LDFLAGS += -static LIBCUNIT_COMMON = $(COMMON_DIR)/libcunit_common.la LIBCPUMASK_COMMON = $(COMMON_DIR)/libcpumask_common.la diff --git a/test/common_plat/validation/drv/Makefile.am b/test/common_plat/validation/drv/Makefile.am index bcdb92e..1574f3d 100644 --- a/test/common_plat/validation/drv/Makefile.am +++ b/test/common_plat/validation/drv/Makefile.am @@ -1,4 +1,5 @@ ODPDRV_MODULES = drvatomic \ + drvinit \ drvshmem SUBDIRS = $(ODPDRV_MODULES) diff --git a/test/common_plat/validation/drv/drvinit/.gitignore b/test/common_plat/validation/drv/drvinit/.gitignore new file mode 100644 index 0000000..d630ef5 --- /dev/null +++ b/test/common_plat/validation/drv/drvinit/.gitignore @@ -0,0 +1 @@ +drvinit_main diff --git a/test/common_plat/validation/drv/drvinit/Makefile.am b/test/common_plat/validation/drv/drvinit/Makefile.am new file mode 100644 index 0000000..8ccf2aa --- /dev/null +++ b/test/common_plat/validation/drv/drvinit/Makefile.am @@ -0,0 +1,25 @@ +include ../Makefile.inc +include $(top_srcdir)/platform/@with_platform@/Makefile.inc + +ABS_TEST_BUILDDIR = $(abs_top_builddir)/test/common_plat/validation/drv/drvinit + +noinst_LTLIBRARIES = libtestdrvinit.la +libtestdrvinit_la_SOURCES = drvinit.c + +# the minimalist driver: +lib_LTLIBRARIES = empty_driver.la +empty_driver_la_SOURCES = empty_driver.c +empty_driver_la_LDFLAGS = $(AM_LDFLAGS) -module -shared -export-dynamic \ + -avoid-version + +# the program trying to load the driver: +# autotools ack: poking straight into .libs to find the ".so" file... +# and hardcoding rpath... +test_PROGRAMS = drvinit_main$(EXEEXT) +drvinit_main_SOURCES = drvinit_main.c +drvinit_main_LDADD = libtestdrvinit.la $(LIBCUNIT_COMMON) $(LIBODP) +drvinit_main_LDFLAGS = $(AM_LDFLAGS) \ + -rpath $(ABS_TEST_BUILDDIR)/.libs \ + -rpath $(libdir) + +EXTRA_DIST = drvinit.h diff --git a/test/common_plat/validation/drv/drvinit/drvinit.c b/test/common_plat/validation/drv/drvinit/drvinit.c new file mode 100644 index 0000000..e79d68a --- /dev/null +++ b/test/common_plat/validation/drv/drvinit/drvinit.c @@ -0,0 +1,58 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <test_config.h> +#include <odp_drv.h> +#include <odp_api.h> +#include <odp_cunit_common.h> +#include "drvinit.h" +#include <stdlib.h> + +#define TEST_SKIPPED 77 + +/* + * basic tests + */ +void drvinit_test_load(void) +{ +#if HAVE_DLFCN_H + CU_ASSERT(odp_load_driver("empty_driver.so") == 0); +#endif +} + +odp_testinfo_t drvinit_suite[] = { + ODP_TEST_INFO(drvinit_test_load), + ODP_TEST_INFO_NULL, +}; + +odp_suiteinfo_t drvinit_suites[] = { + {"Driver load", NULL, NULL, drvinit_suite}, + ODP_SUITE_INFO_NULL, +}; + +int drvinit_main(int argc, char *argv[]) +{ + int ret; + + /* + * none of the following can be performed if we don't have + * some kind of dynamic loading (currentely: dlopen) + */ +#if !HAVE_DLFCN_H + return TEST_SKIPPED; +#endif + + /* parse common options: */ + if (odp_cunit_parse_options(argc, argv)) + return -1; + + ret = odp_cunit_register(drvinit_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; +} diff --git a/test/common_plat/validation/drv/drvinit/drvinit.h b/test/common_plat/validation/drv/drvinit/drvinit.h new file mode 100644 index 0000000..1c9f9a6 --- /dev/null +++ b/test/common_plat/validation/drv/drvinit/drvinit.h @@ -0,0 +1,24 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _ODP_TEST_DRVINIT_H_ +#define _ODP_TEST_DRVINIT_H_ + +#include <odp_cunit_common.h> + +/* test functions: */ +void drvinit_test_load(void); + +/* test arrays: */ +extern odp_testinfo_t drvinit_suite[]; + +/* test registry: */ +extern odp_suiteinfo_t drvinit_suites[]; + +/* main test program: */ +int drvinit_main(int argc, char *argv[]); + +#endif diff --git a/test/common_plat/validation/drv/drvinit/drvinit_main.c b/test/common_plat/validation/drv/drvinit/drvinit_main.c new file mode 100644 index 0000000..2abfd20 --- /dev/null +++ b/test/common_plat/validation/drv/drvinit/drvinit_main.c @@ -0,0 +1,12 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "drvinit.h" + +int main(int argc, char *argv[]) +{ + return drvinit_main(argc, argv); +} diff --git a/test/common_plat/validation/drv/drvinit/empty_driver.c b/test/common_plat/validation/drv/drvinit/empty_driver.c new file mode 100644 index 0000000..c70b6dd --- /dev/null +++ b/test/common_plat/validation/drv/drvinit/empty_driver.c @@ -0,0 +1,12 @@ +#include <odp_drv.h> + +static void __attribute__ ((constructor)) basic_driver_init(void) +{ + odpdrv_driver_param_t params; + + params.name = "basic_driver"; + params.bus = ODPDRV_BUS_PCI; + params.type = ODPDRV_PCI_VIRTIO; + + odpdrv_driver_register(¶ms); +} diff --git a/test/linux-generic/Makefile.am b/test/linux-generic/Makefile.am index 2b7cbc3..93b14cb 100644 --- a/test/linux-generic/Makefile.am +++ b/test/linux-generic/Makefile.am @@ -35,6 +35,7 @@ TESTS = validation/api/pktio/pktio_run.sh \ $(ALL_API_VALIDATION_DIR)/shmem/shmem_main$(EXEEXT) \ $(ALL_API_VALIDATION_DIR)/system/system_main$(EXEEXT) \ $(ALL_DRV_VALIDATION_DIR)/drvatomic/drvatomic_main$(EXEEXT) \ + $(ALL_DRV_VALIDATION_DIR)/drvinit/drvinit_main$(EXEEXT) \ $(ALL_DRV_VALIDATION_DIR)/drvshmem/drvshmem_main$(EXEEXT) \ ring/ring_main$(EXEEXT) diff --git a/test/m4/configure.m4 b/test/m4/configure.m4 index 460e844..a7661d6 100644 --- a/test/m4/configure.m4 +++ b/test/m4/configure.m4 @@ -1,3 +1,6 @@ m4_include([test/common_plat/m4/configure.m4]) AC_CONFIG_FILES([test/Makefile]) + +#expose the OS variations that tests needs to know in test/test_config.h +AC_CONFIG_FILES([test/test_config.h]) diff --git a/test/test_config.h.in b/test/test_config.h.in new file mode 100644 index 0000000..d5850b6 --- /dev/null +++ b/test/test_config.h.in @@ -0,0 +1,13 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* config.h.in is parsed by automake which performs substitutions + * according to the AC_SUBST macro given in m4 files. + */ + +/* The driver test needs to know which file to load (.so for dlopen...) + * the test will return 77 (SKIP) if no file can be loaded */ +#define HAVE_DLFCN_H @HAVE_DLFCN_H@
Trying to fix a proper structure for driver tests in the hard world of autotools: Staticaly linked drivers fails with autotools as the linker would need the "--whole-archive" option which autotools cannot handle. Trying to used ltdl lib does not seem to help the nedd for rpath otpion (which is surprising). So this patch just point at the .so path usiong rpath. Signed-off-by: Christophe Milard <christophe.milard@linaro.org> --- test/.gitignore | 1 + test/Makefile.inc | 3 +- test/common_plat/m4/configure.m4 | 1 + test/common_plat/validation/Makefile.inc | 1 - test/common_plat/validation/drv/Makefile.am | 1 + test/common_plat/validation/drv/drvinit/.gitignore | 1 + .../common_plat/validation/drv/drvinit/Makefile.am | 25 ++++++++++ test/common_plat/validation/drv/drvinit/drvinit.c | 58 ++++++++++++++++++++++ test/common_plat/validation/drv/drvinit/drvinit.h | 24 +++++++++ .../validation/drv/drvinit/drvinit_main.c | 12 +++++ .../validation/drv/drvinit/empty_driver.c | 12 +++++ test/linux-generic/Makefile.am | 1 + test/m4/configure.m4 | 3 ++ test/test_config.h.in | 13 +++++ 14 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 test/.gitignore create mode 100644 test/common_plat/validation/drv/drvinit/.gitignore create mode 100644 test/common_plat/validation/drv/drvinit/Makefile.am create mode 100644 test/common_plat/validation/drv/drvinit/drvinit.c create mode 100644 test/common_plat/validation/drv/drvinit/drvinit.h create mode 100644 test/common_plat/validation/drv/drvinit/drvinit_main.c create mode 100644 test/common_plat/validation/drv/drvinit/empty_driver.c create mode 100644 test/test_config.h.in -- 2.7.4