From patchwork Wed Mar 22 14:48:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 95744 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp230281obz; Wed, 22 Mar 2017 07:04:29 -0700 (PDT) X-Received: by 10.55.45.133 with SMTP id t127mr34871186qkh.218.1490191469104; Wed, 22 Mar 2017 07:04:29 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k38si1145816qtk.329.2017.03.22.07.04.28; Wed, 22 Mar 2017 07:04:29 -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 sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id BD75664011; Wed, 22 Mar 2017 14:04:28 +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.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED,URI_NOVOWEL 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 8294B6430C; Wed, 22 Mar 2017 13:51:19 +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 5F6D5642CF; Wed, 22 Mar 2017 13:51:11 +0000 (UTC) Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by lists.linaro.org (Postfix) with ESMTPS id 38551642CF for ; Wed, 22 Mar 2017 13:49:32 +0000 (UTC) Received: by mail-wm0-f41.google.com with SMTP id n11so37222883wma.1 for ; Wed, 22 Mar 2017 06:49:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rf8v03NHTd+8VR0GkSfVAETOEKqCy/0CbYMh5Qv37Uw=; b=kIFDkWFwNCvoNpMHZ2Pmd7Fe5e+yM3n1MKWQH+pXaoIe6+sLPOMub9ah40bgryVSgo k4yaSxXaMnp/f1eZr/pZ2UZc8qi53fgWDZheihJF8Ip+o70LWGjaf+VVq6fVTLg67gaG yqn1Hu7VtKgGWT86hRgrAk9WSzBf5yiNfAqlGgTy0u6abwkfdChc8iDVPrLp8UuTpner t4TT5K3wZ69zJZdy6zjhk19uRx1k5Bpo5tQup58lRsOeORsfXc4d/fbQwjOwEeEQVM2d AZHbDuKFbVGjgWBzGQqXD5DUsercG5DOBC2n83XE1jf7DEPEHP1j1YvYFssSoH+caRYm w3OQ== X-Gm-Message-State: AFeK/H1GUK49gpnNQk8jlAGFTDMWGmihirBwcpCnZ0qHcqDE0XEfbiIwiJUbHWX/Z3uf9b6S+KU= X-Received: by 10.25.21.74 with SMTP id l71mr11527211lfi.93.1490190570954; Wed, 22 Mar 2017 06:49:30 -0700 (PDT) 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 l23sm522305lfk.27.2017.03.22.06.49.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Mar 2017 06:49:30 -0700 (PDT) From: Christophe Milard To: yi.he@linaro.org, bill.fischofer@linaro.org, lng-odp@lists.linaro.org Date: Wed, 22 Mar 2017 15:48:23 +0100 Message-Id: <1490194110-40168-17-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490194110-40168-1-git-send-email-christophe.milard@linaro.org> References: <1490194110-40168-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv2 16/23] test: drv: devio creation and destruction 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" Testing that devios can be registered and removed in/from ODP. Signed-off-by: Christophe Milard --- .../validation/drv/drvdriver/.gitignore | 1 + .../validation/drv/drvdriver/Makefile.am | 11 ++ .../validation/drv/drvdriver/drvdriver_devio.c | 209 +++++++++++++++++++++ .../validation/drv/drvdriver/drvdriver_devio.h | 24 +++ .../drv/drvdriver/drvdriver_devio_main.c | 12 ++ test/linux-generic/Makefile.am | 1 + 6 files changed, 258 insertions(+) create mode 100644 test/common_plat/validation/drv/drvdriver/drvdriver_devio.c create mode 100644 test/common_plat/validation/drv/drvdriver/drvdriver_devio.h create mode 100644 test/common_plat/validation/drv/drvdriver/drvdriver_devio_main.c -- 2.7.4 diff --git a/test/common_plat/validation/drv/drvdriver/.gitignore b/test/common_plat/validation/drv/drvdriver/.gitignore index 97b4312..829c8b4 100644 --- a/test/common_plat/validation/drv/drvdriver/.gitignore +++ b/test/common_plat/validation/drv/drvdriver/.gitignore @@ -1,3 +1,4 @@ drvdriver_enumr_class_main drvdriver_enumr_main drvdriver_device_main +drvdriver_devio_main diff --git a/test/common_plat/validation/drv/drvdriver/Makefile.am b/test/common_plat/validation/drv/drvdriver/Makefile.am index 544586c..8e695ba 100644 --- a/test/common_plat/validation/drv/drvdriver/Makefile.am +++ b/test/common_plat/validation/drv/drvdriver/Makefile.am @@ -36,3 +36,14 @@ drvdriver_device_main_LDADD = libtestdrvdriverdevice.la \ $(LIBCUNIT_COMMON) $(LIBODP) EXTRA_DIST += drvdriver_device.h + +#tests for devio creation: +noinst_LTLIBRARIES += libtestdrvdriverdevio.la +libtestdrvdriverdevio_la_SOURCES = drvdriver_devio.c + +test_PROGRAMS += drvdriver_devio_main$(EXEEXT) +dist_drvdriver_devio_main_SOURCES = drvdriver_devio_main.c +drvdriver_devio_main_LDADD = libtestdrvdriverdevio.la \ + $(LIBCUNIT_COMMON) $(LIBODP) + +EXTRA_DIST += drvdriver_devio.h diff --git a/test/common_plat/validation/drv/drvdriver/drvdriver_devio.c b/test/common_plat/validation/drv/drvdriver/drvdriver_devio.c new file mode 100644 index 0000000..cf7c7c9 --- /dev/null +++ b/test/common_plat/validation/drv/drvdriver/drvdriver_devio.c @@ -0,0 +1,209 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include "drvdriver_devio.h" +#include + +static odp_instance_t odp_instance; + +static int devio1_removed; +static int devio2_removed; +static int devio3_removed; +static int devio4_removed; + +static int devio1_remove(void); +static int devio2_remove(void); +static int devio3_remove(void); + +/* because many things to be checked are performed during ODP initialisation, + * the initialisation functions have to be a part of the test + */ +static int tests_global_init(void) +{ + if (0 != odp_init_global(&odp_instance, NULL, NULL)) { + fprintf(stderr, "error: odp_init_global() failed.\n"); + return -1; + } + if (0 != odp_init_local(odp_instance, ODP_THREAD_CONTROL)) { + fprintf(stderr, "error: odp_init_local() failed.\n"); + return -1; + } + + return 0; +} + +static int tests_global_term(void) +{ + if (0 != odp_term_local()) { + fprintf(stderr, "error: odp_term_local() failed.\n"); + return -1; + } + + if (0 != odp_term_global(odp_instance)) { + fprintf(stderr, "error: odp_term_global() failed.\n"); + return -1; + } + + return 0; +} + +/*devio register functions, all "statically linked" + *(i.e. directely run at start), due to the fact that platorm independent + * shared lib loading in autotools is a mess */ +static void ODPDRV_CONSTRUCTOR devio1_register(void) +{ + odpdrv_devio_param_t param = { + .api_name = "devio_api_1", + .api_version = 1, + .enumr_api_name = "Enumerator_interface_1", + .enumr_api_version = 1, + .remove = devio1_remove, + .ops = NULL, + }; + + odpdrv_devio_register(¶m); +} + +static void ODPDRV_CONSTRUCTOR devio2_register(void) +{ + odpdrv_devio_param_t param = { + .api_name = "devio_api_2", + .api_version = 1, + .enumr_api_name = "Enumerator_interface_1", + .enumr_api_version = 1, + .probe = NULL, + .remove = devio2_remove, + .ops = NULL, + }; + + odpdrv_devio_register(¶m); +} + +static odpdrv_devio_t devio2_register_retry(void) +{ + odpdrv_devio_param_t param = { + .api_name = "devio_api_2", + .api_version = 1, + .enumr_api_name = "Enumerator_interface_1", + .enumr_api_version = 1, + .probe = NULL, + .remove = NULL, + .ops = NULL, + }; + + return odpdrv_devio_register(¶m); +} + +static void ODPDRV_CONSTRUCTOR devio3_register(void) +{ + odpdrv_devio_param_t param = { + .api_name = "devio_api_2", + .api_version = 1, + .enumr_api_name = "Enumerator_interface_2", + .enumr_api_version = 1, + .probe = NULL, + .remove = devio3_remove, + .ops = NULL, + }; + + odpdrv_devio_register(¶m); +} + +static void ODPDRV_CONSTRUCTOR devio4_register(void) +{ + odpdrv_devio_param_t param = { + .api_name = "devio_api_3", + .api_version = 1, + .enumr_api_name = "Enumerator_interface_3", + .enumr_api_version = 1, + .probe = NULL, + .remove = NULL, + .ops = NULL, + }; + + odpdrv_devio_register(¶m); +} + +/*devio remove functions, just making sure they have been run: */ +static int devio1_remove(void) +{ + devio1_removed = 1; + return 0; +} + +/*devio remove functions, just making sure they have been run: */ +static int devio2_remove(void) +{ + devio2_removed = 1; + return 0; +} + +/*devio remove functions, just making sure they have been run: */ +static int devio3_remove(void) +{ + devio3_removed = 1; + return 0; +} + +void drvdriver_test_devio_register(void) +{ + CU_ASSERT(devio1_removed == 0); + CU_ASSERT(devio2_removed == 0); + CU_ASSERT(devio3_removed == 0); + CU_ASSERT(devio4_removed == 0); + + CU_ASSERT(tests_global_init() == 0); + + /* at this point (after odp init), the constructor + * devios should have registered. just print them: + */ + CU_ASSERT(odpdrv_print_all() == 0); + + /* re-register devio2: this should be kicked-out! */ + CU_ASSERT(devio2_register_retry() == ODPDRV_DEVIO_INVALID); + + CU_ASSERT(tests_global_term() == 0); + + /* after ODP termination completion, all devios have been removed*/ + CU_ASSERT(devio1_removed == 1); + CU_ASSERT(devio2_removed == 1); + CU_ASSERT(devio3_removed == 1); + CU_ASSERT(devio4_removed == 0); /* has no remove function */ +} + +odp_testinfo_t drvdriver_suite_devio[] = { + ODP_TEST_INFO(drvdriver_test_devio_register), + ODP_TEST_INFO_NULL, +}; + +odp_suiteinfo_t drvdriver_suites_devio[] = { + {"Devio registration", NULL, NULL, drvdriver_suite_devio}, + ODP_SUITE_INFO_NULL, +}; + +int drvdriver_devio_main(int argc, char *argv[]) +{ + int ret; + + /* parse common options: */ + if (odp_cunit_parse_options(argc, argv)) + return -1; + + /* prevent default ODP init: */ + odp_cunit_register_global_init(NULL); + odp_cunit_register_global_term(NULL); + + /* register the tests: */ + ret = odp_cunit_register(drvdriver_suites_devio); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; +} diff --git a/test/common_plat/validation/drv/drvdriver/drvdriver_devio.h b/test/common_plat/validation/drv/drvdriver/drvdriver_devio.h new file mode 100644 index 0000000..eea9623 --- /dev/null +++ b/test/common_plat/validation/drv/drvdriver/drvdriver_devio.h @@ -0,0 +1,24 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef _ODP_TEST_DRVDRIVER_DEVIO_H_ +#define _ODP_TEST_DRVDRIVER_DEVIO_H_ + +#include + +/* test functions: */ +void drvdriver_test_devio_register(void); + +/* test arrays: */ +extern odp_testinfo_t drvdriver_suite_devio[]; + +/* test registry: */ +extern odp_suiteinfo_t drvdriver_suites_devio[]; + +/* main test program: */ +int drvdriver_devio_main(int argc, char *argv[]); + +#endif diff --git a/test/common_plat/validation/drv/drvdriver/drvdriver_devio_main.c b/test/common_plat/validation/drv/drvdriver/drvdriver_devio_main.c new file mode 100644 index 0000000..10733ad --- /dev/null +++ b/test/common_plat/validation/drv/drvdriver/drvdriver_devio_main.c @@ -0,0 +1,12 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "drvdriver_devio.h" + +int main(int argc, char *argv[]) +{ + return drvdriver_devio_main(argc, argv); +} diff --git a/test/linux-generic/Makefile.am b/test/linux-generic/Makefile.am index c95449a..55db05c 100644 --- a/test/linux-generic/Makefile.am +++ b/test/linux-generic/Makefile.am @@ -37,6 +37,7 @@ TESTS = validation/api/pktio/pktio_run.sh \ $(ALL_API_VALIDATION_DIR)/system/system_main$(EXEEXT) \ $(ALL_DRV_VALIDATION_DIR)/drvatomic/drvatomic_main$(EXEEXT) \ $(ALL_DRV_VALIDATION_DIR)/drvdriver/drvdriver_device_main$(EXEEXT)\ + $(ALL_DRV_VALIDATION_DIR)/drvdriver/drvdriver_devio_main$(EXEEXT)\ $(ALL_DRV_VALIDATION_DIR)/drvdriver/drvdriver_enumr_class_main$(EXEEXT)\ $(ALL_DRV_VALIDATION_DIR)/drvdriver/drvdriver_enumr_main$(EXEEXT)\ $(ALL_DRV_VALIDATION_DIR)/drvshmem/drvshmem_main$(EXEEXT) \