Merge pull request #175 from mmichal10/generating-wraps-in-UT-framework

UT framerwok: Auto generating wrap functions
This commit is contained in:
Adam Rutkowski 2019-06-06 08:28:01 -04:00 committed by GitHub
commit 75ec3c7db4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 151 additions and 534 deletions

View File

@ -45,13 +45,14 @@ class TestGenerator(object):
buf += "#undef inline\n\n"
buf += self.get_UT_includes()
buf += self.get_includes(self.get_main_tested_dir() + self.get_tested_file_path())
buf += self.get_autowrap_file_include(dst_path)
buf += self.get_empty_test_function()
buf += self.get_test_main()
with open(dst_path, "w") as f:
f.writelines(buf)
print dst_path + " generated successfully!"
print(f"{dst_path} generated successfully!")
def get_markups(self):
ret = "/*\n"
@ -85,13 +86,19 @@ class TestGenerator(object):
return textwrap.dedent(ret)
def get_autowrap_file_include(self, test_file_path):
autowrap_file = test_file_path.rsplit(".", 1)[0]
autowrap_file = autowrap_file.replace(self.main_UT_dir, "")
autowrap_file += "_generated_warps.c"
return "#include \"" + autowrap_file + "\"\n\n"
def get_includes(self, abs_path_to_tested_file):
with open(abs_path_to_tested_file, "r") as f:
code = f.readlines()
ret = [line for line in code if re.search(r'#include', line)]
return "".join(ret) + "\n\n"
return "".join(ret) + "\n"
def get_empty_test_function(self):
ret = "static void " + self.get_tested_function_name() + "_test01(void **state)\n"
@ -125,7 +132,7 @@ class TestGenerator(object):
self.tested_file_path = path
return
print(os.path.join(self.get_main_tested_dir(), path))
print(f"{os.path.join(self.get_main_tested_dir(), path)}")
print("Given path not exists!")
exit(1)
@ -154,7 +161,7 @@ class TestGenerator(object):
def __main__():
if len(sys.argv) < 3:
print "No path to tested file or tested function name given !"
print("No path to tested file or tested function name given !")
sys.exit(1)
tested_file_path = sys.argv[1]

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python3.6
#
# Copyright(c) 2012-2018 Intel Corporation
@ -12,11 +12,12 @@ import os.path
from collections import defaultdict
import subprocess
def run_command(args):
def run_command(args, verbose=True):
result = subprocess.run(" ".join(args), shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result.stdout = result.stdout.decode("ASCII")
result.stderr = result.stderr.decode("ASCII")
result.stdout = result.stdout.decode("ASCII", errors='ignore')
result.stderr = result.stderr.decode("ASCII", errors='ignore')
if verbose:
print(result.stderr)
return result
@ -127,9 +128,52 @@ class UnitTestsSourcesGenerator(object):
continue
dst_path = os.path.normpath(self.get_main_UT_dir() + dst)
shutil.rmtree(dst_path)
shutil.rmtree(dst_path, ignore_errors=True)
shutil.copytree(src_path, dst_path)
def get_user_wraps(self, path):
functions_list = self.get_functions_list(path)
functions_list = [re.sub(r'__wrap_([\S]+)\s*[\d]+', r'\1', line) \
for line in functions_list if re.search("__wrap_", line)]
return functions_list
def get_autowrap_file_path(self, test_file_path):
wrap_file_path = test_file_path.rsplit('.', 1)[0]
wrap_file_path = wrap_file_path + "_generated_warps.c"
return wrap_file_path
def prepare_autowraps(self, test_file_path, preprocessed_file_path):
functions_to_wrap = self.get_functions_calls(
self.get_sources_to_test_repo() + test_file_path)
user_wraps = set(self.get_user_wraps(self.get_main_UT_dir() + test_file_path))
functions_to_wrap = functions_to_wrap - user_wraps
tags_list = self.get_functions_list(preprocessed_file_path, prototypes=True)
wrap_list = []
with open(preprocessed_file_path) as f:
code = f.readlines()
for function in functions_to_wrap:
if function.startswith("env_") or function.startswith("bug"):
continue
for tag in tags_list:
if function in tag:
name, line = tag.split()
if name == function:
line = int(line)
wrap_list.append(self.get_function_wrap(code, line))
break
wrap_file_path = self.get_main_UT_dir() + self.get_autowrap_file_path(test_file_path)
with open(wrap_file_path, "w") as f:
f.write("/* This is file is generated by UT framework */\n")
for wrap in wrap_list:
f.write(wrap + "\n")
def prepare_sources_for_testing(self):
test_files_paths = self.get_files_with_tests_list()
@ -149,6 +193,8 @@ class UnitTestsSourcesGenerator(object):
f.writelines(tested_src)
print(f"Sources for {test_path} saved in {self.get_sources_to_test_repo() + test_path}")
self.prepare_autowraps(test_path, preprocessed_tested_path)
def create_main_cmake_lists(self):
buf = "cmake_minimum_required(VERSION 2.6.0)\n\n"
buf += "project(OCF_unit_tests C)\n\n"
@ -227,7 +273,9 @@ class UnitTestsSourcesGenerator(object):
def generate_cmake_link_flags(self, path):
ret = ""
autowraps_path = self.get_autowrap_file_path(path)
functions_to_wrap = self.get_functions_to_wrap(path)
functions_to_wrap += self.get_functions_to_wrap(autowraps_path)
for function_name in functions_to_wrap:
ret += ",--wrap=" + function_name
@ -270,12 +318,15 @@ class UnitTestsSourcesGenerator(object):
ret = [name for name in ret if name]
return ret
def get_functions_list(self, file_path):
def get_functions_list(self, file_path, prototypes=None):
ctags_path = self.get_ctags_path()
ctags_args = "--c-types=f"
if prototypes == True:
ctags_args += " --c-kinds=+p"
# find all functions' definitions | put tabs instead of spaces |
# take only columns with function name and line number | sort in descending order
result = run_command([ctags_path, "-x", "--c-types=f", file_path,
result = run_command([ctags_path, "-x", ctags_args, file_path,
"--language-force=c | sed \"s/ \\+/\t/g\" | cut -f 1,3 | sort -nsr -k 2"])
# 'output' is string, but it has to be changed to list
@ -461,6 +512,16 @@ class UnitTestsSourcesGenerator(object):
return current_line_index
def get_functions_calls(self, file_to_compile):
out_dir = "/tmp/ocf_ut"
out_file = out_dir + "/ocf_obj.o"
self.create_dir_if_not_exist(out_dir)
cmd = "/usr/bin/gcc -o " + out_file + " -c " + file_to_compile + " &> /dev/null"
run_command([cmd], verbose=None)
result = run_command(["/usr/bin/nm -u " + out_file + " | cut -f2 -d\'U\'"])
return set(result.stdout.split())
def remove_function_body(self, code_lines_list, line_id):
try:
while "{" not in code_lines_list[line_id]:
@ -477,11 +538,56 @@ class UnitTestsSourcesGenerator(object):
del code_lines_list[line_id + 1: last_line_id + 1]
def get_function_wrap(self, code_lines_list, line_id):
ret = []
# Line numbering starts with one, list indexing with zero
line_id -= 1
# If returned type is not present, it should be in line above
try:
code_lines_list[line_id].split("(")[0].rsplit()[1]
except IndexError:
line_id -= 1
while True:
ret.append(code_lines_list[line_id])
if ")" in code_lines_list[line_id]:
break
line_id += 1
# Tags list contains both prototypes and definitions, here we recoginze
# with which one we deals
delimiter = ""
try:
if "{" in ret[-1] or "{" in ret[-2]:
delimter = "{"
else:
delimiter =";"
except IndexError:
delimiter =";"
ret[-1] = ret[-1].split(delimiter)[0]
ret[-1] += "{}"
function_name = ""
line_with_name = 0
try:
function_name = ret[line_with_name].split("(")[0].rsplit(maxsplit=1)[1]
except IndexError:
line_with_name = 1
function_name = ret[line_with_name].split("(")[0]
function_new_name = "__wrap_" + function_name.replace("*", "")
ret[0] = ret[0].replace(function_name, function_new_name)
return ''.join(ret)
def set_ctags_path(self):
result = run_command(["/usr/bin/ctags --version &> /dev/null"])
if result.returncode == 0:
path = "/usr/bin/ctags "
result = run_command([path, "--c-types=f"])
result = run_command([path, "--c-types=f"], verbose=None)
if not re.search("unrecognized option", result.stdout, re.IGNORECASE):
self.ctags_path = path
return
@ -489,7 +595,7 @@ class UnitTestsSourcesGenerator(object):
result = run_command(["/usr/local/bin/ctags --version &> /dev/null"])
if result.returncode == 0:
path = "/usr/local/bin/ctags "
result = run_command(["path", "--c-types=f"])
result = run_command(["path", "--c-types=f"], verbose=None)
if not re.search("unrecognized option", result.stdout, re.IGNORECASE):
self.ctags_path = path
return

View File

@ -13,8 +13,8 @@ import subprocess
def run_command(args):
result = subprocess.run(" ".join(args), shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result.stdout = result.stdout.decode("ASCII")
result.stderr = result.stderr.decode("ASCII")
result.stdout = result.stdout.decode("ASCII", errors='ignore')
result.stderr = result.stderr.decode("ASCII", errors='ignore')
return result
script_path = os.path.dirname(os.path.realpath(__file__))
@ -57,6 +57,7 @@ cmake_result = run_command([ "cmake", ".." ])
print(cmake_result.stdout)
with open(os.path.join(logs_dir, "cmake.output"), "w") as f:
f.write(cmake_result.stdout)
f.write(cmake_result.stderr)
if cmake_result.returncode != 0:
with open(os.path.join(logs_dir, "tests.output"), "w") as f:
@ -68,6 +69,7 @@ make_result = run_command([ "make", "-j" ])
print(make_result.stdout)
with open(os.path.join(logs_dir, "make.output"), "w") as f:
f.write(make_result.stdout)
f.write(make_result.stderr)
if make_result.returncode != 0:
with open(os.path.join(logs_dir, "tests.output"), "w") as f:

View File

@ -35,9 +35,8 @@
#include "../concurrency/ocf_cache_concurrency.h"
#include "../ocf_def_priv.h"
void _alru_rebuild(struct ocf_cache *cache)
{
}
#include "cleaning/alru.c/cleaning_policy_alru_initialize_part_test_generated_warps.c"
static void cleaning_policy_alru_initialize_test01(void **state)
{

View File

@ -35,140 +35,13 @@
#include "../mngt/ocf_mngt_common.h"
#include "../metadata/metadata.h"
#include "cleaning/cleaning.c/ocf_cleaner_run_test_generated_warps.c"
/*
* Mocked functions. Here we must deliver functions definitions which are not
* in tested source file.
*/
int __wrap_cleaning_nop_perform_cleaning(struct ocf_cache *cache,
ocf_cleaner_end_t cmpl)
{
}
void __wrap_cleaning_policy_alru_setup(struct ocf_cache *cache)
{}
int __wrap_cleaning_policy_alru_set_cleaning_param(struct ocf_cache *cache,
uint32_t param_id, uint32_t param_value)
{
}
int __wrap_cleaning_policy_alru_get_cleaning_param(struct ocf_cache *cache,
uint32_t param_id, uint32_t *param_value)
{
}
int __wrap_cleaning_policy_acp_initialize(struct ocf_cache *cache,
int init_metadata, int init_params){}
void __wrap_cleaning_policy_acp_deinitialize(struct ocf_cache *cache){}
int __wrap_cleaning_policy_acp_perform_cleaning(struct ocf_cache *cache,
ocf_cleaner_end_t cmpl){}
void __wrap_cleaning_policy_acp_init_cache_block(struct ocf_cache *cache,
uint32_t cache_line){}
void __wrap_cleaning_policy_acp_set_hot_cache_line(struct ocf_cache *cache,
uint32_t cache_line){}
void __wrap_cleaning_policy_acp_purge_block(struct ocf_cache *cache,
uint32_t cache_line){}
int __wrap_cleaning_policy_acp_purge_range(struct ocf_cache *cache,
int core_id, uint64_t start_byte, uint64_t end_byte){}
int __wrap_cleaning_policy_acp_add_core(ocf_cache_t cache, ocf_core_id_t core_id){}
int __wrap_cleaning_policy_acp_remove_core(ocf_cache_t cache,
ocf_core_id_t core_id){}
void __wrap_cleaning_policy_acp_request_pending(struct ocf_request *req){
}
void cleaning_policy_acp_setup(struct ocf_cache *cache)
{
}
int cleaning_policy_acp_set_cleaning_param(struct ocf_cache *cache,
uint32_t param_id, uint32_t param_value)
{
}
int cleaning_policy_acp_get_cleaning_param(struct ocf_cache *cache,
uint32_t param_id, uint32_t *param_value)
{
}
int __wrap_cleaning_policy_acp_set_cleaning_parameters(
struct ocf_cache *cache, struct ocf_cleaning_params *params)
{
}
void __wrap_cleaning_policy_acp_get_cleaning_parameters(
struct ocf_cache *cache, struct ocf_cleaning_params *params)
{
}
void __wrap_cleaning_policy_alru_init_cache_block(struct ocf_cache *cache,
uint32_t cache_line)
{
}
void __wrap_cleaning_policy_alru_purge_cache_block(struct ocf_cache *cache,
uint32_t cache_line)
{
}
int __wrap_cleaning_policy_alru_purge_range(struct ocf_cache *cache,
int partition_id, int core_id, uint64_t start_byte,
uint64_t end_byte)
{
}
void __wrap_cleaning_policy_alru_set_hot_cache_line(struct ocf_cache *cache,
uint32_t cache_line)
{
}
int __wrap_cleaning_policy_alru_initialize(struct ocf_cache *cache, int partition_id,
int init_metadata)
{
}
void __wrap_cleaning_policy_alru_deinitialize(ocf_cache_t cache)
{
}
int __wrap_cleaning_policy_alru_flush_block(struct ocf_cache *cache,
uint32_t io_queue, uint32_t count, uint32_t *cache_lines,
int partition_id, int core_id, uint8_t do_lock)
{
}
int __wrap_cleaning_policy_alru_set_cleaning_parameters(ocf_cache_t cache,
ocf_part_id_t part_id, struct ocf_cleaning_params *params)
{
}
void __wrap_cleaning_policy_alru_get_cleaning_parameters(ocf_cache_t cache,
ocf_part_id_t part_id, struct ocf_cleaning_params *params)
{
}
void __wrap_ocf_queue_get(ocf_queue_t queue)
{
}
int __wrap_cleaning_alru_perform_cleaning(struct ocf_cache *cache, ocf_cleaner_end_t cmpl)
{

View File

@ -39,6 +39,7 @@
#include "../ocf_ctx_priv.h"
#include "../cleaning/cleaning.h"
#include "mngt/ocf_mngt_cache.c/_cache_mngt_set_cache_mode_test_generated_warps.c"
/*
* Mocked functions
*/
@ -48,10 +49,6 @@ bool __wrap_ocf_cache_mode_is_valid(ocf_cache_mode_t mode)
return mock();
}
const char *__wrap_ocf_get_io_iface_name(ocf_cache_mode_t cache_mode)
{
}
ocf_ctx_t __wrap_ocf_cache_get_ctx(ocf_cache_t cache)
{
return cache->owner;
@ -70,10 +67,6 @@ int __wrap_ocf_mngt_cache_flush(ocf_cache_t cache, bool interruption)
return mock();
}
int __wrap_ocf_metadata_flush_superblock(struct ocf_cache *cache)
{
}
bool __wrap_env_bit_test(int nr, const volatile unsigned long *addr)
{
}
@ -95,177 +88,7 @@ int __wrap_ocf_mngt_cache_reset_fallback_pt_error_counter(ocf_cache_t cache)
return mock();
}
char *__wrap_ocf_cache_get_name(ocf_cache_t cache)
{
}
void __wrap__ocf_mngt_test_volume_initial_write(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_test_volume_first_read(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_test_volume_discard(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_test_volume_second_read(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_cache_device(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_check_ram(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_load_properties(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_prepare_metadata(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_test_volume(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_load_superblock(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_init_instance(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_clean_pol(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_flush_metadata(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_discard(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_flush(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_shutdown_status(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_post_init(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_stop_wait_metadata_io(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_stop_remove_cores(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_stop_unplug(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_stop_put_io_queues(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_detach_flush(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void ocf_mngt_cache_detach_stop_cache_io(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg)
{
}
void ocf_mngt_cache_detach_stop_cleaner_io(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_detach_wait_pending(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_detach_update_metadata(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_detach_unplug(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_test_volume_first_read(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_test_volume_finish(
ocf_pipeline_t pipeline, void *priv, int error)
{
}
void __wrap__ocf_mngt_cache_attach_finish(
ocf_pipeline_t pipeline, void *priv, int error)
{
}
void __wrap_ocf_mngt_cache_stop_finish(
ocf_pipeline_t pipeline, void *priv, int error)
{
}
void __wrap_ocf_mngt_cache_detach_finish(
ocf_pipeline_t pipeline, void *priv, int error)
{
}
void __wrap_ocf_mngt_cache_save_finish(
ocf_pipeline_t pipeline, void *priv, int error)
{
}
void _cache_mngt_update_initial_dirty_clines(ocf_cache_t cache)
void __wrap__cache_mngt_update_initial_dirty_clines(ocf_cache_t cache)
{
function_called();
}
@ -351,7 +174,7 @@ static void _cache_mngt_set_cache_mode_test03(void **state)
expect_function_call(__wrap_ocf_cache_mode_is_valid);
will_return(__wrap_ocf_cache_mode_is_valid, 1);
expect_function_call(_cache_mngt_update_initial_dirty_clines);
expect_function_call(__wrap__cache_mngt_update_initial_dirty_clines);
expect_function_call(__wrap_ocf_log_raw);
will_return(__wrap_ocf_log_raw, 0);

View File

@ -34,6 +34,8 @@
#include "../ocf_ctx_priv.h"
#include "../cleaning/cleaning.h"
#include "mngt/ocf_mngt_cache.c/ocf_mngt_cache_set_fallback_pt_error_threshold_generated_warps.c"
int __wrap_ocf_log_raw(ocf_logger_t logger, ocf_logger_lvl_t lvl,
const char *fmt, ...)
{
@ -50,179 +52,6 @@ int __wrap_ocf_mngt_cache_set_fallback_pt(ocf_cache_t cache)
function_called();
}
bool __wrap_ocf_fallback_pt_is_on(ocf_cache_t cache)
{
}
char *__wrap_ocf_cache_get_name(ocf_cache_t cache)
{
}
void __wrap__ocf_mngt_test_volume_initial_write(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_test_volume_first_read(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_test_volume_discard(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_test_volume_second_read(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_cache_device(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_check_ram(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_load_properties(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_prepare_metadata(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_test_volume(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_load_superblock(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_init_instance(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_clean_pol(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_flush_metadata(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_discard(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_flush(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_shutdown_status(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_attach_post_init(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_stop_wait_metadata_io(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_stop_remove_cores(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_stop_unplug(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_stop_put_io_queues(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_detach_flush(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_detach_stop_cache_io(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg)
{
}
void ocf_mngt_cache_detach_stop_cleaner_io(ocf_pipeline_t pipeline,
void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_detach_wait_pending(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_detach_update_metadata(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap_ocf_mngt_cache_detach_unplug(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_test_volume_first_read(
ocf_pipeline_t pipeline, void *priv, ocf_pipeline_arg_t arg)
{
}
void __wrap__ocf_mngt_test_volume_finish(
ocf_pipeline_t pipeline, void *priv, int error)
{
}
void __wrap__ocf_mngt_cache_attach_finish(
ocf_pipeline_t pipeline, void *priv, int error)
{
}
void __wrap_ocf_mngt_cache_stop_finish(
ocf_pipeline_t pipeline, void *priv, int error)
{
}
void __wrap_ocf_mngt_cache_detach_finish(
ocf_pipeline_t pipeline, void *priv, int error)
{
}
void __wrap_ocf_mngt_cache_save_finish(
ocf_pipeline_t pipeline, void *priv, int error)
{
}
static void ocf_mngt_cache_set_fallback_pt_error_threshold_test01(void **state)
{
struct ocf_cache cache;

View File

@ -35,36 +35,7 @@
#include "../eviction/ops.h"
#include "ocf_env.h"
/* Mocks reqired for compilation */
int __wrap_ocf_log_raw(const struct ocf_logger *logger, ocf_logger_lvl_t lvl,
const char *fmt, ...)
{
}
ocf_ctx_t __wrap_ocf_cache_get_ctx(ocf_cache_t cache)
{
}
char *__wrap_ocf_cache_get_name(ocf_cache_t cache)
{
}
int __wrap_ocf_mngt_cache_lock(ocf_cache_t cache)
{
return 0;
}
void __wrap_ocf_mngt_cache_unlock(ocf_cache_t cache)
{
}
void __wrap_ocf_metadata_lock(struct ocf_cache *cache, int rw)
{
}
void __wrap_ocf_metadata_unlock(struct ocf_cache *cache, int rw)
{
}
#include "mngt/ocf_mngt_io_class.c/ocf_mngt_io_class_generated_warps.c"
/* Functions mocked for testing purposes */
bool __wrap_ocf_part_is_added(struct ocf_user_part *part)

View File

@ -20,6 +20,7 @@
#include "../utils/utils_refcnt.h"
#include "utils/utils_refcnt.c/utils_refcnt_dec_generated_warps.c"
static void ocf_refcnt_dec_test01(void **state)
{

View File

@ -21,6 +21,7 @@
#include "../utils/utils_refcnt.h"
#include "utils/utils_refcnt.c/utils_refcnt_freeze_generated_warps.c"
static void ocf_refcnt_freeze_test01(void **state)
{

View File

@ -20,6 +20,7 @@
#include "../utils/utils_refcnt.h"
#include "utils/utils_refcnt.c/utils_refcnt_inc_generated_warps.c"
static void ocf_refcnt_inc_test(void **state)
{

View File

@ -20,6 +20,7 @@
#include "../utils/utils_refcnt.h"
#include "utils/utils_refcnt.c/utils_refcnt_init_generated_warps.c"
static void ocf_refcnt_init_test(void **state)
{

View File

@ -22,6 +22,8 @@
#include "../utils/utils_refcnt.h"
#include "utils/utils_refcnt.c/utils_refcnt_register_zero_cb_generated_warps.c"
static void zero_cb(void *ctx)
{
function_called();

View File

@ -22,6 +22,7 @@
#include "../utils/utils_refcnt.h"
#include "utils/utils_refcnt.c/utils_refcnt_unfreeze_generated_warps.c"
static void ocf_refcnt_unfreeze_test01(void **state)
{