From patchwork Tue May 17 13:04:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 67956 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2074580qge; Tue, 17 May 2016 06:26:49 -0700 (PDT) X-Received: by 10.55.192.209 with SMTP id v78mr1471006qkv.122.1463491609166; Tue, 17 May 2016 06:26:49 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n138si2184312qhc.119.2016.05.17.06.26.48; Tue, 17 May 2016 06:26:49 -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 97D86617A2; Tue, 17 May 2016 13:26:48 +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 AAFF86178A; Tue, 17 May 2016 13:15:10 +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 EBDC061808; Tue, 17 May 2016 13:14:59 +0000 (UTC) Received: from mail-lf0-f46.google.com (mail-lf0-f46.google.com [209.85.215.46]) by lists.linaro.org (Postfix) with ESMTPS id 291B761789 for ; Tue, 17 May 2016 13:05:19 +0000 (UTC) Received: by mail-lf0-f46.google.com with SMTP id j8so6494985lfd.2 for ; Tue, 17 May 2016 06:05:19 -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=+m6xQDBfV/ufeRBv3htxY85N0AL4ysjiAviq+HyOvng=; b=aAA/J5rNj7pKSbdtBcqpH3bhhFVB6DEnm+K9nHYTuZBDDxHUMbCSXWEApn8Hi1Cy0M tIZj1eBFzlQiPsG9w5yPhz2laI7dvs3o5LAdDmwoXczxM5CkpqRDoxoZApp/wTbZgJQ5 NON3IKxC7p6Hbf6WL8wuO8h71LeCEuXXvD6rigjB6Z4OYId80FF8GF7Rcv97d40iRw4U xOa/YNVY5vq0JMdF714xP9QMcbhOj1lCViP6LP0oocAPIENcNY2YDbKqQ5kAvPtQArVa vKt1bYNIILa4yeXAdlNXcYztsl98xJ4IHUwMEIKIoF91SHtLq6HYm3bBC6HvkWF91TZD I83A== X-Gm-Message-State: AOPr4FVxC+9ARVfcnh8gBqVaeym/Wm73+f4PhtLmN+a90kzWGP4paJLvyWllmTneS3O6L4K66q4= X-Received: by 10.25.18.96 with SMTP id h93mr472222lfi.18.1463490318050; Tue, 17 May 2016 06:05:18 -0700 (PDT) Received: from localhost.localdomain (c-83-233-90-46.cust.bredband2.com. [83.233.90.46]) by smtp.gmail.com with ESMTPSA id q1sm506536lbo.4.2016.05.17.06.05.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 May 2016 06:05:17 -0700 (PDT) From: Christophe Milard To: lng-odp@lists.linaro.org, brian.brooks@linaro.org, mike.holmes@linaro.org Date: Tue, 17 May 2016 15:04:16 +0200 Message-Id: <1463490282-23277-10-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1463490282-23277-1-git-send-email-christophe.milard@linaro.org> References: <1463490282-23277-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv7 09/35] validation: pktio: adding command line argument parsing 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" As the test itself does not have specific args, it just calls the cunit_common parsing function to pick up cunit_common and helpers arguments. Signed-off-by: Christophe Milard --- platform/linux-generic/test/pktio/pktio_run | 21 ++++++++++++++++++--- platform/linux-generic/test/pktio/pktio_run_dpdk | 17 ++++++++++++++++- platform/linux-generic/test/pktio/pktio_run_netmap | 5 ++++- platform/linux-generic/test/pktio/pktio_run_pcap | 5 ++++- platform/linux-generic/test/pktio/pktio_run_tap | 6 +++++- test/validation/pktio/pktio.c | 10 ++++++++-- test/validation/pktio/pktio.h | 2 +- test/validation/pktio/pktio_main.c | 4 ++-- 8 files changed, 58 insertions(+), 12 deletions(-) diff --git a/platform/linux-generic/test/pktio/pktio_run b/platform/linux-generic/test/pktio/pktio_run index 7029ab2..4086fc2 100755 --- a/platform/linux-generic/test/pktio/pktio_run +++ b/platform/linux-generic/test/pktio/pktio_run @@ -6,6 +6,15 @@ # SPDX-License-Identifier: BSD-3-Clause # +# Proceed the pktio tests. This script expects at least one argument: +# setup) setup the pktio test environment +# cleanup) cleanup the pktio test environment +# run) run the pktio tests (setup, run, cleanup) +# extra arguments are passed unchanged to the test itself (pktio_main) +# Without arguments, "run" is assumed and no extra argument is passed to the +# test (legacy mode). +# + # directories where pktio_main binary can be found: # -in the validation dir when running make check (intree or out of tree) # -in the script directory, when running after 'make install', or @@ -59,7 +68,7 @@ run_test() if [ "$disabletype" != "SKIP" ]; then export ODP_PKTIO_DISABLE_SOCKET_${distype}=y fi - pktio_main${EXEEXT} + pktio_main${EXEEXT} $* if [ $? -ne 0 ]; then ret=1 fi @@ -75,7 +84,7 @@ run_test() run() { echo "pktio: using 'loop' device" - pktio_main${EXEEXT} + pktio_main${EXEEXT} $* loop_ret=$? # need to be root to run tests with real interfaces @@ -103,8 +112,14 @@ run() exit $ret } -case "$1" in +if [ $# > 0]; then + action=$1 + shift +fi + +case "$action" in setup) setup_pktio_env ;; cleanup) cleanup_pktio_env ;; + run) run ;; *) run ;; esac diff --git a/platform/linux-generic/test/pktio/pktio_run_dpdk b/platform/linux-generic/test/pktio/pktio_run_dpdk index 50e910a..1a1efac 100755 --- a/platform/linux-generic/test/pktio/pktio_run_dpdk +++ b/platform/linux-generic/test/pktio/pktio_run_dpdk @@ -6,6 +6,15 @@ # SPDX-License-Identifier: BSD-3-Clause # +# Proceed the pktio tests. This script expects at least one argument: +# setup) setup the pktio test environment +# cleanup) cleanup the pktio test environment +# run) run the pktio tests (setup, run, cleanup) +# extra arguments are passed unchanged to the test itself (pktio_main) +# Without arguments, "run" is assumed and no extra argument is passed to the +# test (legacy mode). +# + # directories where pktio_main binary can be found: # -in the validation dir when running make check (intree or out of tree) # -in the script directory, when running after 'make install', or @@ -46,7 +55,7 @@ run_test() { local ret=0 - pktio_main${EXEEXT} + pktio_main${EXEEXT} $* ret=$? if [ $ret -ne 0 ]; then echo "!!! FAILED !!!" @@ -73,8 +82,14 @@ run() run_test } +if [ $# > 0]; then + action=$1 + shift +fi + case "$1" in setup) setup_pktio_env ;; cleanup) cleanup_pktio_env ;; + run) run ;; *) run ;; esac diff --git a/platform/linux-generic/test/pktio/pktio_run_netmap b/platform/linux-generic/test/pktio/pktio_run_netmap index b7f2575..b651ea3 100755 --- a/platform/linux-generic/test/pktio/pktio_run_netmap +++ b/platform/linux-generic/test/pktio/pktio_run_netmap @@ -6,6 +6,9 @@ # SPDX-License-Identifier: BSD-3-Clause # +# any parameter passed as arguments to this script is passed unchanged to +# the test itself (pktio_main) + # directories where pktio_main binary can be found: # -in the validation dir when running make check (intree or out of tree) # -in the script directory, when running after 'make install', or @@ -45,7 +48,7 @@ run_test() { local ret=0 - pktio_main${EXEEXT} + pktio_main${EXEEXT} $* ret=$? if [ $ret -ne 0 ]; then diff --git a/platform/linux-generic/test/pktio/pktio_run_pcap b/platform/linux-generic/test/pktio/pktio_run_pcap index c130417..51716fb 100755 --- a/platform/linux-generic/test/pktio/pktio_run_pcap +++ b/platform/linux-generic/test/pktio/pktio_run_pcap @@ -6,6 +6,9 @@ # SPDX-License-Identifier: BSD-3-Clause # +# any parameter passed as arguments to this script is passed unchanged to +# the test itself (pktio_main) + # directories where pktio_main binary can be found: # -in the validation dir when running make check (intree or out of tree) # -in the script directory, when running after 'make install', or @@ -27,7 +30,7 @@ fi PCAP_FNAME=vald.pcap export ODP_PKTIO_IF0="pcap:out=${PCAP_FNAME}" export ODP_PKTIO_IF1="pcap:in=${PCAP_FNAME}" -pktio_main${EXEEXT} +pktio_main${EXEEXT} $* ret=$? rm -f ${PCAP_FNAME} exit $ret diff --git a/platform/linux-generic/test/pktio/pktio_run_tap b/platform/linux-generic/test/pktio/pktio_run_tap index 2b4f289..1150158 100755 --- a/platform/linux-generic/test/pktio/pktio_run_tap +++ b/platform/linux-generic/test/pktio/pktio_run_tap @@ -6,6 +6,10 @@ # SPDX-License-Identifier: BSD-3-Clause # + +# any parameter passed as arguments to this script is passed unchanged to +# the test itself (pktio_main) + # directories where pktio_main binary can be found: # -in the validation dir when running make check (intree or out of tree) # -in the script directory, when running after 'make install', or @@ -109,7 +113,7 @@ if [ $ret -ne 0 ]; then fi # Using ODP_WAIT_FOR_NETWORK to prevent fail if tap still not enabled in bridge -ODP_WAIT_FOR_NETWORK=yes pktio_main${EXEEXT} +ODP_WAIT_FOR_NETWORK=yes pktio_main${EXEEXT} $* ret=$? exit $ret diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 7b7c0a5..4dfdc44 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -2138,9 +2138,15 @@ odp_suiteinfo_t pktio_suites[] = { ODP_SUITE_INFO_NULL }; -int pktio_main(void) +int pktio_main(int argc, char *argv[]) { - int ret = odp_cunit_register(pktio_suites); + int ret; + + /* parse common options: */ + if (odp_cunit_parse_options(argc, argv)) + return -1; + + ret = odp_cunit_register(pktio_suites); if (ret == 0) ret = odp_cunit_run(); diff --git a/test/validation/pktio/pktio.h b/test/validation/pktio/pktio.h index 5ff20f6..8131d05 100644 --- a/test/validation/pktio/pktio.h +++ b/test/validation/pktio/pktio.h @@ -59,6 +59,6 @@ int pktio_suite_init_unsegmented(void); extern odp_suiteinfo_t pktio_suites[]; /* main test program: */ -int pktio_main(void); +int pktio_main(int argc, char *argv[]); #endif diff --git a/test/validation/pktio/pktio_main.c b/test/validation/pktio/pktio_main.c index dca041c..2928e1b 100644 --- a/test/validation/pktio/pktio_main.c +++ b/test/validation/pktio/pktio_main.c @@ -6,7 +6,7 @@ #include "pktio.h" -int main(void) +int main(int argc, char *argv[]) { - return pktio_main(); + return pktio_main(argc, argv); }