From patchwork Thu Feb 22 09:00:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 129167 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp374003lja; Thu, 22 Feb 2018 01:05:17 -0800 (PST) X-Google-Smtp-Source: AH8x227jYGSegDfsa2Pahgxz4dCbDIw3DN4MF9sjyjW9sl3Tq0UihiWfDJrrnZ+kif+D4rh7Ig+G X-Received: by 10.200.39.6 with SMTP id g6mr9757515qtg.169.1519290316989; Thu, 22 Feb 2018 01:05:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519290316; cv=none; d=google.com; s=arc-20160816; b=JXi1RFHgXxIvnnRN4VoBBmFthPzs/Us1lmN2MRS6BVMa1bXqFl9vucjobF/elyoelQ PkXCacU+Jru1gNCCRNKoNumXUAlx7OD9J/9aGShvmwBKGdkmzFg4ia2GxRzBB/CjHuO8 o2Lf0DleuX4TMvMWD8lk0F37mzOT6KF+TbVAGbjqzopJP/Q29HSxeFwdHwu9de+YxcgX f/UsMWzNU8jp+Y8kxBDahV59rhEwOWRFmnye56DYWXWlP+DruofvJ3OFxcYe3iv7SUkf VMkHgXPSel2CAJH3nTh7ccavmCHBx5tR1MRfj4ao4fdkA/Y2Lkx8S+kmqXlgtvbDuSCK /EOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=kyfwyj37soZBsG8zBVhlr1m4/6JIUhjlBTnEc+vBbgI=; b=gw5GRkV2bhMuCo8u0QR0TJ5sW9sNQ9YzfAN/xX1PtppNCfDVONr9aQBnJaPKnqX7bQ Gj3LGhTr2uWOCPTmWgk+T+p2gxP5Gmu72OPHixZjgrXDVWYy39dcmj6h/I2rzTJSRBFR 7iRGGI6XdiYP/5vznCo7XHBHW9AVXqN0xdmd+DkKHfwueeXzpyFF0nk3eGag9Fwo4WJd nTJLF8zEwGKlbPXaktMKZYh9DaHYBuQUsDBKAKuJD8xzXo8uTAF4UIgNESMNP0ZlsjTd JN1941uoEFfDjSy0/33aWuTR38vs98k0vSaoxmR79gW6raKL/u0vTcYKsXP/eMshOEdy qHuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id g18si3059682qtk.160.2018.02.22.01.05.16; Thu, 22 Feb 2018 01:05:16 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 8A8066172B; Thu, 22 Feb 2018 09:05:16 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 75A7461732; Thu, 22 Feb 2018 09:00:55 +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 3EF00616EA; Thu, 22 Feb 2018 09:00:27 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id 1A7436171C for ; Thu, 22 Feb 2018 09:00:18 +0000 (UTC) Received: from mxback7j.mail.yandex.net (mxback7j.mail.yandex.net [IPv6:2a02:6b8:0:1619::110]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 1CA721345D48 for ; Thu, 22 Feb 2018 12:00:16 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback7j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 52vbNqmrLX-0GkSLJr0; Thu, 22 Feb 2018 12:00:16 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Qk3Eeopztj-0FHWT615; Thu, 22 Feb 2018 12:00:15 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 22 Feb 2018 12:00:07 +0300 Message-Id: <1519290010-13383-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519290010-13383-1-git-send-email-odpbot@yandex.ru> References: <1519290010-13383-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 496 Subject: [lng-odp] [PATCH v1 4/7] validation: init: remove "library" file 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" From: Dmitry Eremin-Solenikov Split init.c/init.h files into individual tests, simplifying setup. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 496 (lumag:tests-fix-2) ** https://github.com/Linaro/odp/pull/496 ** Patch: https://github.com/Linaro/odp/pull/496.patch ** Base sha: 5a58bbf2bb331fd7dde2ebbc0430634ace6900fb ** Merge commit sha: 2ca48deb89c7ac000bd44a1da037c36de66720cb **/ test/validation/api/init/Makefile.am | 6 +- test/validation/api/init/init.c | 190 ----------------------------- test/validation/api/init/init.h | 32 ----- test/validation/api/init/init_main_abort.c | 55 ++++++++- test/validation/api/init/init_main_log.c | 76 +++++++++++- test/validation/api/init/init_main_ok.c | 45 ++++++- 6 files changed, 173 insertions(+), 231 deletions(-) delete mode 100644 test/validation/api/init/init.c delete mode 100644 test/validation/api/init/init.h diff --git a/test/validation/api/init/Makefile.am b/test/validation/api/init/Makefile.am index 2d0661431..5af2e00bc 100644 --- a/test/validation/api/init/Makefile.am +++ b/test/validation/api/init/Makefile.am @@ -4,6 +4,6 @@ include ../Makefile.inc # following each other: therefore 3 separate binaries are # created, each containing its ODP init test. test_PROGRAMS = init_main_abort init_main_log init_main_ok -init_main_abort_SOURCES = init_main_abort.c init.c init.h -init_main_log_SOURCES = init_main_log.c init.c init.h -init_main_ok_SOURCES = init_main_ok.c init.c init.h +init_main_abort_SOURCES = init_main_abort.c +init_main_log_SOURCES = init_main_log.c +init_main_ok_SOURCES = init_main_ok.c diff --git a/test/validation/api/init/init.c b/test/validation/api/init/init.c deleted file mode 100644 index 3dc40ea5f..000000000 --- a/test/validation/api/init/init.c +++ /dev/null @@ -1,190 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "config.h" - -#include -#include -#include -#include -#include "init.h" - -/* flag set when the replacement logging function is used */ -int replacement_logging_used; - -/* replacement abort function: */ -static void odp_init_abort(void) ODP_NORETURN; - -/* replacement log function: */ -ODP_PRINTF_FORMAT(2, 3) -static int odp_init_log(odp_log_level_t level, const char *fmt, ...); - -/* test ODP global init, with alternate abort function */ -void init_test_odp_init_global_replace_abort(void) -{ - int status; - odp_init_t init_data; - odp_instance_t instance; - - odp_init_param_init(&init_data); - init_data.abort_fn = &odp_init_abort; - - status = odp_init_global(&instance, &init_data, NULL); - CU_ASSERT_FATAL(status == 0); - - status = odp_term_global(instance); - CU_ASSERT(status == 0); -} - -odp_testinfo_t init_suite_abort[] = { - ODP_TEST_INFO(init_test_odp_init_global_replace_abort), - ODP_TEST_INFO_NULL, -}; - -odp_suiteinfo_t init_suites_abort[] = { - {"Init", NULL, NULL, init_suite_abort}, - ODP_SUITE_INFO_NULL, -}; - -static void odp_init_abort(void) -{ - abort(); -} - -int init_main_abort(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); - - /* run the tests: */ - ret = odp_cunit_register(init_suites_abort); - - if (ret == 0) - ret = odp_cunit_run(); - - return ret; -} - -/* test ODP global init, with alternate log function */ -void init_test_odp_init_global_replace_log(void) -{ - int status; - odp_init_t init_data; - odp_instance_t instance; - - odp_init_param_init(&init_data); - init_data.log_fn = &odp_init_log; - - replacement_logging_used = 0; - - status = odp_init_global(&instance, &init_data, NULL); - CU_ASSERT_FATAL(status == 0); - - CU_ASSERT_TRUE(replacement_logging_used || ODP_DEBUG_PRINT == 0); - - status = odp_term_global(instance); - CU_ASSERT(status == 0); -} - -odp_testinfo_t init_suite_log[] = { - ODP_TEST_INFO(init_test_odp_init_global_replace_log), - ODP_TEST_INFO_NULL, -}; - -odp_suiteinfo_t init_suites_log[] = { - {"Init", NULL, NULL, init_suite_log}, - ODP_SUITE_INFO_NULL, -}; - -static int odp_init_log(odp_log_level_t level __attribute__((unused)), - const char *fmt, ...) -{ - va_list args; - int r; - - /* just set a flag to be sure the replacement fn was used */ - replacement_logging_used = 1; - - va_start(args, fmt); - r = vfprintf(stderr, fmt, args); - va_end(args); - - return r; -} - -int init_main_log(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(init_suites_log); - - /* run the tests: */ - if (ret == 0) - ret = odp_cunit_run(); - - return ret; -} - -/* test normal ODP global init */ -void init_test_odp_init_global(void) -{ - int status; - odp_instance_t instance; - - status = odp_init_global(&instance, NULL, NULL); - CU_ASSERT_FATAL(status == 0); - - status = odp_term_global(instance); - CU_ASSERT(status == 0); -} - -odp_testinfo_t init_suite_ok[] = { - ODP_TEST_INFO(init_test_odp_init_global), - ODP_TEST_INFO_NULL, -}; - -odp_suiteinfo_t init_suites_ok[] = { - {"Init", NULL, NULL, init_suite_ok}, - ODP_SUITE_INFO_NULL, -}; - -int init_main_ok(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(init_suites_ok); - - /* run the tests: */ - if (ret == 0) - ret = odp_cunit_run(); - - return ret; -} diff --git a/test/validation/api/init/init.h b/test/validation/api/init/init.h deleted file mode 100644 index cad9cf988..000000000 --- a/test/validation/api/init/init.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _ODP_TEST_INIT_H_ -#define _ODP_TEST_INIT_H_ - -#include - -/* test functions: */ -void init_test_odp_init_global_replace_abort(void); -void init_test_odp_init_global_replace_log(void); -void init_test_odp_init_global(void); - -/* test arrays: */ -extern odp_testinfo_t init_suite_abort[]; -extern odp_testinfo_t init_suite_log[]; -extern odp_testinfo_t init_suite_ok[]; - -/* test registry: */ -extern odp_suiteinfo_t init_suites_abort[]; -extern odp_suiteinfo_t init_suites_log[]; -extern odp_suiteinfo_t init_suites_ok[]; - -/* main test program: */ -int init_main_abort(int argc, char *argv[]); -int init_main_log(int argc, char *argv[]); -int init_main_ok(int argc, char *argv[]); - -#endif diff --git a/test/validation/api/init/init_main_abort.c b/test/validation/api/init/init_main_abort.c index 1b043154f..e00d3e089 100644 --- a/test/validation/api/init/init_main_abort.c +++ b/test/validation/api/init/init_main_abort.c @@ -6,9 +6,60 @@ #include "config.h" -#include "init.h" +#include +#include +#include + +/* replacement abort function: */ +static void ODP_NORETURN odp_init_abort(void) +{ + abort(); +} + +/* test ODP global init, with alternate abort function */ +static void init_test_odp_init_global_replace_abort(void) +{ + int status; + odp_init_t init_data; + odp_instance_t instance; + + odp_init_param_init(&init_data); + init_data.abort_fn = &odp_init_abort; + + status = odp_init_global(&instance, &init_data, NULL); + CU_ASSERT_FATAL(status == 0); + + status = odp_term_global(instance); + CU_ASSERT(status == 0); +} + +odp_testinfo_t init_suite_abort[] = { + ODP_TEST_INFO(init_test_odp_init_global_replace_abort), + ODP_TEST_INFO_NULL, +}; + +odp_suiteinfo_t init_suites_abort[] = { + {"Init", NULL, NULL, init_suite_abort}, + ODP_SUITE_INFO_NULL, +}; int main(int argc, char *argv[]) { - return init_main_abort(argc, 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); + + /* run the tests: */ + ret = odp_cunit_register(init_suites_abort); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/api/init/init_main_log.c b/test/validation/api/init/init_main_log.c index d5d1ba6d3..2c6f1f114 100644 --- a/test/validation/api/init/init_main_log.c +++ b/test/validation/api/init/init_main_log.c @@ -6,9 +6,81 @@ #include "config.h" -#include "init.h" +#include +#include +#include + +/* flag set when the replacement logging function is used */ +int replacement_logging_used; + +/* replacement log function: */ +ODP_PRINTF_FORMAT(2, 3) +static int odp_init_log(odp_log_level_t level __attribute__((unused)), + const char *fmt, ...) +{ + va_list args; + int r; + + /* just set a flag to be sure the replacement fn was used */ + replacement_logging_used = 1; + + va_start(args, fmt); + r = vfprintf(stderr, fmt, args); + va_end(args); + + return r; +} + + +/* test ODP global init, with alternate log function */ +static void init_test_odp_init_global_replace_log(void) +{ + int status; + odp_init_t init_data; + odp_instance_t instance; + + odp_init_param_init(&init_data); + init_data.log_fn = &odp_init_log; + + replacement_logging_used = 0; + + status = odp_init_global(&instance, &init_data, NULL); + CU_ASSERT_FATAL(status == 0); + + CU_ASSERT_TRUE(replacement_logging_used || ODP_DEBUG_PRINT == 0); + + status = odp_term_global(instance); + CU_ASSERT(status == 0); +} + +odp_testinfo_t init_suite_log[] = { + ODP_TEST_INFO(init_test_odp_init_global_replace_log), + ODP_TEST_INFO_NULL, +}; + +odp_suiteinfo_t init_suites_log[] = { + {"Init", NULL, NULL, init_suite_log}, + ODP_SUITE_INFO_NULL, +}; int main(int argc, char *argv[]) { - return init_main_log(argc, 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(init_suites_log); + + /* run the tests: */ + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/api/init/init_main_ok.c b/test/validation/api/init/init_main_ok.c index bb205f6df..52df15694 100644 --- a/test/validation/api/init/init_main_ok.c +++ b/test/validation/api/init/init_main_ok.c @@ -6,9 +6,50 @@ #include "config.h" -#include "init.h" +#include +#include + +/* test normal ODP global init */ +static void init_test_odp_init_global(void) +{ + int status; + odp_instance_t instance; + + status = odp_init_global(&instance, NULL, NULL); + CU_ASSERT_FATAL(status == 0); + + status = odp_term_global(instance); + CU_ASSERT(status == 0); +} + +odp_testinfo_t init_suite_ok[] = { + ODP_TEST_INFO(init_test_odp_init_global), + ODP_TEST_INFO_NULL, +}; + +odp_suiteinfo_t init_suites_ok[] = { + {"Init", NULL, NULL, init_suite_ok}, + ODP_SUITE_INFO_NULL, +}; int main(int argc, char *argv[]) { - return init_main_ok(argc, 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(init_suites_ok); + + /* run the tests: */ + if (ret == 0) + ret = odp_cunit_run(); + + return ret; }