From patchwork Fri May 20 16:30:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 68260 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp3853158qge; Fri, 20 May 2016 08:44:55 -0700 (PDT) X-Received: by 10.50.111.101 with SMTP id ih5mr3519303igb.81.1463759095806; Fri, 20 May 2016 08:44:55 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z18si5744699igp.57.2016.05.20.08.44.55; Fri, 20 May 2016 08:44:55 -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 4E318616F5; Fri, 20 May 2016 15:44:55 +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, 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 B76CD61812; Fri, 20 May 2016 15:33:51 +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 52CC0610DE; Fri, 20 May 2016 15:33:41 +0000 (UTC) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com [209.85.217.175]) by lists.linaro.org (Postfix) with ESMTPS id 783B6616F5 for ; Fri, 20 May 2016 15:32:10 +0000 (UTC) Received: by mail-lb0-f175.google.com with SMTP id h1so36542782lbj.3 for ; Fri, 20 May 2016 08:32:10 -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=wFYYgHd5cMJ+oFhKVlsk3W7MHF16az/ZVSHw+CDbZYw=; b=AjgjNR1YOl2zjz7Q9HBGlhIWlO2J9soo7l8fQGnM85yDUYuYeStWBJNDn/zkd3cKUQ Ijqj9T5p/uJZglPb++7lLb7aLLHvaiAfKEAo9I2Ugex+/zZp51e4zHk3K//Ywp3pPRqm D2r8BVGjCsFpyRKGeis6psLpltkkxil5ZwT/QbncLSQXBbYcJHX6hHajxQgmVJfLgipU sxTa3iKeDkH+QITaUqct0K1ZHVPcWToCDDQmuJjjKIDI1R+tRdNv7aKf45JbuQux80A2 q69B6PeBKEedWXHHuIaaVYiEtsy+bpMcXVqtQdayPH/wFSwbiV5yRhhiSzWpddqvqwSY f1tQ== X-Gm-Message-State: AOPr4FXxCCBHnn/3rTaJBmP1CT3L6pjnDReBxEstUteSEKRiwR3oba/TrbI2Pe6jA1wwpSuecrU= X-Received: by 10.112.219.195 with SMTP id pq3mr1373515lbc.33.1463758329235; Fri, 20 May 2016 08:32:09 -0700 (PDT) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-90-46.cust.bredband2.com. [83.233.90.46]) by smtp.gmail.com with ESMTPSA id tg1sm3348847lbb.7.2016.05.20.08.32.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 May 2016 08:32:08 -0700 (PDT) From: Christophe Milard To: maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Fri, 20 May 2016 18:30:25 +0200 Message-Id: <1463761851-37121-10-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1463761851-37121-1-git-send-email-christophe.milard@linaro.org> References: <1463761851-37121-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv9 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.sh | 21 ++++++++++++++++++--- platform/linux-generic/test/pktio/pktio_run_dpdk.sh | 17 ++++++++++++++++- .../linux-generic/test/pktio/pktio_run_netmap.sh | 5 ++++- platform/linux-generic/test/pktio/pktio_run_pcap.sh | 5 ++++- platform/linux-generic/test/pktio/pktio_run_tap.sh | 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.sh b/platform/linux-generic/test/pktio/pktio_run.sh index 7029ab2..1dc1f44 100755 --- a/platform/linux-generic/test/pktio/pktio_run.sh +++ b/platform/linux-generic/test/pktio/pktio_run.sh @@ -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.sh b/platform/linux-generic/test/pktio/pktio_run_dpdk.sh index 50e910a..fd552c6 100755 --- a/platform/linux-generic/test/pktio/pktio_run_dpdk.sh +++ b/platform/linux-generic/test/pktio/pktio_run_dpdk.sh @@ -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.sh b/platform/linux-generic/test/pktio/pktio_run_netmap.sh index b7f2575..b651ea3 100755 --- a/platform/linux-generic/test/pktio/pktio_run_netmap.sh +++ b/platform/linux-generic/test/pktio/pktio_run_netmap.sh @@ -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.sh b/platform/linux-generic/test/pktio/pktio_run_pcap.sh index c130417..51716fb 100755 --- a/platform/linux-generic/test/pktio/pktio_run_pcap.sh +++ b/platform/linux-generic/test/pktio/pktio_run_pcap.sh @@ -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.sh b/platform/linux-generic/test/pktio/pktio_run_tap.sh index 2b4f289..1150158 100755 --- a/platform/linux-generic/test/pktio/pktio_run_tap.sh +++ b/platform/linux-generic/test/pktio/pktio_run_tap.sh @@ -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 bd3c1c1..8f66880 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -2140,9 +2140,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); }