From patchwork Wed Feb 16 02:26:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaopeng Tan X-Patchwork-Id: 12747861 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22B52C433FE for ; Wed, 16 Feb 2022 02:29:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245668AbiBPC3P (ORCPT ); Tue, 15 Feb 2022 21:29:15 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:36416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbiBPC3O (ORCPT ); Tue, 15 Feb 2022 21:29:14 -0500 X-Greylist: delayed 63 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 15 Feb 2022 18:29:02 PST Received: from esa6.hc1455-7.c3s2.iphmx.com (esa6.hc1455-7.c3s2.iphmx.com [68.232.139.139]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95D32F4D30; Tue, 15 Feb 2022 18:29:02 -0800 (PST) IronPort-SDR: O71LzE2HZ2rK+V6H6KRTZDKR9c+9VzwtLs5r4eBl/lqnFWnyp/dJaNtvVF8zOMlsbHYoWfaup2 gn2IZiHkPQJU7ArbXDb3JJJMm9+blEVR5Vd23o7jqAcxn44cs6zih0w/9pxbDfeX8BFqsmpVqL bDKG9qNO5FXf4nD4VJkJwF0MCS4IvUelKOSzqkCS5T6rWeaPeu8DdYWuwJ4T87Ro3CcPN404Fu vkFoTx1fKGJHuqhYabIsXfPDX0Fe7EEOa5OWNOwD7CrnClPh35BbHluF4qQs3uI6o8HT4E8G1D C6DO5/RhVwW2r9vJiKPfErcl X-IronPort-AV: E=McAfee;i="6200,9189,10259"; a="63437440" X-IronPort-AV: E=Sophos;i="5.88,371,1635174000"; d="scan'208";a="63437440" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa6.hc1455-7.c3s2.iphmx.com with ESMTP; 16 Feb 2022 11:29:00 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id BDADE97F0C; Wed, 16 Feb 2022 11:28:58 +0900 (JST) Received: from yto-om4.fujitsu.com (yto-om4.o.css.fujitsu.com [10.128.89.165]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 0431FD9973; Wed, 16 Feb 2022 11:28:58 +0900 (JST) Received: from cn-r05-10.example.com (n3235113.np.ts.nmh.cs.fujitsu.co.jp [10.123.235.113]) by yto-om4.fujitsu.com (Postfix) with ESMTP id C42B94007E8D1; Wed, 16 Feb 2022 11:28:57 +0900 (JST) From: Shaopeng Tan To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, tan.shaopeng@jp.fujitsu.com Subject: [PATCH v3 5/5] selftests/resctrl: Fix resctrl_tests' return code to work with selftest framework Date: Wed, 16 Feb 2022 11:26:41 +0900 Message-Id: <20220216022641.2998318-6-tan.shaopeng@jp.fujitsu.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220216022641.2998318-1-tan.shaopeng@jp.fujitsu.com> References: <20220216022641.2998318-1-tan.shaopeng@jp.fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org In kselftest framework, if a sub test can not run by some reasons, the test result should be marked as SKIP rather than FAIL. Return KSFT_SKIP(4) instead of KSFT_FAIL(1) if resctrl_tests is not run as root or it is run on a test environment which does not support resctrl. - ksft_exit_fail_msg(): returns KSFT_FAIL(1) - ksft_exit_skip(): returns KSFT_SKIP(4) Signed-off-by: Shaopeng Tan Reviewed-by: Shuah Khan --- Some important feedbacks from v1&v2 are addressed as follows: - It is important to highlight that a skipped test is marked as successful to not unnecessarily report a feature failure when there actually is a failure in the test environment. => I highligted this content in changelog as follows. "In kselftest framework, if a test is not run by some reason, the test result is marked as SKIP rather than FAIL." - The subject line can be made more succinct while the details are moved to the commit message. => I made subject line succinct and moved the details to changelog. - How changing ksft_exit_fail_msg() to ksft_exit_skip() accomplishes the goal of unifying the return code. => In changelog, I explained why return code KSFT_SKIP(4) is needed in kselftest framework and the return code of each function. tools/testing/selftests/resctrl/resctrl_tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 973f09a66e1e..3be0895c492b 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -205,7 +205,7 @@ int main(int argc, char **argv) * 2. We execute perf commands */ if (geteuid() != 0) - return ksft_exit_fail_msg("Not running as root, abort testing.\n"); + return ksft_exit_skip("Not running as root, abort testing.\n"); /* Detect AMD vendor */ detect_amd(); @@ -235,7 +235,7 @@ int main(int argc, char **argv) sprintf(bm_type, "fill_buf"); if (!check_resctrlfs_support()) - return ksft_exit_fail_msg("resctrl FS does not exist\n"); + return ksft_exit_skip("resctrl FS does not exist\n"); filter_dmesg();