Commit 8780bc88 authored by Maciej Wieczor-Retman's avatar Maciej Wieczor-Retman Committed by Shuah Khan

selftests/resctrl: Add cleanup function to test framework

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: default avatarMaciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
Reviewed-by: default avatarReinette Chatre <reinette.chatre@intel.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent fa04b7ff
...@@ -373,6 +373,7 @@ struct resctrl_test l3_cat_test = { ...@@ -373,6 +373,7 @@ struct resctrl_test l3_cat_test = {
.resource = "L3", .resource = "L3",
.feature_check = test_resource_feature_check, .feature_check = test_resource_feature_check,
.run_test = cat_run_test, .run_test = cat_run_test,
.cleanup = cat_test_cleanup,
}; };
struct resctrl_test l3_noncont_cat_test = { struct resctrl_test l3_noncont_cat_test = {
......
...@@ -178,4 +178,5 @@ struct resctrl_test cmt_test = { ...@@ -178,4 +178,5 @@ struct resctrl_test cmt_test = {
.resource = "L3", .resource = "L3",
.feature_check = cmt_feature_check, .feature_check = cmt_feature_check,
.run_test = cmt_run_test, .run_test = cmt_run_test,
.cleanup = cmt_test_cleanup,
}; };
...@@ -180,4 +180,5 @@ struct resctrl_test mba_test = { ...@@ -180,4 +180,5 @@ struct resctrl_test mba_test = {
.vendor_specific = ARCH_INTEL, .vendor_specific = ARCH_INTEL,
.feature_check = mba_feature_check, .feature_check = mba_feature_check,
.run_test = mba_run_test, .run_test = mba_run_test,
.cleanup = mba_test_cleanup,
}; };
...@@ -150,4 +150,5 @@ struct resctrl_test mbm_test = { ...@@ -150,4 +150,5 @@ struct resctrl_test mbm_test = {
.vendor_specific = ARCH_INTEL, .vendor_specific = ARCH_INTEL,
.feature_check = mbm_feature_check, .feature_check = mbm_feature_check,
.run_test = mbm_run_test, .run_test = mbm_run_test,
.cleanup = mbm_test_cleanup,
}; };
...@@ -72,6 +72,7 @@ struct user_params { ...@@ -72,6 +72,7 @@ struct user_params {
* @disabled: Test is disabled * @disabled: Test is disabled
* @feature_check: Callback to check required resctrl features * @feature_check: Callback to check required resctrl features
* @run_test: Callback to run the test * @run_test: Callback to run the test
* @cleanup: Callback to cleanup after the test
*/ */
struct resctrl_test { struct resctrl_test {
const char *name; const char *name;
...@@ -82,6 +83,7 @@ struct resctrl_test { ...@@ -82,6 +83,7 @@ struct resctrl_test {
bool (*feature_check)(const struct resctrl_test *test); bool (*feature_check)(const struct resctrl_test *test);
int (*run_test)(const struct resctrl_test *test, int (*run_test)(const struct resctrl_test *test,
const struct user_params *uparams); const struct user_params *uparams);
void (*cleanup)(void);
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment