From patchwork Tue Feb 20 13:14:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Wieczor-Retman X-Patchwork-Id: 13564015 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A3C16A00B; Tue, 20 Feb 2024 13:14:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708434900; cv=none; b=gosQAP7weOVj2m5WO76jioszg7uu+aMDPqNpmigKaS5U2sNs5i7YcbBOSFRd5PrNjVhGaoN1vvgBalAeUIX1m0oLFIm24MhijVdaF/R0yYX9OZgjkA1H+8HGEXmibVK91qcOtU++jNbhB7JrwTHq+Qo1n6q+MFubcHhJLAOug1g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708434900; c=relaxed/simple; bh=Gi1VkP9GPyzQfNuuc0NAYEJ6mkbO6wyMOkVcf8T5EK0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e78Q/4bqnmSn/1nx+PMk3vzz84i+agPPhyDa7GTdNlNZwUjV7b3xCApWJCdcXcqpIurdHvirx7NGfxBeerjneevNycUR+TDMdhuxWNfns3P4H2ANLgoVYuzkv6hYgKMuR5ywQ9k1Y6CRIDBgWF4Y72JfANnUGjZNTYP/XCDfcFw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SpuCm5l/; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SpuCm5l/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708434899; x=1739970899; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gi1VkP9GPyzQfNuuc0NAYEJ6mkbO6wyMOkVcf8T5EK0=; b=SpuCm5l/UzBPYuTtJCHIITtY0oRYY+9ShbRu4wY+e1HS91sCzMLGRICm xsP+qDFo7uOlkAHqcEa6eprdwT+NcY1XWaBQQRFIjYUSy1MTJMUrjUUaZ ctlXsz9bj/0deMyzi3MXQ02I0ovJElgMkPXa+Gdq8BkmMJlhLIqMTZ2ZF jdix8u0qiet4YizJDItOlcXMGhqBEN9W6m00rowzQLSHlF+STuvTFnk2V gdfIw7+6ILHEuQzNQMjaqJA3lNzvYaoQZNgqKXy6oFXRx3Ogqdd/65bkW AD7FejfpsTgtHIV428ONECB/w8MikjwjT/K1IuMxMJ+6sgK1kiI/qrNTV A==; X-IronPort-AV: E=McAfee;i="6600,9927,10989"; a="2660614" X-IronPort-AV: E=Sophos;i="6.06,172,1705392000"; d="scan'208";a="2660614" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 05:14:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,172,1705392000"; d="scan'208";a="5130948" Received: from jmuniak-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.4.63]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 05:14:55 -0800 From: Maciej Wieczor-Retman To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 1/3] selftests/resctrl: Add cleanup function to test framework Date: Tue, 20 Feb 2024 14:14:32 +0100 Message-ID: <357fdb981c7dddcc474818f7bedb1f57a79e117c.1708434017.git.maciej.wieczor-retman@intel.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Resctrl selftests use very similar functions to cleanup after themselves. This creates a lot of code duplication. Also not being hooked to the test framework means that ctrl-c handler isn't aware of what test is currently running and executes all cleanups even though only one is needed. Add a function pointer to the resctrl_test struct and attach to it cleanup functions from individual tests. Signed-off-by: Maciej Wieczor-Retman --- tools/testing/selftests/resctrl/cat_test.c | 1 + tools/testing/selftests/resctrl/cmt_test.c | 1 + tools/testing/selftests/resctrl/mba_test.c | 1 + tools/testing/selftests/resctrl/mbm_test.c | 1 + tools/testing/selftests/resctrl/resctrl.h | 2 ++ 5 files changed, 6 insertions(+) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 24af8310288a..2d2f69d3e5b7 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -299,4 +299,5 @@ struct resctrl_test l3_cat_test = { .resource = "L3", .feature_check = test_resource_feature_check, .run_test = cat_run_test, + .cleanup = cat_test_cleanup, }; diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index dd5ca343c469..32ddee87e43d 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -178,4 +178,5 @@ struct resctrl_test cmt_test = { .resource = "L3", .feature_check = cmt_feature_check, .run_test = cmt_run_test, + .cleanup = cmt_test_cleanup, }; diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index da256d2dbe5c..7cc4067ce930 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -180,4 +180,5 @@ struct resctrl_test mba_test = { .vendor_specific = ARCH_INTEL, .feature_check = mba_feature_check, .run_test = mba_run_test, + .cleanup = mba_test_cleanup, }; diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 34879e7b71a0..071e2d3808a7 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -150,4 +150,5 @@ struct resctrl_test mbm_test = { .vendor_specific = ARCH_INTEL, .feature_check = mbm_feature_check, .run_test = mbm_run_test, + .cleanup = mbm_test_cleanup, }; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index c52eaf46f24d..0f49df4961ea 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -70,6 +70,7 @@ struct user_params { * @disabled: Test is disabled * @feature_check: Callback to check required resctrl features * @run_test: Callback to run the test + * @cleanup: Callback to cleanup after the test */ struct resctrl_test { const char *name; @@ -79,6 +80,7 @@ struct resctrl_test { bool (*feature_check)(const struct resctrl_test *test); int (*run_test)(const struct resctrl_test *test, const struct user_params *uparams); + void (*cleanup)(void); }; /* From patchwork Tue Feb 20 13:14:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Wieczor-Retman X-Patchwork-Id: 13564016 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF7DD6A330; Tue, 20 Feb 2024 13:15:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708434905; cv=none; b=J8QcGXICD19XRz5Dd6OXUnvvOzOyUIN/gQmkX4r4zbEj93HMHvcBdSyNXpqLzRPf40vNFpoRGXuTB1l6qzLf+9hd7oIWcWXMwxX19V135LA05gt1f9HusFYJ/U3Fk18OZWrA4TPhgskbPpt/1o5b1DuPA+VEoVyJjWFInZN2dDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708434905; c=relaxed/simple; bh=v3wRrQUnwDGEEcD6kai4bnghYWPZ35GmgQAO7Rp1/68=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Pmz0mmOIS+TOXI6SFk5E5oGSSg+ltlc8FBFDHosoQ9+WayyJoabxdBpiNO1w8P4MpyVFul78lfn5ABDZp12/g7q9SXRus+0C9y9Wqb1Orm6DRASLG5rQkPd3R/1OfZYkuTWpJZ1VPxxUtwcwHrVZc2r+UAtQA4euS+dHqvDv/kw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ke3pfWy1; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ke3pfWy1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708434904; x=1739970904; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v3wRrQUnwDGEEcD6kai4bnghYWPZ35GmgQAO7Rp1/68=; b=ke3pfWy1TLuoDDwQ1lR2mvxzr6ppA4Yqwl9tkMuH5d1Yk3+tvViJOED7 Aw7EPEuT5vw/6HaWvl0RX4evRkNnEAsVgUWhAZsfPogUSMN9ED75CWOrw zvYIcHCR7qhssYMNH7McYVcSMpVjpyg4uKMTUD5fkcSFf39yD7kvpNPs1 11aJovEHFlZNS1obJwLJH+Pt6EVkuNddunplvoxHEIaLlw4ByJ8aAlsrD CW7E9cigv1a3665WhWTpR3sVGHN63B95BHeWVKYrgcWOza5ZT89NHIFZx fhwUxltsLHe6rG+ufLkXHrV+t5uJDXMquMXSqlauWubBT/9zf/12u7bOf A==; X-IronPort-AV: E=McAfee;i="6600,9927,10989"; a="2660621" X-IronPort-AV: E=Sophos;i="6.06,172,1705392000"; d="scan'208";a="2660621" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 05:15:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,172,1705392000"; d="scan'208";a="5130974" Received: from jmuniak-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.4.63]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 05:15:01 -0800 From: Maciej Wieczor-Retman To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 2/3] selftests/resctrl: Simplify cleanup in ctrl-c handler Date: Tue, 20 Feb 2024 14:14:33 +0100 Message-ID: <8c4fcfb6b4e38a0f0e400be88ecf1af0d20e12e7.1708434017.git.maciej.wieczor-retman@intel.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Ctrl-c handler isn't aware of what test is currently running. Because of that it executes all cleanups even if they aren't necessary. Since the ctrl-c handler uses the sigaction system no parameters can be passed to it as function arguments. Add a global variable to make ctrl-c handler aware of the currently run test and only execute the correct cleanup callback. Signed-off-by: Maciej Wieczor-Retman --- tools/testing/selftests/resctrl/resctrl.h | 2 ++ .../testing/selftests/resctrl/resctrl_tests.c | 20 +++++++++---------- tools/testing/selftests/resctrl/resctrl_val.c | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 0f49df4961ea..79b45cbeb628 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -128,6 +128,8 @@ extern pid_t bm_pid, ppid; extern char llc_occup_path[1024]; +extern struct resctrl_test current_test; + int get_vendor(void); bool check_resctrlfs_support(void); int filter_dmesg(void); diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index 75fc49ba3efb..b17f7401892c 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -14,6 +14,12 @@ static volatile int sink_target; volatile int *value_sink = &sink_target; +/* + * Set during test preparation for the cleanup function pointer used in + * ctrl-c sa_sigaction + */ +struct resctrl_test current_test; + static struct resctrl_test *resctrl_tests[] = { &mbm_test, &mba_test, @@ -75,18 +81,12 @@ static void cmd_help(void) printf("\t-h: help\n"); } -void tests_cleanup(void) -{ - mbm_test_cleanup(); - mba_test_cleanup(); - cmt_test_cleanup(); - cat_test_cleanup(); -} - -static int test_prepare(void) +static int test_prepare(const struct resctrl_test *test) { int res; + current_test = *test; + res = signal_handler_register(); if (res) { ksft_print_msg("Failed to register signal handler\n"); @@ -130,7 +130,7 @@ static void run_single_test(const struct resctrl_test *test, const struct user_p ksft_print_msg("Starting %s test ...\n", test->name); - if (test_prepare()) { + if (test_prepare(test)) { ksft_exit_fail_msg("Abnormal failure when preparing for the test\n"); return; } diff --git a/tools/testing/selftests/resctrl/resctrl_val.c b/tools/testing/selftests/resctrl/resctrl_val.c index 5a49f07a6c85..db6aac33ced1 100644 --- a/tools/testing/selftests/resctrl/resctrl_val.c +++ b/tools/testing/selftests/resctrl/resctrl_val.c @@ -472,7 +472,7 @@ void ctrlc_handler(int signum, siginfo_t *info, void *ptr) if (bm_pid) kill(bm_pid, SIGKILL); umount_resctrlfs(); - tests_cleanup(); + current_test.cleanup(); ksft_print_msg("Ending\n\n"); exit(EXIT_SUCCESS); From patchwork Tue Feb 20 13:14:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Wieczor-Retman X-Patchwork-Id: 13564017 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 527C26A030; Tue, 20 Feb 2024 13:15:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708434920; cv=none; b=FFR0ieS/foREuzcct4evMW4AC/Oqd0sYCWlOfcWjsUJ0xX5f7hi3wArkc3v+tFVQvPH1LKxPvtaHZlLDJTaAwCiKCmVEYqgfsqNT1xD4KtCql+mEE5ZwUU2hsc68XtL2ovYGmTWmx1J8NGBa4cbQ/rB8ztTKAtruMsEz09Mrisk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708434920; c=relaxed/simple; bh=is7X7bYYLaNl4Xd9u1Jgp8nNiOY1JjyfGPu5LdGB1Mo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sDsvQNXe+ra/ItAjyXVvMpaWS2ejvo8RMa9lt9Jiy6h9S6N9jMSZUbQKTTKoWA7wcgbxiaZrJBIaFWOvJtHuPrDu6xdrV8nbc1o+IUug/14S6w0cUEamJrPqBdB8XsqHQO6neDE403R63CCXmhem50u6rhWQy+CE83o0DymllSw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Q+dVKl8L; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Q+dVKl8L" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708434918; x=1739970918; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=is7X7bYYLaNl4Xd9u1Jgp8nNiOY1JjyfGPu5LdGB1Mo=; b=Q+dVKl8L7XCWwcFZOlcjdjQTaoGVbAzrqNXLejJjvHDP6ZGAi3GmJ9u2 kGxOGxYT/k1E1po26qoAiedd9C2D85cqJd84gXgxUtRYzslX1cYSZlGsm 2+7h9py4R/lshgFbnpw4hCmUEPhqjMDsxAwySHHcui+BplSx4cxQJqeyJ T8iSLEPVHdvkYluOnMW2ot1KR9Ab+DLfVPwKfNDdv/zOdhCLhC67Z68PB 2Kl9WJIXAU8LOiiKcdA7yF0ERUzAmiJYzR9DrHOEpf4GL6KwysctpaTIP 4ZP2WZ84qjZWc9IK/+sjjFrtfoC38UFijZKQKsvdNMZaKX0MfRLiDDdRP g==; X-IronPort-AV: E=McAfee;i="6600,9927,10989"; a="2660634" X-IronPort-AV: E=Sophos;i="6.06,172,1705392000"; d="scan'208";a="2660634" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 05:15:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,172,1705392000"; d="scan'208";a="5131033" Received: from jmuniak-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.4.63]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 05:15:15 -0800 From: Maciej Wieczor-Retman To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 3/3] selftests/resctrl: Move cleanups out of individual tests Date: Tue, 20 Feb 2024 14:14:34 +0100 Message-ID: <63b9763211c2954f0ef517a817b3bf0c482df8cd.1708434017.git.maciej.wieczor-retman@intel.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Every test calls its cleanup function at the end of it's test function. After the cleanup function pointer is added to the test framework this can be simplified to executing the callback function at the end of the generic test running function. Make test cleanup functions static and call them from the end of run_single_test() from the resctrl_test's cleanup function pointer. Signed-off-by: Maciej Wieczor-Retman --- tools/testing/selftests/resctrl/cat_test.c | 4 +--- tools/testing/selftests/resctrl/cmt_test.c | 3 +-- tools/testing/selftests/resctrl/mba_test.c | 4 +--- tools/testing/selftests/resctrl/mbm_test.c | 4 +--- tools/testing/selftests/resctrl/resctrl.h | 4 ---- tools/testing/selftests/resctrl/resctrl_tests.c | 2 ++ 6 files changed, 6 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 2d2f69d3e5b7..ad5ebce65c07 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -128,7 +128,7 @@ static int check_results(struct resctrl_val_param *param, const char *cache_type return fail; } -void cat_test_cleanup(void) +static void cat_test_cleanup(void) { remove(RESULT_FILE_NAME); } @@ -289,8 +289,6 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param ret = check_results(¶m, test->resource, cache_total_size, full_cache_mask, start_mask); out: - cat_test_cleanup(); - return ret; } diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 32ddee87e43d..c477f3c9635f 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -91,7 +91,7 @@ static int check_results(struct resctrl_val_param *param, size_t span, int no_of MAX_DIFF, MAX_DIFF_PERCENT, runs - 1, true); } -void cmt_test_cleanup(void) +static void cmt_test_cleanup(void) { remove(RESULT_FILE_NAME); } @@ -161,7 +161,6 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param ksft_print_msg("Intel CMT may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n"); out: - cmt_test_cleanup(); free(span_str); return ret; diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 7cc4067ce930..e4cd484941ec 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -137,7 +137,7 @@ static int check_results(void) return show_mba_info(bw_imc, bw_resc); } -void mba_test_cleanup(void) +static void mba_test_cleanup(void) { remove(RESULT_FILE_NAME); } @@ -163,8 +163,6 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param ret = check_results(); out: - mba_test_cleanup(); - return ret; } diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 071e2d3808a7..405edd7df816 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -105,7 +105,7 @@ static int mbm_setup(const struct resctrl_test *test, return ret; } -void mbm_test_cleanup(void) +static void mbm_test_cleanup(void) { remove(RESULT_FILE_NAME); } @@ -133,8 +133,6 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param ksft_print_msg("Intel MBM may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n"); out: - mbm_test_cleanup(); - return ret; } diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 79b45cbeb628..c2a74e11a65e 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -156,8 +156,6 @@ int resctrl_val(const struct resctrl_test *test, const char * const *benchmark_cmd, struct resctrl_val_param *param); void tests_cleanup(void); -void mbm_test_cleanup(void); -void mba_test_cleanup(void); unsigned long create_bit_mask(unsigned int start, unsigned int len); unsigned int count_contiguous_bits(unsigned long val, unsigned int *start); int get_full_cbm(const char *cache_type, unsigned long *mask); @@ -166,9 +164,7 @@ int get_cache_size(int cpu_no, const char *cache_type, unsigned long *cache_size void ctrlc_handler(int signum, siginfo_t *info, void *ptr); int signal_handler_register(void); void signal_handler_unregister(void); -void cat_test_cleanup(void); unsigned int count_bits(unsigned long n); -void cmt_test_cleanup(void); void perf_event_attr_initialize(struct perf_event_attr *pea, __u64 config); void perf_event_initialize_read_format(struct perf_event_read *pe_read); diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index b17f7401892c..e01937e798ee 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -142,6 +142,8 @@ static void run_single_test(const struct resctrl_test *test, const struct user_p } ret = test->run_test(test, uparams); + if (test->cleanup) + test->cleanup(); ksft_test_result(!ret, "%s: test\n", test->name); cleanup: