From patchwork Thu Dec 8 12:50:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 87234 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp801370qgi; Thu, 8 Dec 2016 03:51:35 -0800 (PST) X-Received: by 10.55.67.81 with SMTP id q78mr63455913qka.53.1481197895846; Thu, 08 Dec 2016 03:51:35 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p86si17072289qki.104.2016.12.08.03.51.35; Thu, 08 Dec 2016 03:51:35 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 5262562F58; Thu, 8 Dec 2016 11:51:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 6373E6347E; Thu, 8 Dec 2016 11:51:24 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 39E736347E; Thu, 8 Dec 2016 11:51:14 +0000 (UTC) Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by lists.linaro.org (Postfix) with ESMTPS id 8EE7462F52 for ; Thu, 8 Dec 2016 11:51:12 +0000 (UTC) Received: by mail-wm0-f46.google.com with SMTP id t79so21553685wmt.0 for ; Thu, 08 Dec 2016 03:51:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ou93QUn8k3ad9qiZxsRwG/aYDhwkxNLT3F/mG5iexvM=; b=GqiJkQz1ofyWT7pQFMogaTrW9AV7brbm4yf41DWsdhLQxlcHACdrQrmRVA5NwVfZUL wgyvwyxPzgENhOReNG3VL2hC0gI5sbi8hXqAHY54IPq5Nd027G1MJ4R6WhBWId2eqdmP ImdpIDyFDcnd8dUo21vFXq8eFpsU/Jh8oYRwqkNBxMEAchKLcen3NJvXS9vYf+kZXhPt ik2iFfeqZktMuU0WyaI7Z7c5FN/AJ/eDIsmfa+e6+qGreUyefxCP8EarNUC9qTuTI6Jn HpGAPqnty5QQhzIECXO45BzsYaTM2BYBpLIDBTMPTcpqalNvIVgzKjBISN8bbIohYFGZ QvgQ== X-Gm-Message-State: AKaTC010jRtZS+PVPTbKDMF6gecE2dZX5yM47lKNwW6nBXqMJl3JvgaEgKJBIMnFPzGIXg7sIJI= X-Received: by 10.25.15.40 with SMTP id e40mr942884lfi.10.1481197871444; Thu, 08 Dec 2016 03:51:11 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id a79sm5496193lfe.48.2016.12.08.03.51.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Dec 2016 03:51:10 -0800 (PST) From: Christophe Milard To: francois.ozog@linaro.org, forrest.shi@linaro.org, mike.holmes@linaro.org, yi.he@linaro.org, bill.fischofer@linaro.org, lng-odp@lists.linaro.org Date: Thu, 8 Dec 2016 13:50:43 +0100 Message-Id: <1481201443-33934-1-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [lng-odp] [RFC API-NEXT PATCHv3] test: adding test for driver loading X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" 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 --- 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 diff --git a/test/common_plat/m4/configure.m4 b/test/common_plat/m4/configure.m4 index 1fc350d..3ff90fb 100644 --- a/test/common_plat/m4/configure.m4 +++ b/test/common_plat/m4/configure.m4 @@ -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]) 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..0d56fa9 --- /dev/null +++ b/test/common_plat/validation/drv/drvinit/.gitignore @@ -0,0 +1,3 @@ +drvinit_main +odp_conf_path.h +odp.conf 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..622bbf3 --- /dev/null +++ b/test/common_plat/validation/drv/drvinit/Makefile.am @@ -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 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..c4152f7 --- /dev/null +++ b/test/common_plat/validation/drv/drvinit/drvinit.c @@ -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 +#include +#include +#include "drvinit.h" +#include "odp_conf_path.h" +#include +#include +#include +#include + +#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; +} 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 + +/* 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..e7acb83 --- /dev/null +++ b/test/common_plat/validation/drv/drvinit/empty_driver.c @@ -0,0 +1,40 @@ +#include + +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; +} diff --git a/test/common_plat/validation/drv/drvinit/odp.conf.in b/test/common_plat/validation/drv/drvinit/odp.conf.in new file mode 100644 index 0000000..65688fe --- /dev/null +++ b/test/common_plat/validation/drv/drvinit/odp.conf.in @@ -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"]; +}; diff --git a/test/common_plat/validation/drv/drvinit/odp_conf_path.h.in b/test/common_plat/validation/drv/drvinit/odp_conf_path.h.in new file mode 100644 index 0000000..ea62f78 --- /dev/null +++ b/test/common_plat/validation/drv/drvinit/odp_conf_path.h.in @@ -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 diff --git a/test/linux-generic/Makefile.am b/test/linux-generic/Makefile.am index 888da5d..b0517db 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)