Received: by 10.192.165.148 with SMTP id m20csp703450imm; Fri, 4 May 2018 18:53:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZolSufVfr5ok7Kuvn9B1ATdCy2CXScz02/Es10jNf6L1zuWP2vvzTbNJzKJ/zkJYBnY52Zh X-Received: by 2002:a17:902:2ac3:: with SMTP id j61-v6mr29358025plb.224.1525485232196; Fri, 04 May 2018 18:53:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525485232; cv=none; d=google.com; s=arc-20160816; b=LAW36YAKOskSU9rSSswGsIvJMMr+rHN3ywJQ4Ilz1Hq2ZU+o9nrF+E9/Mbl5J8q/tO ZUEIN0oK1fbdMMnuPaNlm0tb4IBYJxOqPeCHE2y8ys/3ugdw8aKzsgbvVZ32s1YlfdkV lTRrLggSfF4hP7NDY9fWl0ecSLwj3Q+JKU815ehp+KpbjyFoCiTGxK6y5Km5YZg75muh epz+1nO8l10e6lMi0/ZXIn16leq6XbEgV1Prv38cCxqhA+DLbYuEoh4R7sSVbHYFbBtI JZnr/KrE+49d9Xiv/x2KL8PLT2ry+Tu9iOn4FbbRXoXBb7sShRFp8SOPNwFiqZhdCYFa sMMQ== 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:dkim-signature :arc-authentication-results; bh=RtxCQXarNfzMiea/avLigeROkaouAXUzBTnJRr/VJSo=; b=Bv+MpClEBS9thO2CxEuUVCbe0AFSmi2hlxzEvHSY60MukfxvF83dkmgocjt4XE39b1 bNhlHOcFYKwYKTE07ZSF+Op3fePYK1NomMq67Cd9SCPUZLiTzbG2K6sRkFeTsp0DoaGH aQa31bn8MwbkWHbZ+DltakzPahOZOhY53E/tgvgstKF0kwx59WLEsdEdWNMC29K77QkE PmnGl9GInn3uPVmwpz9/qQW1NPcSEYNDKlWQ/efJuFkgQfcEt8ZQxCkRMxNh/zOAbkyc 7uvSlNoQlxnS6sq6SiT+AXZP54YQQ5JGY2GeItkm0yukDYdpQ62OMwaHJbzCf9Jz2n8g ZVCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=I/p7/eQG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h17si647253pfn.150.2018.05.04.18.53.37; Fri, 04 May 2018 18:53:52 -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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=I/p7/eQG; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751899AbeEEBx0 (ORCPT + 99 others); Fri, 4 May 2018 21:53:26 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:33662 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751751AbeEEBxY (ORCPT ); Fri, 4 May 2018 21:53:24 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w451o5cj153995; Sat, 5 May 2018 01:52:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=RtxCQXarNfzMiea/avLigeROkaouAXUzBTnJRr/VJSo=; b=I/p7/eQGUHkYJMfKxuW0/vSz0UUi/h4vLie/XJ3T5FgSnIQH8yJnwguct/BC5QWJ/pAi v3Oxp/f14nKssppGi/DbvUvmwNrsX7JSynWMBJuVHoegCuSp+Lae9ilx++ER0dQBuImi AhoUFv8nJmRITdwWuV9QC2W8bFv+1MQnlhrckYrjfLkhZzR5nDL6nJf8M/+D9osblpPU haQFR1bCX/KNYVgKc9n8tGZHlNjdGijLt70oVD1vco76TVuVLPjblfEZFKww5FQGkpfo XJK4RsFrozAjq8KRHC8FP85iVDSlXgevSfHY5cThdQju+Ew5sZnjblV1T7NsyiDklO53 KA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2hmgxg88ky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 05 May 2018 01:52:59 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w451qxMj015674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 5 May 2018 01:52:59 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w451qw8V022878; Sat, 5 May 2018 01:52:58 GMT Received: from [192.168.1.164] (/50.38.38.67) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 04 May 2018 18:52:58 -0700 Subject: Re: [PATCH 21/24] selftests: memfd: return Kselftest Skip code for skipped tests To: "Shuah Khan (Samsung OSG)" , akpm@linux-foundation.org, marcandre.lureau@redhat.com, lizhijian@cn.fujitsu.com Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180505011328.32078-1-shuah@kernel.org> <20180505011328.32078-21-shuah@kernel.org> From: Mike Kravetz Message-ID: Date: Fri, 4 May 2018 18:52:57 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180505011328.32078-21-shuah@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8883 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805050013 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 #