Rename "evict" to "remap" across the entire repo

Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
Adam Rutkowski
2021-05-25 20:21:01 +02:00
parent 4f217b91a5
commit fac35d34a2
7 changed files with 65 additions and 64 deletions

View File

@@ -3,7 +3,7 @@
* <tested_function>ocf_prepare_clines_miss</tested_function>
* <functions_to_leave>
* ocf_prepare_clines_evict
* ocf_engine_evict
* ocf_engine_remap
* ocf_req_set_mapping_error
* ocf_req_test_mapping_error
* ocf_req_set_part_evict
@@ -74,7 +74,7 @@ void __wrap_ocf_metadata_end_exclusive_access(
{
}
int __wrap_space_managment_evict_do(struct ocf_request *req)
int __wrap_ocf_space_managment_remap_do(struct ocf_request *req)
{
function_called();
return mock();
@@ -89,8 +89,8 @@ static void ocf_prepare_clines_miss_test01(void **state)
print_test_description("\tEviction success\n");
will_return_always(__wrap_ocf_user_part_has_space, false);
expect_function_call(__wrap_space_managment_evict_do);
will_return_always(__wrap_space_managment_evict_do, LOOKUP_REMAPPED);
expect_function_call(__wrap_ocf_space_managment_remap_do);
will_return_always(__wrap_ocf_space_managment_remap_do, LOOKUP_REMAPPED);
ocf_prepare_clines_miss(&req);
assert(!ocf_req_test_mapping_error(&req));
@@ -107,8 +107,8 @@ static void ocf_prepare_clines_miss_test02(void **state)
will_return_always(__wrap_ocf_user_part_has_space, false);
expect_function_call(__wrap_space_managment_evict_do);
will_return(__wrap_space_managment_evict_do, LOOKUP_MISS);
expect_function_call(__wrap_ocf_space_managment_remap_do);
will_return(__wrap_ocf_space_managment_remap_do, LOOKUP_MISS);
ocf_prepare_clines_miss(&req);
assert(ocf_req_test_mapping_error(&req));
@@ -124,8 +124,8 @@ static void ocf_prepare_clines_miss_test03(void **state)
print_test_description("\tEviction success\n");
will_return_always(__wrap_ocf_user_part_has_space, true);
expect_function_call(__wrap_space_managment_evict_do);
will_return_always(__wrap_space_managment_evict_do, LOOKUP_REMAPPED);
expect_function_call(__wrap_ocf_space_managment_remap_do);
will_return_always(__wrap_ocf_space_managment_remap_do, LOOKUP_REMAPPED);
ocf_prepare_clines_miss(&req);
assert(!ocf_req_test_mapping_error(&req));
@@ -142,8 +142,8 @@ static void ocf_prepare_clines_miss_test04(void **state)
will_return_always(__wrap_ocf_user_part_has_space, true);
expect_function_call(__wrap_space_managment_evict_do);
will_return(__wrap_space_managment_evict_do, LOOKUP_MISS);
expect_function_call(__wrap_ocf_space_managment_remap_do);
will_return(__wrap_ocf_space_managment_remap_do, LOOKUP_MISS);
ocf_prepare_clines_miss(&req);
assert(ocf_req_test_mapping_error(&req));

View File

@@ -1,6 +1,6 @@
/*
* <tested_file_path>src/eviction/eviction.c</tested_file_path>
* <tested_function>ocf_evict_do</tested_function>
* <tested_function>ocf_remap_do</tested_function>
* <functions_to_leave>
ocf_evict_user_partitions
* </functions_to_leave>
@@ -59,7 +59,7 @@ uint32_t __wrap_ocf_evict_calculate(ocf_cache_t cache,
return min(tcache->evictable[user_part->part.id], to_evict);
}
uint32_t __wrap_ocf_eviction_need_space(struct ocf_cache *cache,
uint32_t __wrap_ocf_request_space(struct ocf_cache *cache,
ocf_queue_t io_queue, struct ocf_part *part,
uint32_t clines)
{
@@ -200,13 +200,13 @@ uint32_t __wrap_ocf_engine_unmapped_count(struct ocf_request *req)
#define _expect_evict_call(tcache, part_id, req_count, ret_count) \
do { \
expect_value(__wrap_ocf_eviction_need_space, part, &tcache.cache.user_parts[part_id].part); \
expect_value(__wrap_ocf_eviction_need_space, clines, req_count); \
expect_function_call(__wrap_ocf_eviction_need_space); \
will_return(__wrap_ocf_eviction_need_space, ret_count); \
expect_value(__wrap_ocf_request_space, part, &tcache.cache.user_parts[part_id].part); \
expect_value(__wrap_ocf_request_space, clines, req_count); \
expect_function_call(__wrap_ocf_request_space); \
will_return(__wrap_ocf_request_space, ret_count); \
} while (false);
static void ocf_evict_do_test01(void **state)
static void ocf_remap_do_test01(void **state)
{
struct test_cache tcache = {};
struct ocf_request req = {.cache = &tcache.cache, .part_id = 0 };
@@ -220,11 +220,11 @@ static void ocf_evict_do_test01(void **state)
tcache.req_unmapped = 50;
_expect_evict_call(tcache, 10, 50, 50);
evicted = ocf_evict_do(&req);
evicted = ocf_remap_do(&req);
assert_int_equal(evicted, 50);
}
static void ocf_evict_do_test02(void **state)
static void ocf_remap_do_test02(void **state)
{
struct test_cache tcache = {};
struct ocf_request req = {.cache = &tcache.cache, .part_id = 0 };
@@ -241,11 +241,11 @@ static void ocf_evict_do_test02(void **state)
_expect_evict_call(tcache, 10, 50, 50);
evicted = ocf_evict_do(&req);
evicted = ocf_remap_do(&req);
assert_int_equal(evicted, 50);
}
static void ocf_evict_do_test03(void **state)
static void ocf_remap_do_test03(void **state)
{
struct test_cache tcache = {};
struct ocf_request req = {.cache = &tcache.cache, .part_id = 0 };
@@ -267,11 +267,11 @@ static void ocf_evict_do_test03(void **state)
_expect_evict_call(tcache, 16, 100, 100);
_expect_evict_call(tcache, 17, 50, 50);
evicted = ocf_evict_do(&req);
evicted = ocf_remap_do(&req);
assert_int_equal(evicted, 350);
}
static void ocf_evict_do_test04(void **state)
static void ocf_remap_do_test04(void **state)
{
struct test_cache tcache = {};
struct ocf_request req = {.cache = &tcache.cache, .part_id = 0 };
@@ -301,16 +301,16 @@ static void ocf_evict_do_test04(void **state)
_expect_evict_call(tcache, 16, 100, 100);
_expect_evict_call(tcache, 17, 80, 80);
evicted = ocf_evict_do(&req);
evicted = ocf_remap_do(&req);
assert_int_equal(evicted, 580);
}
int main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test(ocf_evict_do_test01),
cmocka_unit_test(ocf_evict_do_test02),
cmocka_unit_test(ocf_evict_do_test03),
cmocka_unit_test(ocf_evict_do_test04)
cmocka_unit_test(ocf_remap_do_test01),
cmocka_unit_test(ocf_remap_do_test02),
cmocka_unit_test(ocf_remap_do_test03),
cmocka_unit_test(ocf_remap_do_test04)
};
return cmocka_run_group_tests(tests, NULL, NULL);