summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/resctrl/cat_test.c
diff options
context:
space:
mode:
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>2023-12-15 17:05:11 +0200
committerShuah Khan <skhan@linuxfoundation.org>2024-02-13 13:56:45 -0700
commitc603ff5bb830b8c22dae56ca3ca5ceb5c103525b (patch)
tree3a2d7d5fdf66f2b9c91272196d6a474413545f71 /tools/testing/selftests/resctrl/cat_test.c
parent15f298821289d3efba87bb34db29d0ba9780a443 (diff)
selftests/resctrl: Introduce generalized test framework
Each test currently has a "run test" function in per test file and another resctrl_tests.c. The functions in resctrl_tests.c are almost identical. Generalize the one in resctrl_tests.c such that it can be shared between all of the tests. It makes adding new tests easier and removes the per test if () forests. Also add comment to CPU vendor IDs that they must be defined as bits for a bitmask. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/selftests/resctrl/cat_test.c')
-rw-r--r--tools/testing/selftests/resctrl/cat_test.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c
index 272132ff7337..a9b4583620d0 100644
--- a/tools/testing/selftests/resctrl/cat_test.c
+++ b/tools/testing/selftests/resctrl/cat_test.c
@@ -231,7 +231,7 @@ reset_affinity:
return ret;
}
-int cat_perf_miss_val(const struct user_params *uparams, char *cache_type)
+static int cat_run_test(const struct resctrl_test *test, const struct user_params *uparams)
{
unsigned long long_mask, start_mask, full_cache_mask;
unsigned long cache_total_size = 0;
@@ -241,16 +241,16 @@ int cat_perf_miss_val(const struct user_params *uparams, char *cache_type)
size_t span;
int ret;
- ret = get_full_cbm(cache_type, &full_cache_mask);
+ ret = get_full_cbm(test->resource, &full_cache_mask);
if (ret)
return ret;
/* Get the largest contiguous exclusive portion of the cache */
- ret = get_mask_no_shareable(cache_type, &long_mask);
+ ret = get_mask_no_shareable(test->resource, &long_mask);
if (ret)
return ret;
/* Get L3/L2 cache size */
- ret = get_cache_size(uparams->cpu, cache_type, &cache_total_size);
+ ret = get_cache_size(uparams->cpu, test->resource, &cache_total_size);
if (ret)
return ret;
ksft_print_msg("Cache size :%lu\n", cache_total_size);
@@ -283,9 +283,17 @@ int cat_perf_miss_val(const struct user_params *uparams, char *cache_type)
if (ret)
goto out;
- ret = check_results(&param, cache_type, cache_total_size, full_cache_mask, start_mask);
+ ret = check_results(&param, test->resource,
+ cache_total_size, full_cache_mask, start_mask);
out:
cat_test_cleanup();
return ret;
}
+
+struct resctrl_test l3_cat_test = {
+ .name = "CAT",
+ .resource = "L3",
+ .feature_check = test_resource_feature_check,
+ .run_test = cat_run_test,
+};