diff --git a/tests/unit/framework/prepare_sources_for_testing.py b/tests/unit/framework/prepare_sources_for_testing.py index 06aa557..03b4921 100755 --- a/tests/unit/framework/prepare_sources_for_testing.py +++ b/tests/unit/framework/prepare_sources_for_testing.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3.6 +#!/usr/bin/env python3 # # Copyright(c) 2012-2018 Intel Corporation @@ -42,6 +42,7 @@ class UnitTestsSourcesGenerator(object): script_dir_abs_path = "" main_UT_dir = "" + main_env_dir = "" main_tested_dir = "" ctags_path = "" @@ -70,6 +71,7 @@ class UnitTestsSourcesGenerator(object): self.set_ctags_path() self.set_main_UT_dir() + self.set_main_env_dir() self.set_main_tested_dir() 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): 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 def prepare_autowraps(self, test_file_path, preprocessed_file_path): @@ -158,7 +160,10 @@ class UnitTestsSourcesGenerator(object): with open(preprocessed_file_path) as f: code = f.readlines() 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 for tag in tags_list: 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) 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: f.write(wrap + "\n") @@ -655,6 +660,9 @@ class UnitTestsSourcesGenerator(object): def get_main_UT_dir(self): 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): return os.path.normpath(self.main_tested_dir) + os.sep @@ -673,6 +681,17 @@ class UnitTestsSourcesGenerator(object): def get_includes_to_copy_dict(self): 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): main_UT_dir = os.path.normpath(os.path.normpath(self.get_script_dir_path() + os.sep diff --git a/tests/unit/tests/cleaning/alru.c/cleaning_policy_alru_initialize_part_test.c b/tests/unit/tests/cleaning/alru.c/cleaning_policy_alru_initialize_part_test.c index 9b74a29..53bc9b8 100644 --- a/tests/unit/tests/cleaning/alru.c/cleaning_policy_alru_initialize_part_test.c +++ b/tests/unit/tests/cleaning/alru.c/cleaning_policy_alru_initialize_part_test.c @@ -35,7 +35,7 @@ #include "../concurrency/ocf_cache_line_concurrency.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) @@ -58,7 +58,7 @@ static void cleaning_policy_alru_initialize_test01(void **state) 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_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->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_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(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_tail, -collision_table_entries); diff --git a/tests/unit/tests/ocf_env/CMakeLists.txt b/tests/unit/tests/ocf_env/CMakeLists.txt index 61b4475..5ab2fea 100644 --- a/tests/unit/tests/ocf_env/CMakeLists.txt +++ b/tests/unit/tests/ocf_env/CMakeLists.txt @@ -1,2 +1,3 @@ -add_library(ocf_env ocf_env.c) -target_link_libraries(ocf_env pthread) +add_library(ocf_env ocf_env.c /usr/include/sys/types.h /usr/include/setjmp.h /usr/include/cmocka.h) +add_definitions(-Dstatic= -Dinline= ) +target_link_libraries(ocf_env pthread z)