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=-16.5 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, 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 4E72EC433E0 for ; Tue, 22 Dec 2020 03:04:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 144F222B43 for ; Tue, 22 Dec 2020 03:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725875AbgLVDEB (ORCPT ); Mon, 21 Dec 2020 22:04:01 -0500 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:56121 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725869AbgLVDEB (ORCPT ); Mon, 21 Dec 2020 22:04:01 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=haoxu@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0UJP3jDe_1608606197; Received: from B-25KNML85-0107.local(mailfrom:haoxu@linux.alibaba.com fp:SMTPD_---0UJP3jDe_1608606197) by smtp.aliyun-inc.com(127.0.0.1); Tue, 22 Dec 2020 11:03:17 +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> Message-ID: <87b3001f-0984-3890-269b-1a069704e374@linux.alibaba.com> Date: Tue, 22 Dec 2020 11:03:17 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <12018281-f8d4-7a67-3ffc-49d6a1c721b8@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/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 >> 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 >>