Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1432868imm; Wed, 13 Jun 2018 20:36:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKI1yu+Z6eeYa0LqGHSkrrgRJv2sFV00kj1dSLCFHk0q06Kj/NMPs/XS1kYSgnt22SqK/Mg X-Received: by 2002:a63:9843:: with SMTP id l3-v6mr789568pgo.208.1528947413325; Wed, 13 Jun 2018 20:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528947413; cv=none; d=google.com; s=arc-20160816; b=JwBSO/2q8ZNwktLyMQ998Rwz5QOfKuWENr8DAKgudw2SJO6WtI/9uUrgz6fI/GtcBS 6PoT3KRqaF5WNNPztiJGZ8opLnfP2yF18cqSIXU+NbwnPXdhzWjM4QTfmnm/0Muhut9r wtEiU1hQMqwgGGNs4GdOTEP9Ib8aUGQ+HsvKkz8iWb/meJplZMURuPRkRSFXMHGIxsjP QSsiNOJJanabJ2Hz8D4lzqzhFRLDO2AZguTXbg8HyIYvEjgx7aD7UXortPmrvQ2OOUMY XYzB9Dn5N97fyZqZLjGHsvCK2zoNeOuVIXCY/bLPV7mmsIXoqTH3W3X78sFuDHJtxliw MKUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=mhrVEe8R3b2B90fc//aZ9ShOfzJH3e0c/udxL2c4CHc=; b=z5LVUERhcFNpFm1YY5dr4hWnysLMk7wZ5uBxqSm1CVLoXpBYZGmtx9z4Urbqma2/ED Pj+Zk2gJ338ZXo9ghnNoRAf3RSp8g1vYcmOs3hBcAVkj4+TuffQi1DpjWdXxEjRxjQZe M0p/uDhi9xmRZMYnY6M7saqNzHeuWAErU/lH170o9z7qjBlEpwYijUVu7uw+8QFaL1y4 eOkeBoGMm85bqE7I7/7WmCzq3vPk6loulmrkUG92HrdNVcyRhCEa9JXTu02Y/Bo6KA9r 5B0cpZINQX9PF/nkc05AZ8AO9FRIIfwAHoUzv6Aiv29cqX9c2RUgat+qPOMjAF143ohz 3hgg== 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 v69-v6si3518894pgb.609.2018.06.13.20.36.38; Wed, 13 Jun 2018 20:36:53 -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 S936004AbeFNDgN (ORCPT + 99 others); Wed, 13 Jun 2018 23:36:13 -0400 Received: from mailout.easymail.ca ([64.68.200.34]:36155 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935910AbeFNDgM (ORCPT ); Wed, 13 Jun 2018 23:36:12 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id B6CDB41057; Thu, 14 Jun 2018 03:36:11 +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 gRCewa33mMRw; Thu, 14 Jun 2018 03:36:11 +0000 (UTC) Received: from localhost.localdomain (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 BDD7540F9B; Thu, 14 Jun 2018 03:35:58 +0000 (UTC) From: "Shuah Khan (Samsung OSG)" To: shuah@kernel.org, arnd@arndb.de, akpm@linux-foundation.org, zhijianx.li@intel.com, aneesh.kumar@linux.vnet.ibm.com, aarcange@redhat.com, rppt@linux.vnet.ibm.com, prakash.sangappa@oracle.com Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selftests: vm: return Kselftest Skip code for skipped tests Date: Wed, 13 Jun 2018 21:35:57 -0600 Message-Id: <20180614033557.10191-1-shuah@kernel.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When vm test is skipped because of unmet dependencies and/or unsupported configuration, it exits with error 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. 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/vm/compaction_test.c | 4 +++- tools/testing/selftests/vm/mlock2-tests.c | 12 +++++++----- tools/testing/selftests/vm/run_vmtests | 5 ++++- tools/testing/selftests/vm/userfaultfd.c | 4 +++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/vm/compaction_test.c b/tools/testing/selftests/vm/compaction_test.c index 1097f04e4d80..bcec71250873 100644 --- a/tools/testing/selftests/vm/compaction_test.c +++ b/tools/testing/selftests/vm/compaction_test.c @@ -16,6 +16,8 @@ #include #include +#include "../kselftest.h" + #define MAP_SIZE 1048576 struct map_list { @@ -169,7 +171,7 @@ int main(int argc, char **argv) printf("Either the sysctl compact_unevictable_allowed is not\n" "set to 1 or couldn't read the proc file.\n" "Skipping the test\n"); - return 0; + return KSFT_SKIP; } lim.rlim_cur = RLIM_INFINITY; diff --git a/tools/testing/selftests/vm/mlock2-tests.c b/tools/testing/selftests/vm/mlock2-tests.c index 4997b9222cfa..637b6d0ac0d0 100644 --- a/tools/testing/selftests/vm/mlock2-tests.c +++ b/tools/testing/selftests/vm/mlock2-tests.c @@ -9,6 +9,8 @@ #include #include "mlock2.h" +#include "../kselftest.h" + struct vm_boundaries { unsigned long start; unsigned long end; @@ -303,7 +305,7 @@ static int test_mlock_lock() if (mlock2_(map, 2 * page_size, 0)) { if (errno == ENOSYS) { printf("Cannot call new mlock family, skipping test\n"); - _exit(0); + _exit(KSFT_SKIP); } perror("mlock2(0)"); goto unmap; @@ -412,7 +414,7 @@ static int test_mlock_onfault() if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) { if (errno == ENOSYS) { printf("Cannot call new mlock family, skipping test\n"); - _exit(0); + _exit(KSFT_SKIP); } perror("mlock2(MLOCK_ONFAULT)"); goto unmap; @@ -425,7 +427,7 @@ static int test_mlock_onfault() if (munlock(map, 2 * page_size)) { if (errno == ENOSYS) { printf("Cannot call new mlock family, skipping test\n"); - _exit(0); + _exit(KSFT_SKIP); } perror("munlock()"); goto unmap; @@ -457,7 +459,7 @@ static int test_lock_onfault_of_present() if (mlock2_(map, 2 * page_size, MLOCK_ONFAULT)) { if (errno == ENOSYS) { printf("Cannot call new mlock family, skipping test\n"); - _exit(0); + _exit(KSFT_SKIP); } perror("mlock2(MLOCK_ONFAULT)"); goto unmap; @@ -583,7 +585,7 @@ static int test_vma_management(bool call_mlock) if (call_mlock && mlock2_(map, 3 * page_size, MLOCK_ONFAULT)) { if (errno == ENOSYS) { printf("Cannot call new mlock family, skipping test\n"); - _exit(0); + _exit(KSFT_SKIP); } perror("mlock(ONFAULT)\n"); goto out; diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests index 22d564673830..88cbe5575f0c 100755 --- a/tools/testing/selftests/vm/run_vmtests +++ b/tools/testing/selftests/vm/run_vmtests @@ -2,6 +2,9 @@ # SPDX-License-Identifier: GPL-2.0 #please run as root +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + mnt=./huge exitcode=0 @@ -36,7 +39,7 @@ if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages if [ $? -ne 0 ]; then echo "Please run this test as root" - exit 1 + exit $ksft_skip fi while read name size unit; do if [ "$name" = "HugePages_Free:" ]; then diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index de2f9ec8a87f..7b8171e3128a 100644 --- a/tools/testing/selftests/vm/userfaultfd.c +++ b/tools/testing/selftests/vm/userfaultfd.c @@ -69,6 +69,8 @@ #include #include +#include "../kselftest.h" + #ifdef __NR_userfaultfd static unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size; @@ -1322,7 +1324,7 @@ int main(int argc, char **argv) int main(void) { printf("skip: Skipping userfaultfd test (missing __NR_userfaultfd)\n"); - return 0; + return KSFT_SKIP; } #endif /* __NR_userfaultfd */ -- 2.17.0