From patchwork Wed Sep 16 09:42:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 53723 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 6129A22DB2 for ; Wed, 16 Sep 2015 09:46:06 +0000 (UTC) Received: by wicuu12 with SMTP id uu12sf19084853wic.2 for ; Wed, 16 Sep 2015 02:46:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=epZj4nuxPhcW83vwotz+YFS4XHH6K3uowaQEKMuGt1w=; b=WflGucC+9x4BL4YPafjAa9XVrjfRWt8mnddlJqtwVjCkwJiu14nKnOTF4RiSzGo9Ou HFaY721zowjuNJE5N2NVOMiRm2OPSvLLx9vIEt0x12UPszGEkNmTbbuFS/4bmVDsTcu6 T9OE6+pB9ywc5gKgEHI2YWqnA5JARGrh8a1pxq8s+QE9i8IGqL6D0er7GUz1gRztdTQU TRYwOSloU5eperUbOFVPh0L/jnwqxhIYhFJuY/J4L+ositCWPKhPNzUzJQ0o165ZRf5A jBE7Ce+kzoOCqkaB6NE7XNmPV67URgX2TKsIEM9k0TFgAN6iNNMC54JIlQsqEZ7A/WlQ 4eOQ== X-Gm-Message-State: ALoCoQnBP/PcKGiQ0SB+KGCRFAko1kjdMJkYyqjXSqjNnAK3ei/QUfOJ+tm25ywODoc7JsoDeRJX X-Received: by 10.152.21.42 with SMTP id s10mr2310473lae.9.1442396765645; Wed, 16 Sep 2015 02:46:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.131 with SMTP id k3ls393120lah.20.gmail; Wed, 16 Sep 2015 02:46:05 -0700 (PDT) X-Received: by 10.112.77.197 with SMTP id u5mr25771284lbw.120.1442396765474; Wed, 16 Sep 2015 02:46:05 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id n5si10657303laf.41.2015.09.16.02.46.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Sep 2015 02:46:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by lagj9 with SMTP id j9so127009534lag.2 for ; Wed, 16 Sep 2015 02:46:05 -0700 (PDT) X-Received: by 10.112.146.104 with SMTP id tb8mr26106361lbb.35.1442396765071; Wed, 16 Sep 2015 02:46:05 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp2328853lbq; Wed, 16 Sep 2015 02:46:03 -0700 (PDT) X-Received: by 10.107.41.138 with SMTP id p132mr29480142iop.188.1442396763792; Wed, 16 Sep 2015 02:46:03 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n8si4670499igi.93.2015.09.16.02.46.03; Wed, 16 Sep 2015 02:46:03 -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; Received: by lists.linaro.org (Postfix, from userid 109) id 416CE610A6; Wed, 16 Sep 2015 09:46:03 +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, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED 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 BF3D862D2C; Wed, 16 Sep 2015 09:44:03 +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 3506B619BA; Wed, 16 Sep 2015 09:43:52 +0000 (UTC) Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by lists.linaro.org (Postfix) with ESMTPS id 6471C61585 for ; Wed, 16 Sep 2015 09:42:40 +0000 (UTC) Received: by wiclk2 with SMTP id lk2so62413041wic.1 for ; Wed, 16 Sep 2015 02:42:39 -0700 (PDT) X-Received: by 10.180.85.103 with SMTP id g7mr16477723wiz.93.1442396559585; Wed, 16 Sep 2015 02:42:39 -0700 (PDT) Received: from e106441.emea.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id kb5sm25580683wjc.17.2015.09.16.02.42.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Sep 2015 02:42:38 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Wed, 16 Sep 2015 10:42:01 +0100 Message-Id: <1442396523-18466-3-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1442396523-18466-1-git-send-email-stuart.haslam@linaro.org> References: <1442396523-18466-1-git-send-email-stuart.haslam@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 2/4] validation: add odp_cunit_update() to modify registered tests X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stuart.haslam@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Add an odp_cunit_update() function to allow some attributes of previously registered tests to be modified, such as whether it's active or not. Previously, registering and running tests was done in a single step; odp_cunit_run(testsuites); But this is now split; odp_cunit_register(testsuites); odp_cunit_update(testsuites_updates); odp_cunit_run(); The odp_cunit_update() is optional and none of the currently defined tests use it, so there's no functional change in this patch. Signed-off-by: Stuart Haslam --- test/validation/buffer/buffer.c | 7 +- test/validation/classification/classification.c | 7 +- test/validation/common/odp_cunit_common.c | 107 ++++++++++++++++++++++-- test/validation/common/odp_cunit_common.h | 11 ++- test/validation/cpumask/cpumask.c | 7 +- test/validation/crypto/crypto.c | 10 ++- test/validation/errno/errno.c | 7 +- test/validation/init/init.c | 29 ++++++- test/validation/packet/packet.c | 7 +- test/validation/pktio/pktio.c | 7 +- test/validation/pool/pool.c | 7 +- test/validation/queue/queue.c | 7 +- test/validation/random/random.c | 7 +- test/validation/scheduler/scheduler.c | 7 +- test/validation/shmem/shmem.c | 7 +- test/validation/synchronizers/synchronizers.c | 10 ++- test/validation/system/system.c | 7 +- test/validation/thread/thread.c | 7 +- test/validation/time/time.c | 7 +- test/validation/timer/timer.c | 7 +- 20 files changed, 245 insertions(+), 27 deletions(-) diff --git a/test/validation/buffer/buffer.c b/test/validation/buffer/buffer.c index 4600e59..257e95c 100644 --- a/test/validation/buffer/buffer.c +++ b/test/validation/buffer/buffer.c @@ -153,5 +153,10 @@ odp_suiteinfo_t buffer_suites[] = { int buffer_main(void) { - return odp_cunit_run(buffer_suites); + int ret = odp_cunit_register(buffer_suites); + + if (ret == 0) + odp_cunit_run(); + + return ret; } diff --git a/test/validation/classification/classification.c b/test/validation/classification/classification.c index b868c61..fe9a827 100644 --- a/test/validation/classification/classification.c +++ b/test/validation/classification/classification.c @@ -23,5 +23,10 @@ odp_suiteinfo_t classification_suites[] = { int classification_main(void) { - return odp_cunit_run(classification_suites); + int ret = odp_cunit_register(classification_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c index d63e87e..8b62370 100644 --- a/test/validation/common/odp_cunit_common.c +++ b/test/validation/common/odp_cunit_common.c @@ -164,16 +164,99 @@ static int cunit_register_suites(odp_suiteinfo_t testsuites[]) return 0; } +static int cunit_update_test(odp_suiteinfo_t *sinfo, + odp_testinfo_t *updated_tinfo) +{ + odp_testinfo_t *tinfo; + + for (tinfo = sinfo->pTests; tinfo->testinfo.pName; tinfo++) + if (strcmp(tinfo->testinfo.pName, + updated_tinfo->testinfo.pName) == 0) + break; + + if (!tinfo || !tinfo->testinfo.pName) + return -1; + + tinfo->check_active = updated_tinfo->check_active; + + return 0; +} + +static int cunit_update_suite(odp_suiteinfo_t *updated_sinfo) +{ + CU_pSuite suite; + CU_pTest test; + odp_suiteinfo_t *sinfo; + odp_testinfo_t *tinfo; + + /* find previously registered suite with matching name */ + for (sinfo = global_testsuites; sinfo->pName; sinfo++) + if (strcmp(sinfo->pName, updated_sinfo->pName) == 0) + break; + + if (!sinfo || !sinfo->pName) { + fprintf(stderr, "%s: unable to add new suite: %s\n", + __func__, updated_sinfo->pName); + return -1; + } + + /* lookup the associated CUnit suite */ + suite = CU_get_suite_by_name(sinfo->pName, CU_get_registry()); + if (!suite) { + fprintf(stderr, "%s: can't find registered suite %s\n", + __func__, sinfo->pName); + return CU_get_error(); + } + + sinfo->pInitFunc = updated_sinfo->pInitFunc; + sinfo->pCleanupFunc = updated_sinfo->pCleanupFunc; + + CU_set_suite_cleanupfunc(suite, updated_sinfo->pCleanupFunc); + + for (tinfo = updated_sinfo->pTests; tinfo->testinfo.pName; tinfo++) { + test = CU_get_test(suite, tinfo->testinfo.pName); + + if (test) { + CU_ErrorCode err = CU_set_test_func(test, + tinfo->testinfo.pTestFunc); + if (err != CUE_SUCCESS) + return -1; + + if (cunit_update_test(sinfo, tinfo) != 0) + return -1; + } else { + fprintf(stderr, "%s: unable to add new test: %s\n", + __func__, tinfo->testinfo.pName); + return -1; + } + } + + return 0; +} + /* - * Register test suites to be run via odp_cunit_run() + * Update suites/tests previously registered via odp_cunit_register(). + * + * Note that this is intended for modifying the properties of already + * registered suites/tests. New suites/tests can only be registered via + * odp_cunit_register(). */ -int odp_cunit_run(odp_suiteinfo_t testsuites[]) +int odp_cunit_update(odp_suiteinfo_t testsuites[]) { - int ret; + int ret = 0; + odp_suiteinfo_t *sinfo; - printf("\tODP API version: %s\n", odp_version_api_str()); - printf("\tODP implementation version: %s\n", odp_version_impl_str()); + for (sinfo = testsuites; sinfo->pName && ret == 0; sinfo++) + ret = cunit_update_suite(sinfo); + return ret; +} + +/* + * Register test suites to be run via odp_cunit_run() + */ +int odp_cunit_register(odp_suiteinfo_t testsuites[]) +{ /* call test executable init hook, if any */ if (global_init_term.global_init_ptr && ((*global_init_term.global_init_ptr)() != 0)) @@ -185,6 +268,20 @@ int odp_cunit_run(odp_suiteinfo_t testsuites[]) global_testsuites = testsuites; cunit_register_suites(testsuites); CU_set_fail_on_inactive(CU_FALSE); + + return 0; +} + +/* + * Run tests previously registered via odp_cunit_register() + */ +int odp_cunit_run(void) +{ + int ret; + + printf("\tODP API version: %s\n", odp_version_api_str()); + printf("\tODP implementation version: %s\n", odp_version_impl_str()); + CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); diff --git a/test/validation/common/odp_cunit_common.h b/test/validation/common/odp_cunit_common.h index 218146c..c689054 100644 --- a/test/validation/common/odp_cunit_common.h +++ b/test/validation/common/odp_cunit_common.h @@ -68,9 +68,16 @@ typedef struct { int numthrds; /**< no of pthreads to create */ } pthrd_arg; +/* register suites to be run via odp_cunit_run() */ +int odp_cunit_register(odp_suiteinfo_t testsuites[]); +/* update tests previously registered via odp_cunit_register() */ +int odp_cunit_update(odp_suiteinfo_t testsuites[]); +/* the function, called by module main(), to run the testsuites: */ +int odp_cunit_run(void); + /** create thread fro start_routine function */ -extern int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg); -extern int odp_cunit_thread_exit(pthrd_arg *); +int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg); +int odp_cunit_thread_exit(pthrd_arg *); /** * Global tests initialization/termination. diff --git a/test/validation/cpumask/cpumask.c b/test/validation/cpumask/cpumask.c index 37dee6a..bf5421e 100644 --- a/test/validation/cpumask/cpumask.c +++ b/test/validation/cpumask/cpumask.c @@ -101,5 +101,10 @@ odp_suiteinfo_t cpumask_suites[] = { int cpumask_main(void) { - return odp_cunit_run(cpumask_suites); + int ret = odp_cunit_register(cpumask_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/crypto/crypto.c b/test/validation/crypto/crypto.c index b2f9d96..9229cab 100644 --- a/test/validation/crypto/crypto.c +++ b/test/validation/crypto/crypto.c @@ -94,7 +94,15 @@ int crypto_term(void) int crypto_main(void) { + int ret; + odp_cunit_register_global_init(crypto_init); odp_cunit_register_global_term(crypto_term); - return odp_cunit_run(crypto_suites); + + ret = odp_cunit_register(crypto_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/errno/errno.c b/test/validation/errno/errno.c index 6196164..d0e2128 100644 --- a/test/validation/errno/errno.c +++ b/test/validation/errno/errno.c @@ -31,5 +31,10 @@ odp_suiteinfo_t errno_suites[] = { int errno_main(void) { - return odp_cunit_run(errno_suites); + int ret = odp_cunit_register(errno_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/init/init.c b/test/validation/init/init.c index d5ec333..a8a5640 100644 --- a/test/validation/init/init.c +++ b/test/validation/init/init.c @@ -53,12 +53,19 @@ static void odp_init_abort(void) int init_main_abort(void) { + int ret; + /* prevent default ODP init: */ odp_cunit_register_global_init(NULL); odp_cunit_register_global_term(NULL); /* run the tests: */ - return odp_cunit_run(init_suites_abort); + ret = odp_cunit_register(init_suites_abort); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } /* test ODP global init, with alternate log function */ @@ -109,12 +116,20 @@ static int odp_init_log(odp_log_level_e level __attribute__((unused)), int init_main_log(void) { + int ret; + /* 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: */ - return odp_cunit_run(init_suites_log); + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } /* test normal ODP global init */ @@ -141,10 +156,18 @@ odp_suiteinfo_t init_suites_ok[] = { int init_main_ok(void) { + int ret; + /* 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: */ - return odp_cunit_run(init_suites_ok); + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/packet/packet.c b/test/validation/packet/packet.c index 8a4f0a6..d9a543f 100644 --- a/test/validation/packet/packet.c +++ b/test/validation/packet/packet.c @@ -805,5 +805,10 @@ odp_suiteinfo_t packet_suites[] = { int packet_main(void) { - return odp_cunit_run(packet_suites); + int ret = odp_cunit_register(packet_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index bfcaace..118fe89 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -908,5 +908,10 @@ odp_suiteinfo_t pktio_suites[] = { int pktio_main(void) { - return odp_cunit_run(pktio_suites); + int ret = odp_cunit_register(pktio_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/pool/pool.c b/test/validation/pool/pool.c index 3de2714..bca210a 100644 --- a/test/validation/pool/pool.c +++ b/test/validation/pool/pool.c @@ -116,5 +116,10 @@ odp_suiteinfo_t pool_suites[] = { int pool_main(void) { - return odp_cunit_run(pool_suites); + int ret = odp_cunit_register(pool_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/queue/queue.c b/test/validation/queue/queue.c index 7d6de54..98da2ec 100644 --- a/test/validation/queue/queue.c +++ b/test/validation/queue/queue.c @@ -137,5 +137,10 @@ odp_suiteinfo_t queue_suites[] = { int queue_main(void) { - return odp_cunit_run(queue_suites); + int ret = odp_cunit_register(queue_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/random/random.c b/test/validation/random/random.c index a9a5a01..8ed5944 100644 --- a/test/validation/random/random.c +++ b/test/validation/random/random.c @@ -29,5 +29,10 @@ odp_suiteinfo_t random_suites[] = { int random_main(void) { - return odp_cunit_run(random_suites); + int ret = odp_cunit_register(random_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/scheduler/scheduler.c b/test/validation/scheduler/scheduler.c index 81653c4..684dba5 100644 --- a/test/validation/scheduler/scheduler.c +++ b/test/validation/scheduler/scheduler.c @@ -1149,5 +1149,10 @@ odp_suiteinfo_t scheduler_suites[] = { int scheduler_main(void) { - return odp_cunit_run(scheduler_suites); + int ret = odp_cunit_register(scheduler_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/shmem/shmem.c b/test/validation/shmem/shmem.c index 41ec725..5524b5c 100644 --- a/test/validation/shmem/shmem.c +++ b/test/validation/shmem/shmem.c @@ -88,5 +88,10 @@ odp_suiteinfo_t shmem_suites[] = { int shmem_main(void) { - return odp_cunit_run(shmem_suites); + int ret = odp_cunit_register(shmem_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/synchronizers/synchronizers.c b/test/validation/synchronizers/synchronizers.c index 595be74..96783fa 100644 --- a/test/validation/synchronizers/synchronizers.c +++ b/test/validation/synchronizers/synchronizers.c @@ -1212,6 +1212,14 @@ odp_suiteinfo_t synchronizers_suites[] = { int synchronizers_main(void) { + int ret; + odp_cunit_register_global_init(synchronizers_init); - return odp_cunit_run(synchronizers_suites); + + ret = odp_cunit_register(synchronizers_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/system/system.c b/test/validation/system/system.c index cf0ab0a..7dc2cc0 100644 --- a/test/validation/system/system.c +++ b/test/validation/system/system.c @@ -101,5 +101,10 @@ odp_suiteinfo_t system_suites[] = { int system_main(void) { - return odp_cunit_run(system_suites); + int ret = odp_cunit_register(system_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/thread/thread.c b/test/validation/thread/thread.c index b86ebd3..9ba8322 100644 --- a/test/validation/thread/thread.c +++ b/test/validation/thread/thread.c @@ -125,5 +125,10 @@ odp_suiteinfo_t thread_suites[] = { int thread_main(void) { - return odp_cunit_run(thread_suites); + int ret = odp_cunit_register(thread_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/time/time.c b/test/validation/time/time.c index f2c196c..41db0e9 100644 --- a/test/validation/time/time.c +++ b/test/validation/time/time.c @@ -75,5 +75,10 @@ odp_suiteinfo_t time_suites[] = { int time_main(void) { - return odp_cunit_run(time_suites); + int ret = odp_cunit_register(time_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; } diff --git a/test/validation/timer/timer.c b/test/validation/timer/timer.c index 02398f7..645dc58 100644 --- a/test/validation/timer/timer.c +++ b/test/validation/timer/timer.c @@ -544,5 +544,10 @@ odp_suiteinfo_t timer_suites[] = { int timer_main(void) { - return odp_cunit_run(timer_suites); + int ret = odp_cunit_register(timer_suites); + + if (ret == 0) + ret = odp_cunit_run(); + + return ret; }