summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/resctrl/resctrl_tests.c
diff options
context:
space:
mode:
authorFenghua Yu <fenghua.yu@intel.com>2021-03-17 05:22:42 +0300
committerShuah Khan <skhan@linuxfoundation.org>2021-04-02 22:54:08 +0300
commitca2f4214f9671dfc08b6c5723188e03574203dc5 (patch)
treed44d208f746dbf39b091e981935346a03ef52fc4 /tools/testing/selftests/resctrl/resctrl_tests.c
parent2f320911d9fab38597d2a32d91b4f31165e0c9b4 (diff)
downloadlinux-ca2f4214f9671dfc08b6c5723188e03574203dc5.tar.xz
selftests/resctrl: Call kselftest APIs to log test results
Call kselftest APIs instead of using printf() to log test results for cleaner code and better future extension. Suggested-by: Shuah Khan <skhan@linuxfoundation.org> Tested-by: Babu Moger <babu.moger@amd.com> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/selftests/resctrl/resctrl_tests.c')
-rw-r--r--tools/testing/selftests/resctrl/resctrl_tests.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c
index 6b2ed2efaad4..ccc1d6987cc6 100644
--- a/tools/testing/selftests/resctrl/resctrl_tests.c
+++ b/tools/testing/selftests/resctrl/resctrl_tests.c
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
int res, c, cpu_no = 1, span = 250, argc_new = argc, i, no_of_bits = 5;
char *benchmark_cmd[BENCHMARK_ARGS], bw_report[64], bm_type[64];
char benchmark_cmd_area[BENCHMARK_ARGS][BENCHMARK_ARG_SIZE];
- int ben_ind, ben_count;
+ int ben_ind, ben_count, tests = 0;
bool cat_test = true;
for (i = 0; i < argc; i++) {
@@ -87,12 +87,16 @@ int main(int argc, char **argv)
while (token) {
if (!strncmp(token, MBM_STR, sizeof(MBM_STR))) {
mbm_test = true;
+ tests++;
} else if (!strncmp(token, MBA_STR, sizeof(MBA_STR))) {
mba_test = true;
+ tests++;
} else if (!strncmp(token, CMT_STR, sizeof(CMT_STR))) {
cmt_test = true;
+ tests++;
} else if (!strncmp(token, CAT_STR, sizeof(CAT_STR))) {
cat_test = true;
+ tests++;
} else {
printf("invalid argument\n");
@@ -118,7 +122,7 @@ int main(int argc, char **argv)
}
}
- printf("TAP version 13\n");
+ ksft_print_header();
/*
* Typically we need root privileges, because:
@@ -126,7 +130,7 @@ int main(int argc, char **argv)
* 2. We execute perf commands
*/
if (geteuid() != 0)
- printf("# WARNING: not running as root, tests may fail.\n");
+ return ksft_exit_fail_msg("Not running as root, abort testing.\n");
/* Detect AMD vendor */
detect_amd();
@@ -155,48 +159,46 @@ int main(int argc, char **argv)
sprintf(bw_report, "reads");
sprintf(bm_type, "fill_buf");
- check_resctrlfs_support();
+ if (!check_resctrlfs_support())
+ return ksft_exit_fail_msg("resctrl FS does not exist\n");
+
filter_dmesg();
+ ksft_set_plan(tests ? : 4);
+
if (!is_amd && mbm_test) {
- printf("# Starting MBM BW change ...\n");
+ ksft_print_msg("Starting MBM BW change ...\n");
if (!has_ben)
sprintf(benchmark_cmd[5], "%s", MBA_STR);
res = mbm_bw_change(span, cpu_no, bw_report, benchmark_cmd);
- printf("%sok MBM: bw change\n", res ? "not " : "");
+ ksft_test_result(!res, "MBM: bw change\n");
mbm_test_cleanup();
- tests_run++;
}
if (!is_amd && mba_test) {
- printf("# Starting MBA Schemata change ...\n");
+ ksft_print_msg("Starting MBA Schemata change ...\n");
if (!has_ben)
sprintf(benchmark_cmd[1], "%d", span);
res = mba_schemata_change(cpu_no, bw_report, benchmark_cmd);
- printf("%sok MBA: schemata change\n", res ? "not " : "");
+ ksft_test_result(!res, "MBA: schemata change\n");
mba_test_cleanup();
- tests_run++;
}
if (cmt_test) {
- printf("# Starting CMT test ...\n");
+ ksft_print_msg("Starting CMT test ...\n");
if (!has_ben)
sprintf(benchmark_cmd[5], "%s", CMT_STR);
res = cmt_resctrl_val(cpu_no, no_of_bits, benchmark_cmd);
- printf("%sok CMT: test\n", res ? "not " : "");
+ ksft_test_result(!res, "CMT: test\n");
cmt_test_cleanup();
- tests_run++;
}
if (cat_test) {
- printf("# Starting CAT test ...\n");
+ ksft_print_msg("Starting CAT test ...\n");
res = cat_perf_miss_val(cpu_no, no_of_bits, "L3");
- printf("%sok CAT: test\n", res ? "not " : "");
- tests_run++;
+ ksft_test_result(!res, "CAT: test\n");
cat_test_cleanup();
}
- printf("1..%d\n", tests_run);
-
- return 0;
+ return ksft_exit_pass();
}