From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8248AC433E0 for ; Tue, 26 Jan 2021 06:27:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BF1F2075A for ; Tue, 26 Jan 2021 06:27:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728630AbhAZGZy (ORCPT ); Tue, 26 Jan 2021 01:25:54 -0500 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:34607 "EHLO out30-54.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730212AbhAZGTK (ORCPT ); Tue, 26 Jan 2021 01:19:10 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R331e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=haoxu@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0UMxNT9z_1611641905; Received: from B-25KNML85-0107.local(mailfrom:haoxu@linux.alibaba.com fp:SMTPD_---0UMxNT9z_1611641905) by smtp.aliyun-inc.com(127.0.0.1); Tue, 26 Jan 2021 14:18:25 +0800 Subject: Re: [PATCH liburing] test: use a map to define test files / devices we need From: Hao Xu To: Jens Axboe Cc: io-uring@vger.kernel.org, Joseph Qi References: <1607430489-10020-1-git-send-email-haoxu@linux.alibaba.com> <12018281-f8d4-7a67-3ffc-49d6a1c721b8@linux.alibaba.com> <87b3001f-0984-3890-269b-1a069704e374@linux.alibaba.com> Message-ID: <81cf9b02-a6e6-6b9e-3053-a5a34d3cffb6@linux.alibaba.com> Date: Tue, 26 Jan 2021 14:18:25 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <87b3001f-0984-3890-269b-1a069704e374@linux.alibaba.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org 在 2020/12/22 上午11:03, Hao Xu 写道: > 在 2020/12/15 上午10:44, Hao Xu 写道: >> 在 2020/12/8 下午8:28, Hao Xu 写道: >> ping... > Hi Jens, > I'm currently develop a test which need a device arg, so I > leverage TEST_FILES, I found it may be better to form > TEST_FILES as a key-value structure. > Thanks && Regards, > Hao ping again.. >>> Different tests need different files / devices, use a map to indicate >>> what each test need. >>> >>> Signed-off-by: Hao Xu >>> --- >>> >>> the former implementation use a array for the global list TEST_FILES, >>> which may causes this: >>>     TEST_FILES="dev0 dev1" >>>     dev0 required by test0 >>>     dev1 required by test1 >>> In the loop, we run the test for each $dev, which >>> makes and run, these are not expected. >>> Currently I see that statx.c accept argv[1] as a file_name, if someone >>> writes another test which defines a device(say nvme0n1) in TEST_FILES, >>> it may cause issues. >>> >>>   test/config      |  2 +- >>>   test/runtests.sh | 13 ++++++------- >>>   2 files changed, 7 insertions(+), 8 deletions(-) >>> >>> diff --git a/test/config b/test/config >>> index cab270359155..1bd9b40207bb 100644 >>> --- a/test/config >>> +++ b/test/config >>> @@ -4,4 +4,4 @@ >>>   # TEST_EXCLUDE="" >>>   # >>>   # Define raw test devices (or files) for test cases, if any >>> -# TEST_FILES="/dev/nvme0n1p2 /data/file" >>> +# declare -A TEST_FILES=() >>> diff --git a/test/runtests.sh b/test/runtests.sh >>> index fa240f205542..1a6905b42768 100755 >>> --- a/test/runtests.sh >>> +++ b/test/runtests.sh >>> @@ -5,10 +5,10 @@ RET=0 >>>   TIMEOUT=60 >>>   DMESG_FILTER="cat" >>>   TEST_DIR=$(dirname $0) >>> -TEST_FILES="" >>>   FAILED="" >>>   SKIPPED="" >>>   MAYBE_FAILED="" >>> +declare -A TEST_FILES >>>   # Only use /dev/kmsg if running as root >>>   DO_KMSG="1" >>> @@ -17,7 +17,7 @@ DO_KMSG="1" >>>   # Include config.local if exists and check TEST_FILES for valid >>> devices >>>   if [ -f "$TEST_DIR/config.local" ]; then >>>       . $TEST_DIR/config.local >>> -    for dev in $TEST_FILES; do >>> +    for dev in ${TEST_FILES[@]}; do >>>           if [ ! -e "$dev" ]; then >>>               echo "Test file $dev not valid" >>>               exit 1 >>> @@ -109,11 +109,10 @@ run_test() >>>   # Run all specified tests >>>   for tst in $TESTS; do >>> -    run_test $tst >>> -    if [ ! -z "$TEST_FILES" ]; then >>> -        for dev in $TEST_FILES; do >>> -            run_test $tst $dev >>> -        done >>> +    if [ ! -n "${TEST_FILES[$tst]}" ]; then >>> +        run_test $tst >>> +    else >>> +        run_test $tst ${TEST_FILES[$tst]} >>>       fi >>>   done >>>