From patchwork Mon Nov 7 11:15:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 81029 Delivered-To: patch@linaro.org Received: by 10.182.113.165 with SMTP id iz5csp1030487obb; Mon, 7 Nov 2016 02:19:11 -0800 (PST) X-Received: by 10.55.78.138 with SMTP id c132mr5622440qkb.186.1478513951296; Mon, 07 Nov 2016 02:19:11 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a62si15609241qkd.5.2016.11.07.02.19.11; Mon, 07 Nov 2016 02:19:11 -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 04BD360D10; Mon, 7 Nov 2016 10:19:11 +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 5197460CF3; Mon, 7 Nov 2016 10:16:45 +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 6227760D04; Mon, 7 Nov 2016 10:16:23 +0000 (UTC) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) by lists.linaro.org (Postfix) with ESMTPS id 9D4DB60A55 for ; Mon, 7 Nov 2016 10:16:15 +0000 (UTC) Received: by mail-lf0-f50.google.com with SMTP id b14so109122880lfg.2 for ; Mon, 07 Nov 2016 02:16:15 -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:in-reply-to :references; bh=HUuzfWDXqXBiv7E8cc2oMX4TbXtfvBpSjZG2tx2ynNU=; b=AQsTRg5+gmkUaiOStgWNkwqMh1q6/M7scvaKOCSbVrzi/ERleMobbF6bB7UyqTcGOB SVNKCrOXxYikUlJ+YNSqPnZqbAOqtio0PBW7plaVwi5jYG8M8/PggkdOVNPK7fCTn97X NNaqSOS0rslfG0CCycrz7DYPk2x2sSocUGsNATFYQJfR8UKGhSdcG6lYu6GHUpThl9J6 n3PFCeYbK935qnZmAtCXi81M1D2PUDoFCZLmwqg844A9BMC+pg7WSKR7nbfRmrrAVkS3 zdR2onI5C2MMb1d0AKez0taDajva7UW/GYWiSyNZunYe6A63QjlMaZeLoewCYvYcsOWS +4EQ== X-Gm-Message-State: ABUngvdSwciUNs2dp0glBkHDYb4dLfws67+QjFcC6R3d6uWmxSzLoqJu0JaD8ZDoaY92hgNU1xQ= X-Received: by 10.25.196.136 with SMTP id u130mr3024830lff.62.1478513774289; Mon, 07 Nov 2016 02:16:14 -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 w67sm4932592lff.16.2016.11.07.02.16.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Nov 2016 02:16:13 -0800 (PST) From: Christophe Milard To: yi.he@linaro.org, mike.holmes@linaro.org, bill.fischofer@linaro.org, lng-odp@lists.linaro.org Date: Mon, 7 Nov 2016 12:15:24 +0100 Message-Id: <1478517324-11324-6-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478517324-11324-1-git-send-email-christophe.milard@linaro.org> References: <1478517324-11324-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 5/5] test: adding test for driver load function 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. 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 --- 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 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 +#include +#include +#include +#include "drvinit.h" +#include + +#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 + +/* 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 + +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@