Skip to content

Commit 8780bc8

Browse files
maciejwieczorretmanshuahkh
authored andcommitted
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: Maciej Wieczor-Retman <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent fa04b7f commit 8780bc8

File tree

5 files changed

+6
-0
lines changed

5 files changed

+6
-0
lines changed

tools/testing/selftests/resctrl/cat_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ struct resctrl_test l3_cat_test = {
373373
.resource = "L3",
374374
.feature_check = test_resource_feature_check,
375375
.run_test = cat_run_test,
376+
.cleanup = cat_test_cleanup,
376377
};
377378

378379
struct resctrl_test l3_noncont_cat_test = {

tools/testing/selftests/resctrl/cmt_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,5 @@ struct resctrl_test cmt_test = {
178178
.resource = "L3",
179179
.feature_check = cmt_feature_check,
180180
.run_test = cmt_run_test,
181+
.cleanup = cmt_test_cleanup,
181182
};

tools/testing/selftests/resctrl/mba_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,5 @@ struct resctrl_test mba_test = {
180180
.vendor_specific = ARCH_INTEL,
181181
.feature_check = mba_feature_check,
182182
.run_test = mba_run_test,
183+
.cleanup = mba_test_cleanup,
183184
};

tools/testing/selftests/resctrl/mbm_test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,5 @@ struct resctrl_test mbm_test = {
150150
.vendor_specific = ARCH_INTEL,
151151
.feature_check = mbm_feature_check,
152152
.run_test = mbm_run_test,
153+
.cleanup = mbm_test_cleanup,
153154
};

tools/testing/selftests/resctrl/resctrl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ struct user_params {
7272
* @disabled: Test is disabled
7373
* @feature_check: Callback to check required resctrl features
7474
* @run_test: Callback to run the test
75+
* @cleanup: Callback to cleanup after the test
7576
*/
7677
struct resctrl_test {
7778
const char *name;
@@ -82,6 +83,7 @@ struct resctrl_test {
8283
bool (*feature_check)(const struct resctrl_test *test);
8384
int (*run_test)(const struct resctrl_test *test,
8485
const struct user_params *uparams);
86+
void (*cleanup)(void);
8587
};
8688

8789
/*

0 commit comments

Comments
 (0)