@@ -33,4 +33,7 @@ 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/drvinit/odp.conf
+ test/common_plat/validation/drv/drvinit/odp_conf_path.h
test/common_plat/validation/drv/drvshmem/Makefile])
@@ -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
@@ -1,4 +1,5 @@
ODPDRV_MODULES = drvatomic \
+ drvinit \
drvshmem
SUBDIRS = $(ODPDRV_MODULES)
new file mode 100644
@@ -0,0 +1,3 @@
+drvinit_main
+odp_conf_path.h
+odp.conf
new file mode 100644
@@ -0,0 +1,27 @@
+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) \
+ -dlreopen $(ABS_TEST_BUILDDIR)/empty_driver.la
+
+# the odp configuration file for this test:
+check_DATA = odp.conf
+
+EXTRA_DIST = drvinit.h odp_conf_path.h
new file mode 100644
@@ -0,0 +1,62 @@
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#define _POSIX_C_SOURCE 200112L /* allowed?? UGLY! */
+#include <odp_drv.h>
+#include <odp_api.h>
+#include <odp_cunit_common.h>
+#include "drvinit.h"
+#include "odp_conf_path.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <libgen.h>
+#include <linux/limits.h>
+
+#define TEST_SKIPPED 77
+
+/*
+ * basic tests
+ */
+void drvinit_test_load(void)
+{
+ /* if we reaches so far, the global init is done, i.e.
+ * the driver was loaded. A loading failure would stop global_init() */
+ CU_PASS();
+}
+
+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;
+
+ /* parse common options: */
+ if (odp_cunit_parse_options(argc, argv))
+ return -1;
+
+ /*
+ * sets the ODP_SYSCONFIG_FILE environment variable:
+ * the ODP_SYSCONFIG_FILE environment variable is used to force
+ * the odp configuration filename (hence not taking the defauld
+ * /etc/odp.conf.
+ * we force the configuration file to be taken from the local directory
+ */
+ setenv("ODP_SYSCONFIG_FILE", CONFIG_FILE, 1);
+
+ ret = odp_cunit_register(drvinit_suites);
+ if (ret == 0)
+ ret = odp_cunit_run();
+
+ return ret;
+}
new file mode 100644
@@ -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
new file mode 100644
@@ -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);
+}
new file mode 100644
@@ -0,0 +1,40 @@
+#include <odp_drv.h>
+
+static int probe(odpdrv_enumerated_dev_t *dev);
+static int remove(odpdrv_enumerated_dev_t *dev);
+
+static odpdrv_driver_t params = {
+ .name = "basic_driver",
+ .devios = {
+ {
+ .devio_api_name = "pci_no_iommu",
+ .devio_api_version = 1,
+ },
+ {
+ .devio_api_name = "\0",
+ }
+ },
+ .probe = probe,
+ .remove = remove,
+};
+
+static void __attribute__ ((constructor)) basic_driver_init(void)
+{
+ odpdrv_driver_register(¶ms);
+}
+
+static int probe(odpdrv_enumerated_dev_t *dev)
+{
+ if (dev)
+ return 0;
+ else
+ return 1;
+}
+
+static int remove(odpdrv_enumerated_dev_t *dev)
+{
+ if (dev)
+ return 0;
+ else
+ return 1;
+}
new file mode 100644
@@ -0,0 +1,8 @@
+#configuration related to modules:
+module = {
+ #listing the modules to be loaded:
+ #here, we just load an empty driver, making sure the loading works.
+ #Need to specify full path to be sure we load the right stuff=>.libs =>UGLY!
+ #modules = ["@abs_top_builddir@/test/common_plat/validation/drv/drvinit/.libs/empty_driver.so"];
+ modules = ["empty_driver.so"];
+};
new file mode 100644
@@ -0,0 +1,4 @@
+/* setting the path to the odp configuration file needed for this test */
+#define CONFIG_FILE_DIR "test/common_plat/validation/drv/drvinit/"
+#define CONFIG_FILE_NAME "odp.conf"
+#define CONFIG_FILE "@abs_top_builddir@" "/" CONFIG_FILE_DIR CONFIG_FILE_NAME
@@ -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)
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. This patch load an empty driver as a shared library (.so), and is the result of a long series of trial and errors with autotools. Signed-off-by: Christophe Milard <christophe.milard@linaro.org> --- Note: must be applied on top of: [API-NEXT PATCHv4 0/5] driver initialisation framework Since V2: includes a needed change for V4 of "driver initialisation framework" Still problem with clang and ther -dlreopen Aututools option... Since V1: updates for V4 of "driver initialisation framework" Is this good enough to go in the test structure? I assumed this is linux test, i.e. not platform dependent... (based on the ARCH decision where we said all linux we consider have dlopen()) Fails with Clang: clang: error: argument unused during compilation: '-dlreopen' test/common_plat/m4/configure.m4 | 3 ++ test/common_plat/validation/Makefile.inc | 1 - test/common_plat/validation/drv/Makefile.am | 1 + test/common_plat/validation/drv/drvinit/.gitignore | 3 ++ .../common_plat/validation/drv/drvinit/Makefile.am | 27 ++++++++++ test/common_plat/validation/drv/drvinit/drvinit.c | 62 ++++++++++++++++++++++ test/common_plat/validation/drv/drvinit/drvinit.h | 24 +++++++++ .../validation/drv/drvinit/drvinit_main.c | 12 +++++ .../validation/drv/drvinit/empty_driver.c | 40 ++++++++++++++ .../common_plat/validation/drv/drvinit/odp.conf.in | 8 +++ .../validation/drv/drvinit/odp_conf_path.h.in | 4 ++ test/linux-generic/Makefile.am | 1 + 12 files changed, 185 insertions(+), 1 deletion(-) 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/common_plat/validation/drv/drvinit/odp.conf.in create mode 100644 test/common_plat/validation/drv/drvinit/odp_conf_path.h.in -- 2.7.4