Received: by 10.192.165.148 with SMTP id m20csp3408324imm; Mon, 7 May 2018 11:46:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoqZpUyn9X7a0bZfX7hES3yYlGddE7OFOjp2mgYnqKCnjpYDFsW3Nv3XbyeC5fdWHjQt2pk X-Received: by 2002:a24:9588:: with SMTP id m130-v6mr970284itd.58.1525718778598; Mon, 07 May 2018 11:46:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525718778; cv=none; d=google.com; s=arc-20160816; b=tnee22/uQ1NbQXQrBVARPkS67snlM7eZ7HYW6lgUyuEvKgpQH5YwxN2iPqXFm0moId uL8w4K23lY/rJrGF7muCTLl99VG2SWbIEGF5oyFGQT3JsA986B257+MyxFpX/qKAPGWT 3IefIgAzKGIjNYSx+GG9m1N+3PQJL77uG3iT1daoQr0mMS8+2gnPQl4/eHurMnTH6Frv 6KE9CULwefmJbA9CLrKpbNKTEqYs+rOg65ofomQcsHxyMb4z169scUS466zrhmCem6Br pC6YcQVJKvOKhPu5ohJQi4CTJB4v91xYHBk5tQ4G0w293iU73VsGkj3OHqUFEjdnWU/F 6M+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=XD+O/MbkwNjRVpyTcafBhk5XE9mQzKdcE6WOXmGzylg=; b=w9gAc4Dg+MEYd4MCLlC/uIwh0LTy59HEndps1HAItG3uf7cOXQgH0GSujju9wlbg53 lMiPPGCCFka6tT3SdJbVsED9W3xGbs036pnHcjtTeXsFG4IqfGbn8zwLHpQDb/UHA++A KojG+XD3pJdVjUOOs0XGCDaUJEBHZ8zX0UaLyz4+903QS1RbvLua5N1eVYljMR8qGP5a LAhEaInoGMbaPXaQO01iTUb8mrZckHNYcfO0gmQZl4ZhMPX0KiZ70fjkjf5q/XEOUTwn /NhvvxwThszaOFPXGvEZHD27EHnOjTOaoYMTNvskZfEbxTsz1CAwl9ZZEoYzo1CD5ynJ qSoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 12-v6si20602368iog.19.2018.05.07.11.46.04; Mon, 07 May 2018 11:46:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752811AbeEGSpn (ORCPT + 99 others); Mon, 7 May 2018 14:45:43 -0400 Received: from mailout.easymail.ca ([64.68.200.34]:59730 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752656AbeEGSpl (ORCPT ); Mon, 7 May 2018 14:45:41 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id DEED64123B; Mon, 7 May 2018 18:45:40 +0000 (UTC) Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo03-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rte07cczDTTp; Mon, 7 May 2018 18:45:40 +0000 (UTC) Received: from [192.168.1.87] (c-24-9-64-241.hsd1.co.comcast.net [24.9.64.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id 0D5B440F08; Mon, 7 May 2018 18:45:31 +0000 (UTC) Subject: Re: [PATCH 21/24] selftests: memfd: return Kselftest Skip code for skipped tests To: Mike Kravetz , akpm@linux-foundation.org, marcandre.lureau@redhat.com, lizhijian@cn.fujitsu.com Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan References: <20180505011328.32078-1-shuah@kernel.org> <20180505011328.32078-21-shuah@kernel.org> From: Shuah Khan Message-ID: Date: Mon, 7 May 2018 12:45:22 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/04/2018 07:52 PM, Mike Kravetz wrote: > On 05/04/2018 06:13 PM, Shuah Khan (Samsung OSG) wrote: >> When memfd test is skipped because of unmet dependencies and/or unsupported >> configuration, it returns non-zero value which is treated as a fail by the >> Kselftest framework. This leads to false negative result even when the test >> could not be run. >> >> Change it to return kselftest skip code when a test gets skipped to >> clearly report that the test could not be run. >> >> Added an explicit check for root user and return skip code. >> >> Kselftest framework SKIP code is 4 and the framework prints appropriate >> messages to indicate that the test is skipped. >> >> Signed-off-by: Shuah Khan (Samsung OSG) >> --- >> tools/testing/selftests/memfd/run_tests.sh | 10 +++++++++- >> 1 file changed, 9 insertions(+), 1 deletion(-) >> >> diff --git a/tools/testing/selftests/memfd/run_tests.sh b/tools/testing/selftests/memfd/run_tests.sh >> index c2d41ed81b24..88dc206a69b7 100755 >> --- a/tools/testing/selftests/memfd/run_tests.sh >> +++ b/tools/testing/selftests/memfd/run_tests.sh >> @@ -1,6 +1,14 @@ >> #!/bin/bash >> # please run as root >> >> +# Kselftest framework requirement - SKIP code is 4. >> +ksft_skip=4 >> + >> +if [ $UID != 0 ]; then >> + echo "Please run this test as root" >> + exit $ksft_skip >> +fi >> + >> # >> # Normal tests requiring no special resources >> # >> @@ -33,7 +41,7 @@ if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then >> echo $(( $hpages_needed + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages >> if [ $? -ne 0 ]; then >> echo "Please run this test as root" >> - exit 1 >> + exit $ksft_skip > > We now KNOW that we are running as root because of the check above. We > can delete this test, and rely on the later check to determine if the > number of huge pages was actually increased. Thanks for the review. Yesh this check can go away. > > How about this instead (untested)? > > Signed-off-by: Mike Kravetz > diff --git a/tools/testing/selftests/memfd/run_tests.sh b/tools/testing/selftests/memfd/run_tests.sh > index c2d41ed81b24..99a265a84e1d 100755 > --- a/tools/testing/selftests/memfd/run_tests.sh > +++ b/tools/testing/selftests/memfd/run_tests.sh > @@ -1,6 +1,14 @@ > #!/bin/bash > # please run as root > > +# Kselftest framework requirement - SKIP code is 4. > +ksft_skip=4 > + > +if [ $UID != 0 ]; then > + echo "Please run this test as root" > + exit $ksft_skip > +fi > + > # > # Normal tests requiring no special resources > # > @@ -31,10 +39,6 @@ if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then > > echo 3 > /proc/sys/vm/drop_caches > echo $(( $hpages_needed + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages > - if [ $? -ne 0 ]; then > - echo "Please run this test as root" > - exit 1 > - fi > while read name size unit; do > if [ "$name" = "HugePages_Free:" ]; then > freepgs=$size > @@ -53,7 +57,7 @@ if [ $freepgs -lt $hpages_test ]; then > fi > printf "Not enough huge pages available (%d < %d)\n" \ > $freepgs $needpgs > - exit 1 > + exit $ksft_skip > fi I thought about changing this to skip and wasn't sure since the test did run partially. Good to know this case can be classified as skip. I will make the suggested changes and send v2. thanks, -- Shuah