Skip to contentSkip to conversation

selftests/resctrl: Use correct exit code when tests fail

PATCH In review Peter Newman 3 participants 3 messages Mar 9, 2023 – Mar 17, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/resctrl: Use correct exit code when tests fail

Use ksft_finished() after running tests so that resctrl_tests doesn't return exit code 0 when tests fail.

Consequently, report the MBA and MBM tests as skipped when running on non-Intel hardware, otherwise resctrl_tests will exit with a failure code.

---
 tools/testing/selftests/resctrl/resctrl_tests.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/resctrl/resctrl_tests.c +5 -5
index df0d8d8526fc..69ebb0d7fff6 100644
@@ -77,7 +77,7 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span,
 
 	ksft_print_msg("Starting MBM BW change ...\n");
 
-	if (!validate_resctrl_feature_request(MBM_STR)) {
+	if (!validate_resctrl_feature_request(MBM_STR) || (get_vendor() != ARCH_INTEL)) {
 		ksft_test_result_skip("Hardware does not support MBM or MBM is disabled\n");
 		return;
 	}
@@ -98,7 +98,7 @@ static void run_mba_test(bool has_ben, char **benchmark_cmd, int span,
 
 	ksft_print_msg("Starting MBA Schemata change ...\n");
 
-	if (!validate_resctrl_feature_request(MBA_STR)) {
+	if (!validate_resctrl_feature_request(MBA_STR) || (get_vendor() != ARCH_INTEL)) {
 		ksft_test_result_skip("Hardware does not support MBA or MBA is disabled\n");
 		return;
 	}
@@ -258,10 +258,10 @@ int main(int argc, char **argv)
 
 	ksft_set_plan(tests ? : 4);
 
-	if ((get_vendor() == ARCH_INTEL) && mbm_test)
+	if (mbm_test)
 		run_mbm_test(has_ben, benchmark_cmd, span, cpu_no, bw_report);
 
-	if ((get_vendor() == ARCH_INTEL) && mba_test)
+	if (mba_test)
 		run_mba_test(has_ben, benchmark_cmd, span, cpu_no, bw_report);
 
 	if (cmt_test)
@@ -272,5 +272,5 @@ int main(int argc, char **argv)
 
 	umount_resctrlfs();
 
-	return ksft_exit_pass();
+	ksft_finished();
 }

base-commit: c9c3395d5e3dcc6daee66c6908354d47bf98cb0c

Signature · 1 line
2.40.0.rc1.284.g88254d51c5-goog
Reviewed-by Tested-by on v1 1/1
#1 lore raw

Hi Peter,

Quoted 65 lines

Subject: [PATCH] selftests/resctrl: Use correct exit code when tests fail

Use ksft_finished() after running tests so that resctrl_tests doesn't return exit code 0 when tests fail.

Consequently, report the MBA and MBM tests as skipped when running on non-Intel hardware, otherwise resctrl_tests will exit with a failure code.

---
 tools/testing/selftests/resctrl/resctrl_tests.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/resctrl/resctrl_tests.c +2 -1
index df0d8d8526fc..69ebb0d7fff6 100644
@@ -77,7 +77,7 @@ static void run_mbm_test(bool has_ben, char
 **benchmark_cmd, int span,
 
 	ksft_print_msg("Starting MBM BW change ...\n");
 
-	if (!validate_resctrl_feature_request(MBM_STR)) {
+	if (!validate_resctrl_feature_request(MBM_STR) || (get_vendor() !=
+ARCH_INTEL)) {
 		ksft_test_result_skip("Hardware does not support MBM or

MBM is disabled\n");

tools/testing/selftests/resctrl/resctrl_tests.c +2 -1
 		return;
 	}
@@ -98,7 +98,7 @@ static void run_mba_test(bool has_ben, char
 **benchmark_cmd, int span,
 
 	ksft_print_msg("Starting MBA Schemata change ...\n");
 
-	if (!validate_resctrl_feature_request(MBA_STR)) {
+	if (!validate_resctrl_feature_request(MBA_STR) || (get_vendor() !=
+ARCH_INTEL)) {
 		ksft_test_result_skip("Hardware does not support MBA or

MBA is disabled\n");

tools/testing/selftests/resctrl/resctrl_tests.c +2 -2
 		return;
 	}
@@ -258,10 +258,10 @@ int main(int argc, char **argv)
 
 	ksft_set_plan(tests ? : 4);
 
-	if ((get_vendor() == ARCH_INTEL) && mbm_test)
+	if (mbm_test)
 		run_mbm_test(has_ben, benchmark_cmd, span, cpu_no,
 bw_report);
 
-	if ((get_vendor() == ARCH_INTEL) && mba_test)
+	if (mba_test)
 		run_mba_test(has_ben, benchmark_cmd, span, cpu_no,
 bw_report);
tools/testing/selftests/resctrl/resctrl_tests.c +1 -1
 	if (cmt_test)
@@ -272,5 +272,5 @@ int main(int argc, char **argv)
 
 	umount_resctrlfs();
 
-	return ksft_exit_pass();
+	ksft_finished();
 }
Quoted 3 lines

base-commit: c9c3395d5e3dcc6daee66c6908354d47bf98cb0c --
2.40.0.rc1.284.g88254d51c5-goog

I think it is no problem.

Best regards,
Shaopeng TAN

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Peter Newman

Hi Peter,

Quoted 9 lines · Peter Newman

Use ksft_finished() after running tests so that resctrl_tests doesn't return exit code 0 when tests fail.

Consequently, report the MBA and MBM tests as skipped when running on non-Intel hardware, otherwise resctrl_tests will exit with a failure code.

---

Thank you very much.

Reinette