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, 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 CF1B6C4361B for ; Tue, 15 Dec 2020 02:45:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90DEA207CF for ; Tue, 15 Dec 2020 02:45:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726203AbgLOCpG (ORCPT ); Mon, 14 Dec 2020 21:45:06 -0500 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:54312 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726163AbgLOCpA (ORCPT ); Mon, 14 Dec 2020 21:45:00 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=haoxu@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0UIg9dND_1608000254; Received: from B-25KNML85-0107.local(mailfrom:haoxu@linux.alibaba.com fp:SMTPD_---0UIg9dND_1608000254) by smtp.aliyun-inc.com(127.0.0.1); Tue, 15 Dec 2020 10:44:14 +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> Message-ID: <12018281-f8d4-7a67-3ffc-49d6a1c721b8@linux.alibaba.com> Date: Tue, 15 Dec 2020 10:44:14 +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: <1607430489-10020-1-git-send-email-haoxu@linux.alibaba.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org ÔÚ 2020/12/8 ÏÂÎç8:28, Hao Xu дµÀ: ping... > 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 > >