const struct user_params *uparams,
                const char * const *benchmark_cmd,
                struct resctrl_val_param *param);
-void tests_cleanup(void);
 void mbm_test_cleanup(void);
 void mba_test_cleanup(void);
 unsigned long create_bit_mask(unsigned int start, unsigned int len);
 int get_cache_size(int cpu_no, const char *cache_type, unsigned long *cache_size);
 int resource_info_unsigned_get(const char *resource, const char *filename, unsigned int *val);
 void ctrlc_handler(int signum, siginfo_t *info, void *ptr);
-int signal_handler_register(void);
+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);
 
        printf("\t-h: help\n");
 }
 
-void tests_cleanup(void)
-{
-       mbm_test_cleanup();
-       mba_test_cleanup();
-       cmt_test_cleanup();
-       cat_test_cleanup();
-}
-
-static int test_prepare(void)
+static int test_prepare(const struct resctrl_test *test)
 {
        int res;
 
-       res = signal_handler_register();
+       res = signal_handler_register(test);
        if (res) {
                ksft_print_msg("Failed to register signal handler\n");
                return res;
 
        ksft_print_msg("Starting %s test ...\n", test->name);
 
-       if (test_prepare()) {
+       if (test_prepare(test)) {
                ksft_exit_fail_msg("Abnormal failure when preparing for the test\n");
                return;
        }
 
 static char mbm_total_path[1024];
 static int imcs;
 static struct imc_counter_config imc_counters_config[MAX_IMCS][2];
+static const struct resctrl_test *current_test;
 
 void membw_initialize_perf_event_attr(int i, int j)
 {
        if (bm_pid)
                kill(bm_pid, SIGKILL);
        umount_resctrlfs();
-       tests_cleanup();
+       if (current_test && current_test->cleanup)
+               current_test->cleanup();
        ksft_print_msg("Ending\n\n");
 
        exit(EXIT_SUCCESS);
  * Register CTRL-C handler for parent, as it has to kill
  * child process before exiting.
  */
-int signal_handler_register(void)
+int signal_handler_register(const struct resctrl_test *test)
 {
        struct sigaction sigact = {};
        int ret = 0;
 
        bm_pid = 0;
 
+       current_test = test;
        sigact.sa_sigaction = ctrlc_handler;
        sigemptyset(&sigact.sa_mask);
        sigact.sa_flags = SA_SIGINFO;
 {
        struct sigaction sigact = {};
 
+       current_test = NULL;
        sigact.sa_handler = SIG_DFL;
        sigemptyset(&sigact.sa_mask);
        if (sigaction(SIGINT, &sigact, NULL) ||