mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 12:42:02 +00:00
selftests/resctrl: Move cleanups out of individual tests
Every test calls its cleanup function at the end of it's test function. After the cleanup function pointer is added to the test framework this can be simplified to executing the callback function at the end of the generic test running function. Make test cleanup functions static and call them from the end of run_single_test() from the resctrl_test's cleanup function pointer. Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
parent
e6487230e9
commit
6cd368982c
@ -128,7 +128,7 @@ static int check_results(struct resctrl_val_param *param, const char *cache_type
|
||||
return fail;
|
||||
}
|
||||
|
||||
void cat_test_cleanup(void)
|
||||
static void cat_test_cleanup(void)
|
||||
{
|
||||
remove(RESULT_FILE_NAME);
|
||||
}
|
||||
@ -284,13 +284,10 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param
|
||||
|
||||
ret = cat_test(test, uparams, ¶m, span, start_mask);
|
||||
if (ret)
|
||||
goto out;
|
||||
return ret;
|
||||
|
||||
ret = check_results(¶m, test->resource,
|
||||
cache_total_size, full_cache_mask, start_mask);
|
||||
out:
|
||||
cat_test_cleanup();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ static int check_results(struct resctrl_val_param *param, size_t span, int no_of
|
||||
MAX_DIFF, MAX_DIFF_PERCENT, runs - 1, true);
|
||||
}
|
||||
|
||||
void cmt_test_cleanup(void)
|
||||
static void cmt_test_cleanup(void)
|
||||
{
|
||||
remove(RESULT_FILE_NAME);
|
||||
}
|
||||
@ -161,7 +161,6 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param
|
||||
ksft_print_msg("Intel CMT may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n");
|
||||
|
||||
out:
|
||||
cmt_test_cleanup();
|
||||
free(span_str);
|
||||
|
||||
return ret;
|
||||
|
@ -137,7 +137,7 @@ static int check_results(void)
|
||||
return show_mba_info(bw_imc, bw_resc);
|
||||
}
|
||||
|
||||
void mba_test_cleanup(void)
|
||||
static void mba_test_cleanup(void)
|
||||
{
|
||||
remove(RESULT_FILE_NAME);
|
||||
}
|
||||
@ -158,13 +158,10 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param
|
||||
|
||||
ret = resctrl_val(test, uparams, uparams->benchmark_cmd, ¶m);
|
||||
if (ret)
|
||||
goto out;
|
||||
return ret;
|
||||
|
||||
ret = check_results();
|
||||
|
||||
out:
|
||||
mba_test_cleanup();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ static int mbm_setup(const struct resctrl_test *test,
|
||||
return ret;
|
||||
}
|
||||
|
||||
void mbm_test_cleanup(void)
|
||||
static void mbm_test_cleanup(void)
|
||||
{
|
||||
remove(RESULT_FILE_NAME);
|
||||
}
|
||||
@ -126,15 +126,12 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param
|
||||
|
||||
ret = resctrl_val(test, uparams, uparams->benchmark_cmd, ¶m);
|
||||
if (ret)
|
||||
goto out;
|
||||
return ret;
|
||||
|
||||
ret = check_results(DEFAULT_SPAN);
|
||||
if (ret && (get_vendor() == ARCH_INTEL))
|
||||
ksft_print_msg("Intel MBM may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n");
|
||||
|
||||
out:
|
||||
mbm_test_cleanup();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -158,8 +158,6 @@ int resctrl_val(const struct resctrl_test *test,
|
||||
const struct user_params *uparams,
|
||||
const char * const *benchmark_cmd,
|
||||
struct resctrl_val_param *param);
|
||||
void mbm_test_cleanup(void);
|
||||
void mba_test_cleanup(void);
|
||||
unsigned long create_bit_mask(unsigned int start, unsigned int len);
|
||||
unsigned int count_contiguous_bits(unsigned long val, unsigned int *start);
|
||||
int get_full_cbm(const char *cache_type, unsigned long *mask);
|
||||
@ -169,9 +167,7 @@ int resource_info_unsigned_get(const char *resource, const char *filename, unsig
|
||||
void ctrlc_handler(int signum, siginfo_t *info, void *ptr);
|
||||
int signal_handler_register(const struct resctrl_test *test);
|
||||
void signal_handler_unregister(void);
|
||||
void cat_test_cleanup(void);
|
||||
unsigned int count_bits(unsigned long n);
|
||||
void cmt_test_cleanup(void);
|
||||
|
||||
void perf_event_attr_initialize(struct perf_event_attr *pea, __u64 config);
|
||||
void perf_event_initialize_read_format(struct perf_event_read *pe_read);
|
||||
|
@ -100,8 +100,10 @@ static int test_prepare(const struct resctrl_test *test)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void test_cleanup(void)
|
||||
static void test_cleanup(const struct resctrl_test *test)
|
||||
{
|
||||
if (test->cleanup)
|
||||
test->cleanup();
|
||||
umount_resctrlfs();
|
||||
signal_handler_unregister();
|
||||
}
|
||||
@ -143,7 +145,7 @@ static void run_single_test(const struct resctrl_test *test, const struct user_p
|
||||
ksft_test_result(!ret, "%s: test\n", test->name);
|
||||
|
||||
cleanup:
|
||||
test_cleanup();
|
||||
test_cleanup(test);
|
||||
}
|
||||
|
||||
static void init_user_params(struct user_params *uparams)
|
||||
|
Loading…
Reference in New Issue
Block a user