Skip to content

Commit

Permalink
selftests/resctrl: Remove duplicate codes that clear each test result…
Browse files Browse the repository at this point in the history
… file

Before exiting each test function(run_cmt/cat/mbm/mba_test()),
test results("ok","not ok") are printed by ksft_test_result() and then
temporary result files are cleaned by function
cmt/cat/mbm/mba_test_cleanup().
However, before running ksft_test_result(),
function cmt/cat/mbm/mba_test_cleanup()
has been run in each test function as follows:
  cmt_resctrl_val()
  cat_perf_miss_val()
  mba_schemata_change()
  mbm_bw_change()

Remove duplicate codes that clear each test result file,
while ensuring cleanup properly even when errors occur in each test.

Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
  • Loading branch information
Shaopeng Tan authored and Shuah Khan committed Apr 13, 2023
1 parent 73c55fa commit 91db4fd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
7 changes: 3 additions & 4 deletions tools/testing/selftests/resctrl/cmt_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,12 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd)

ret = resctrl_val(benchmark_cmd, &param);
if (ret)
return ret;
goto out;

ret = check_results(&param, n);
if (ret)
return ret;

out:
cmt_test_cleanup();

return 0;
return ret;
}
7 changes: 3 additions & 4 deletions tools/testing/selftests/resctrl/mba_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,12 @@ int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd)

ret = resctrl_val(benchmark_cmd, &param);
if (ret)
return ret;
goto out;

ret = check_results();
if (ret)
return ret;

out:
mba_test_cleanup();

return 0;
return ret;
}
7 changes: 3 additions & 4 deletions tools/testing/selftests/resctrl/mbm_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,12 @@ int mbm_bw_change(int span, int cpu_no, char *bw_report, char **benchmark_cmd)

ret = resctrl_val(benchmark_cmd, &param);
if (ret)
return ret;
goto out;

ret = check_results(span);
if (ret)
return ret;

out:
mbm_test_cleanup();

return 0;
return ret;
}
4 changes: 0 additions & 4 deletions tools/testing/selftests/resctrl/resctrl_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ static void run_mbm_test(bool has_ben, char **benchmark_cmd, int span,
ksft_test_result(!res, "MBM: bw change\n");
if ((get_vendor() == ARCH_INTEL) && res)
ksft_print_msg("Intel MBM may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n");
mbm_test_cleanup();
}

static void run_mba_test(bool has_ben, char **benchmark_cmd, int span,
Expand All @@ -107,7 +106,6 @@ static void run_mba_test(bool has_ben, char **benchmark_cmd, int span,
sprintf(benchmark_cmd[1], "%d", span);
res = mba_schemata_change(cpu_no, bw_report, benchmark_cmd);
ksft_test_result(!res, "MBA: schemata change\n");
mba_test_cleanup();
}

static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no)
Expand All @@ -126,7 +124,6 @@ static void run_cmt_test(bool has_ben, char **benchmark_cmd, int cpu_no)
ksft_test_result(!res, "CMT: test\n");
if ((get_vendor() == ARCH_INTEL) && res)
ksft_print_msg("Intel CMT may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n");
cmt_test_cleanup();
}

static void run_cat_test(int cpu_no, int no_of_bits)
Expand All @@ -142,7 +139,6 @@ static void run_cat_test(int cpu_no, int no_of_bits)

res = cat_perf_miss_val(cpu_no, no_of_bits, "L3");
ksft_test_result(!res, "CAT: test\n");
cat_test_cleanup();
}

int main(int argc, char **argv)
Expand Down

0 comments on commit 91db4fd

Please sign in to comment.