UT prapare update
**CMake lists**: link Zlib; include libs for UT during compilation. **prapare script**: add path to regular ocf_env files; ignore 'memcpy' functions when copied to wrappers. **cleaning policy**: update of some functions for proper use of atomics. Signed-off-by: Slawomir_Jankowski <slawomir.jankowski@intel.com>
This commit is contained in:
parent
5d0a6fa05a
commit
717b8aa259
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3.6
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright(c) 2012-2018 Intel Corporation
|
# Copyright(c) 2012-2018 Intel Corporation
|
||||||
@ -42,6 +42,7 @@ class UnitTestsSourcesGenerator(object):
|
|||||||
script_dir_abs_path = ""
|
script_dir_abs_path = ""
|
||||||
|
|
||||||
main_UT_dir = ""
|
main_UT_dir = ""
|
||||||
|
main_env_dir = ""
|
||||||
main_tested_dir = ""
|
main_tested_dir = ""
|
||||||
|
|
||||||
ctags_path = ""
|
ctags_path = ""
|
||||||
@ -70,6 +71,7 @@ class UnitTestsSourcesGenerator(object):
|
|||||||
self.set_ctags_path()
|
self.set_ctags_path()
|
||||||
|
|
||||||
self.set_main_UT_dir()
|
self.set_main_UT_dir()
|
||||||
|
self.set_main_env_dir()
|
||||||
self.set_main_tested_dir()
|
self.set_main_tested_dir()
|
||||||
|
|
||||||
self.test_catalogues_list = tests_config.DIRECTORIES_WITH_TESTS_LIST
|
self.test_catalogues_list = tests_config.DIRECTORIES_WITH_TESTS_LIST
|
||||||
@ -141,7 +143,7 @@ class UnitTestsSourcesGenerator(object):
|
|||||||
|
|
||||||
def get_autowrap_file_path(self, test_file_path):
|
def get_autowrap_file_path(self, test_file_path):
|
||||||
wrap_file_path = test_file_path.rsplit('.', 1)[0]
|
wrap_file_path = test_file_path.rsplit('.', 1)[0]
|
||||||
wrap_file_path = wrap_file_path + "_generated_warps.c"
|
wrap_file_path = wrap_file_path + "_generated_wraps.c"
|
||||||
return wrap_file_path
|
return wrap_file_path
|
||||||
|
|
||||||
def prepare_autowraps(self, test_file_path, preprocessed_file_path):
|
def prepare_autowraps(self, test_file_path, preprocessed_file_path):
|
||||||
@ -158,7 +160,10 @@ class UnitTestsSourcesGenerator(object):
|
|||||||
with open(preprocessed_file_path) as f:
|
with open(preprocessed_file_path) as f:
|
||||||
code = f.readlines()
|
code = f.readlines()
|
||||||
for function in functions_to_wrap:
|
for function in functions_to_wrap:
|
||||||
if function.startswith("env_") or function.startswith("bug"):
|
if function.startswith("env_") or function.startswith("bug") \
|
||||||
|
or function.startswith("memcpy"):
|
||||||
|
# added memcpy function to list of ignored functions
|
||||||
|
# because this is macro
|
||||||
continue
|
continue
|
||||||
for tag in tags_list:
|
for tag in tags_list:
|
||||||
if function in tag:
|
if function in tag:
|
||||||
@ -171,7 +176,7 @@ class UnitTestsSourcesGenerator(object):
|
|||||||
wrap_file_path = self.get_main_UT_dir() + self.get_autowrap_file_path(test_file_path)
|
wrap_file_path = self.get_main_UT_dir() + self.get_autowrap_file_path(test_file_path)
|
||||||
|
|
||||||
with open(wrap_file_path, "w") as f:
|
with open(wrap_file_path, "w") as f:
|
||||||
f.write("/* This is file is generated by UT framework */\n")
|
f.write("/* This file is generated by UT framework */\n")
|
||||||
for wrap in wrap_list:
|
for wrap in wrap_list:
|
||||||
f.write(wrap + "\n")
|
f.write(wrap + "\n")
|
||||||
|
|
||||||
@ -655,6 +660,9 @@ class UnitTestsSourcesGenerator(object):
|
|||||||
def get_main_UT_dir(self):
|
def get_main_UT_dir(self):
|
||||||
return os.path.normpath(self.main_UT_dir) + os.sep
|
return os.path.normpath(self.main_UT_dir) + os.sep
|
||||||
|
|
||||||
|
def get_main_env_dir(self):
|
||||||
|
return os.path.normpath(self.main_env_dir) + os.sep
|
||||||
|
|
||||||
def get_main_tested_dir(self):
|
def get_main_tested_dir(self):
|
||||||
return os.path.normpath(self.main_tested_dir) + os.sep
|
return os.path.normpath(self.main_tested_dir) + os.sep
|
||||||
|
|
||||||
@ -673,6 +681,17 @@ class UnitTestsSourcesGenerator(object):
|
|||||||
def get_includes_to_copy_dict(self):
|
def get_includes_to_copy_dict(self):
|
||||||
return self.includes_to_copy_dict
|
return self.includes_to_copy_dict
|
||||||
|
|
||||||
|
def set_main_env_dir(self):
|
||||||
|
main_env_dir = os.path.normpath(os.path.normpath(self.get_script_dir_path()
|
||||||
|
+ os.sep
|
||||||
|
+ tests_config.
|
||||||
|
MAIN_DIRECTORY_OF_ENV_FILES))
|
||||||
|
if not os.path.isdir(main_env_dir):
|
||||||
|
print("Given path to main env directory is wrong!")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
self.main_env_dir = main_env_dir
|
||||||
|
|
||||||
def set_main_UT_dir(self):
|
def set_main_UT_dir(self):
|
||||||
main_UT_dir = os.path.normpath(os.path.normpath(self.get_script_dir_path()
|
main_UT_dir = os.path.normpath(os.path.normpath(self.get_script_dir_path()
|
||||||
+ os.sep
|
+ os.sep
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include "../concurrency/ocf_cache_line_concurrency.h"
|
#include "../concurrency/ocf_cache_line_concurrency.h"
|
||||||
#include "../ocf_def_priv.h"
|
#include "../ocf_def_priv.h"
|
||||||
|
|
||||||
#include "cleaning/alru.c/cleaning_policy_alru_initialize_part_test_generated_warps.c"
|
#include "cleaning/alru.c/cleaning_policy_alru_initialize_part_test_generated_wraps.c"
|
||||||
|
|
||||||
|
|
||||||
static void cleaning_policy_alru_initialize_test01(void **state)
|
static void cleaning_policy_alru_initialize_test01(void **state)
|
||||||
@ -58,7 +58,7 @@ static void cleaning_policy_alru_initialize_test01(void **state)
|
|||||||
|
|
||||||
assert_int_equal(result, 0);
|
assert_int_equal(result, 0);
|
||||||
|
|
||||||
assert_int_equal(cache.user_parts[part_id].runtime->cleaning.policy.alru.size, 0);
|
assert_int_equal(env_atomic_read(&cache.user_parts[part_id].runtime->cleaning.policy.alru.size), 0);
|
||||||
assert_int_equal(cache.user_parts[part_id].runtime->cleaning.policy.alru.lru_head, collision_table_entries);
|
assert_int_equal(cache.user_parts[part_id].runtime->cleaning.policy.alru.lru_head, collision_table_entries);
|
||||||
assert_int_equal(cache.user_parts[part_id].runtime->cleaning.policy.alru.lru_tail, collision_table_entries);
|
assert_int_equal(cache.user_parts[part_id].runtime->cleaning.policy.alru.lru_tail, collision_table_entries);
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ static void cleaning_policy_alru_initialize_test02(void **state)
|
|||||||
cache.device = test_malloc(sizeof(struct ocf_cache_device));
|
cache.device = test_malloc(sizeof(struct ocf_cache_device));
|
||||||
cache.device->runtime_meta = test_malloc(sizeof(struct ocf_superblock_runtime));
|
cache.device->runtime_meta = test_malloc(sizeof(struct ocf_superblock_runtime));
|
||||||
|
|
||||||
cache.user_parts[part_id].runtime->cleaning.policy.alru.size = 1;
|
env_atomic_set(&cache.user_parts[part_id].runtime->cleaning.policy.alru.size, 1);
|
||||||
cache.user_parts[part_id].runtime->cleaning.policy.alru.lru_head = -collision_table_entries;
|
cache.user_parts[part_id].runtime->cleaning.policy.alru.lru_head = -collision_table_entries;
|
||||||
cache.user_parts[part_id].runtime->cleaning.policy.alru.lru_tail = -collision_table_entries;
|
cache.user_parts[part_id].runtime->cleaning.policy.alru.lru_tail = -collision_table_entries;
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ static void cleaning_policy_alru_initialize_test02(void **state)
|
|||||||
|
|
||||||
assert_int_equal(result, 0);
|
assert_int_equal(result, 0);
|
||||||
|
|
||||||
assert_int_equal(cache.user_parts[part_id].runtime->cleaning.policy.alru.size, 1);
|
assert_int_equal(env_atomic_read(&cache.user_parts[part_id].runtime->cleaning.policy.alru.size), 1);
|
||||||
assert_int_equal(cache.user_parts[part_id].runtime->cleaning.policy.alru.lru_head, -collision_table_entries);
|
assert_int_equal(cache.user_parts[part_id].runtime->cleaning.policy.alru.lru_head, -collision_table_entries);
|
||||||
assert_int_equal(cache.user_parts[part_id].runtime->cleaning.policy.alru.lru_tail, -collision_table_entries);
|
assert_int_equal(cache.user_parts[part_id].runtime->cleaning.policy.alru.lru_tail, -collision_table_entries);
|
||||||
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
add_library(ocf_env ocf_env.c)
|
add_library(ocf_env ocf_env.c /usr/include/sys/types.h /usr/include/setjmp.h /usr/include/cmocka.h)
|
||||||
target_link_libraries(ocf_env pthread)
|
add_definitions(-Dstatic= -Dinline= )
|
||||||
|
target_link_libraries(ocf_env pthread z)
|
||||||
|
Loading…
Reference in New Issue
Block a user