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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90354C30626 for ; Thu, 17 Aug 2023 14:48:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1080694002E; Thu, 17 Aug 2023 10:48:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B7EE940009; Thu, 17 Aug 2023 10:48:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC1D494002E; Thu, 17 Aug 2023 10:48:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D992D940009 for ; Thu, 17 Aug 2023 10:48:00 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9A9AE1407CD for ; Thu, 17 Aug 2023 14:48:00 +0000 (UTC) X-FDA: 81133876320.26.AFB3D2D Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf01.hostedemail.com (Postfix) with ESMTP id 7D6F840011 for ; Thu, 17 Aug 2023 14:47:58 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of andre.przywara@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=andre.przywara@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692283678; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sjb6wn7ZsTbahFKMLvlt+kipirbiriVRVT4HR11T3ic=; b=uP69TfM0AXNseVDYUF6XAcZWGdKVceJ5P5XOO+/fSeF26vWuGHdIOydAh33Tr8NylAhDEm 8SaAguXbxIQhu/FhRxpy7/7oajTqpYLAq1PnVGfhc7HixA7AOccvM/EoQySFcVvn2bCseu BcfCQXkRkaI4/v6ZMFH2rK4bcsfgvl4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692283678; a=rsa-sha256; cv=none; b=VN1AeMQabPQt5g6wTCAdDKf2Ttn0TS9XhTVMkRL26KZfngqY+pTCafedKu/072RxZV9TSY YnB9K7dp0aBg3jAwY3RX8OtanLDdYSbyXoVp4D7naS2U1G5khAI2aJntef2WPIKnJ/UZGm Iefk4HuScg+v+hhZk+EbEKi9nNnUM8o= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of andre.przywara@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=andre.przywara@arm.com; dmarc=pass (policy=none) header.from=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5E2A61515; Thu, 17 Aug 2023 07:48:38 -0700 (PDT) Received: from donnerap.manchester.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4E3903F793; Thu, 17 Aug 2023 07:47:56 -0700 (PDT) Date: Thu, 17 Aug 2023 15:47:54 +0100 From: Andre Przywara To: Shuah Khan Cc: Shuah Khan , Nhat Pham , Johannes Weiner , linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] selftests: cachestat: test for cachestat availability Message-ID: <20230817154754.278218ae@donnerap.manchester.arm.com> In-Reply-To: <59c0fcd1-a1f2-de37-c94d-76687934acd5@linuxfoundation.org> References: <20230815155612.2535947-1-andre.przywara@arm.com> <20230815155612.2535947-4-andre.przywara@arm.com> <59c0fcd1-a1f2-de37-c94d-76687934acd5@linuxfoundation.org> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 7D6F840011 X-Rspam-User: X-Stat-Signature: y6pm1bkk8frbb85dhzz8nurcuarr1e4r X-Rspamd-Server: rspam03 X-HE-Tag: 1692283678-15746 X-HE-Meta: U2FsdGVkX19rEXOcJmv/sdHu6rzoKVr4Ho9/HFxoBaL54z0oq/4bYx+Uvn/g8R7dyA7Susz5UdPX8F+sYkEPGkyAwVFAgndhmmLZsuGDxvComx/YYOIXpACwQr95W2ShULSbhSZ31Zr19hbsbygXJEH3QPVtHAf+PXJXaH6P2IeZkKaUhpVw+IZJ/4lSbThH8gIFarPZvbBJOTA7wOF6vIYJ6lERqNch02/sAwozRmjKoZoepujqzw0EYiCu40ewNwWTWOGUf57d2LfqqU0Dwk3KqHvIpvvfiOmWg1Hh7jQLcc/SV1BsK81i1P4Jsa8EyOu9zTXNb8F3YgOIThLVQqulnm8VSbz88+j4cnJy6OvgBBQv4Tos6YGdMzSoPVt4jpftqYoFcoWnwXvDXmcf44ULsgz2riXcb9+m+TtW2x8dXwo+Ga35lxwt9NZgBbOzD8Um9wlZiLQRWrhE7E+7BAhvPmNIQ6r+8TooPm9EdfNJxiMAqGr90xBoQcco6znW4DuOlAIzmAxargvwMq6eGUiRmf7Rrb4bsWaavmY0DLkYDCqsMSl+Jm4kHIvajrof1Pam1ysnPDdnAys1kF0gTGQ8nLZV+bF0x7KFOtnpSs8Lx8+bbktvcjLMDfZLT/GEQTqgRmBIsP9sZPgsc6FsPlDJqYuNTtPz+dXgiwb67Bp44WEFlvK7gHm/8GQgjNBtBx2urAmueQCi123m8U0Cjma8hlrsI3Rf+JFd7IOsaJJFKJr1HFstSJH6aMTRwulpq40/DF7o/a+iS/vSDNRf8HobA0cHJ3PuT7sKZah5WDNakNS8V5JHEPmukF6MCQ5h8r8U/hSEQldOvkfx+TxS4OhCX5LZrlmGQbuTWvRUeEDYgNni1vlwrDxckVae6X9PhSB4Vz2inN5S7J/ZzAuoyg1tulRt6vNj4vLjO4w+r91XRDzXcL5fAEJz5gmTkVTGQspUvypEIMGspMK8xkj CTSiBpaw 2UqBrF6gpD25FtQVnBOzuxlkdoz8x8w5lCdUTzlmWU7OFNkRmfFUyNJzRVDfyqNeKo/ANzzq3XWdbdSrutFMARz3d/OVIguNIaLy8c2rnX6iNCFpJ0K2YdU1KkvB+6lt2zzvguA8A51JhlFMLQWMijHP0QrDrlJ0Lqkv8dreeHqF4WgKX4KRZPoUon4YV6sC+zifoKpjS6momk8hEbYBVTpki3/4+Dl4jxQ/OVCOjRjGrtH4XUG3uygiAFDLA3zkR/gIX1QxM99oKIV8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 16 Aug 2023 11:11:49 -0600 Shuah Khan wrote: Hi, > On 8/15/23 09:56, Andre Przywara wrote: > > As cachestat is a new syscall, it won't be available on older kernels, > > for instance those running on a build machine. In this case, a run > > reports all tests as "not ok" at the moment. > > > > Test for the cachestat syscall availability first, before doing further > > tests, and bail out early with a TAP SKIP comment. > > > > This also uses the opportunity to add the proper TAP headers, and add > > one check for the syscall error handling (illegal file descriptor). > > > > Signed-off-by: Andre Przywara > > --- > > .../selftests/cachestat/test_cachestat.c | 22 ++++++++++++++++++- > > 1 file changed, 21 insertions(+), 1 deletion(-) > > > > diff --git a/tools/testing/selftests/cachestat/test_cachestat.c b/tools/testing/selftests/cachestat/test_cachestat.c > > index a5a4ac8dcb76c..77620e7ecf562 100644 > > --- a/tools/testing/selftests/cachestat/test_cachestat.c > > +++ b/tools/testing/selftests/cachestat/test_cachestat.c > > @@ -15,6 +15,8 @@ > > > > #include "../kselftest.h" > > > > +#define NR_TESTS 8 > > + > > static const char * const dev_files[] = { > > "/dev/zero", "/dev/null", "/dev/urandom", > > "/proc/version", "/proc" > > @@ -235,7 +237,25 @@ bool test_cachestat_shmem(void) > > > > int main(void) > > { > > - int ret = 0; > > + int ret; > > + > > + ksft_print_header(); > > + > > + ret = syscall(__NR_cachestat, -1, NULL, NULL, 0); > > + if (ret == -1 && errno == ENOSYS) { > > + printf("1..0 # Skipped: cachestat syscall not available\n"); > > + return KSFT_SKIP; > What happens when other errors besides ENOSYS? The test shouldn't > continue. -1 is an illegal file descriptor, and this is checked below (still using the same ret and errno), but reported using the normal framework. This check above is done early, before we even announce the plan, so that we can skip *all* of the tests, since they don't make any sense when the syscall is not available at all. Does that make sense? Cheers, Andre > > > + } > > + > > + ksft_set_plan(NR_TESTS); > > + > > + if (ret == -1 && errno == EBADF) { > > + ksft_test_result_pass("bad file descriptor recognized\n"); > > + ret = 0; > > + } else { > > + ksft_test_result_fail("bad file descriptor ignored\n"); > > + ret = 1; > > + } > > > > for (int i = 0; i < 5; i++) { > > const char *dev_filename = dev_files[i]; > > thanks, > -- Shuah