From patchwork Mon Oct 31 18:58: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: 80263 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp269613qge; Mon, 31 Oct 2016 12:02:40 -0700 (PDT) X-Received: by 10.200.41.201 with SMTP id 9mr25143537qtt.138.1477940560412; Mon, 31 Oct 2016 12:02:40 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k10si2899809qtb.97.2016.10.31.12.02.40; Mon, 31 Oct 2016 12:02:40 -0700 (PDT) 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 1B63C6178C; Mon, 31 Oct 2016 19:02:40 +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 7971D61791; Mon, 31 Oct 2016 18:59:37 +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 D79B7617A9; Mon, 31 Oct 2016 18:59:25 +0000 (UTC) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) by lists.linaro.org (Postfix) with ESMTPS id 72AB96096F for ; Mon, 31 Oct 2016 18:58:55 +0000 (UTC) Received: by mail-lf0-f43.google.com with SMTP id f134so105650756lfg.2 for ; Mon, 31 Oct 2016 11:58:55 -0700 (PDT) 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=lstQRfaeZH1+8OQEEXp3hq6ccy3QcZJI//pJtMpQr0U=; b=GN2Wh2n2+KvaMRoZ6QS20+lKTKp6QkfjNDyOrSHkqFyyOJ9tj3fMF+xldXkKXXm+hl on6QTcrmnJ1UBBAZKps1cku3inXW3bvAQTmALwWaz4eT2weg6z4xz9EYBTRwCOrvJeh5 yf7DwgfHS9k4s3u0MdYmoRfBP6/bm6BtY2sUhlHKHNMpCwqZNs6FB3uhtmA66U9gmO1k WQ4XWo33/u+dbSzpzfd3EtmneeJxzCvfZPzDWKbwahXbVBxYZV26Uxqnz+8elM0oFxzE 24tLkem9V+k3urSQTF1QCZikM5gWgFSHporP40BBGVphqn0j7y4xPWzWOwXgx419gKKu RZKg== X-Gm-Message-State: ABUngvdPGtqM9BFDHKkh26Qp6bSsdMfWngisUh/gCZJAYrZM/AvVUpICzYqUjWNbGY5ePOZRQ9M= X-Received: by 10.25.8.6 with SMTP id 6mr15366831lfi.64.1477940334030; Mon, 31 Oct 2016 11:58:54 -0700 (PDT) Received: from localhost.localdomain (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id b29sm4792417lfh.8.2016.10.31.11.58.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Oct 2016 11:58:52 -0700 (PDT) From: Christophe Milard To: mike.holmes@linaro.org, bill.fischofer@linaro.org, brian.brooks@linaro.org, lng-odp@lists.linaro.org Date: Mon, 31 Oct 2016 19:58:43 +0100 Message-Id: <1477940323-7278-6-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477940323-7278-1-git-send-email-christophe.milard@linaro.org> References: <1477940323-7278-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 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 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..d2cd1bb --- /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 = PCI; + params.type = 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@