Remove partition list
Signed-off-by: Adam Rutkowski <adam.j.rutkowski@intel.com>
This commit is contained in:
@@ -16,7 +16,7 @@ MAIN_DIRECTORY_OF_UNIT_TESTS = "../tests/"
|
||||
# Paths to all directories, in which tests are stored. All paths should be relative to
|
||||
# MAIN_DIRECTORY_OF_UNIT_TESTS
|
||||
DIRECTORIES_WITH_TESTS_LIST = ["cleaning/", "metadata/", "mngt/", "concurrency/", "engine/",
|
||||
"eviction/", "utils/", "promotion/", "ocf_freelist.c/"]
|
||||
"eviction/", "utils/", "promotion/"]
|
||||
|
||||
# Paths to all directories containing files with sources. All paths should be relative to
|
||||
# MAIN_DIRECTORY_OF_TESTED_PROJECT
|
||||
|
@@ -4,6 +4,10 @@
|
||||
* <functions_to_leave>
|
||||
* ocf_prepare_clines_evict
|
||||
* ocf_engine_evict
|
||||
* ocf_req_set_mapping_error
|
||||
* ocf_req_test_mapping_error
|
||||
* ocf_req_set_part_evict
|
||||
* ocf_req_part_evict
|
||||
* </functions_to_leave>
|
||||
*/
|
||||
|
||||
@@ -22,7 +26,6 @@
|
||||
#include "../ocf_priv.h"
|
||||
#include "../ocf_cache_priv.h"
|
||||
#include "../ocf_queue_priv.h"
|
||||
#include "../ocf_freelist.h"
|
||||
#include "engine_common.h"
|
||||
#include "engine_debug.h"
|
||||
#include "../utils/utils_cache_line.h"
|
||||
@@ -71,45 +74,27 @@ void __wrap_ocf_metadata_end_exclusive_access(
|
||||
{
|
||||
}
|
||||
|
||||
bool __wrap_ocf_user_part_is_enabled(struct ocf_user_part *target_part)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
|
||||
void __wrap_ocf_engine_map(struct ocf_request *req)
|
||||
{
|
||||
function_called();
|
||||
}
|
||||
|
||||
bool __wrap_ocf_req_test_mapping_error(struct ocf_request *req)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
|
||||
void __wrap_ocf_req_set_mapping_error(struct ocf_request *req)
|
||||
{
|
||||
function_called();
|
||||
}
|
||||
|
||||
int __wrap_space_managment_evict_do(struct ocf_request *req)
|
||||
{
|
||||
function_called();
|
||||
return mock();
|
||||
}
|
||||
|
||||
uint32_t __wrap_ocf_engine_unmapped_count(struct ocf_request *req)
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
static void ocf_prepare_clines_miss_test01(void **state)
|
||||
{
|
||||
struct ocf_cache cache;
|
||||
struct ocf_request req = {.cache = &cache };
|
||||
print_test_description("Target part is disabled and empty\n");
|
||||
will_return(__wrap_ocf_user_part_is_enabled, false);
|
||||
expect_function_call(__wrap_ocf_req_set_mapping_error);
|
||||
assert_int_equal(ocf_prepare_clines_miss(&req, NULL), -OCF_ERR_NO_LOCK);
|
||||
|
||||
print_test_description("Target part doesn't have enough space.\n");
|
||||
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);
|
||||
|
||||
ocf_prepare_clines_miss(&req);
|
||||
assert(!ocf_req_test_mapping_error(&req));
|
||||
assert(ocf_req_part_evict(&req));
|
||||
}
|
||||
|
||||
static void ocf_prepare_clines_miss_test02(void **state)
|
||||
@@ -117,13 +102,17 @@ static void ocf_prepare_clines_miss_test02(void **state)
|
||||
struct ocf_cache cache;
|
||||
struct ocf_request req = {.cache = &cache };
|
||||
|
||||
print_test_description("Target part is disabled but has cachelines assigned.\n");
|
||||
print_test_description("\tMark mapping error\n");
|
||||
print_test_description("Target part doesn't have enough space.\n");
|
||||
print_test_description("\tEviction failed\n");
|
||||
|
||||
will_return(__wrap_ocf_user_part_is_enabled, false);
|
||||
expect_function_call(__wrap_ocf_req_set_mapping_error);
|
||||
will_return_always(__wrap_ocf_user_part_has_space, false);
|
||||
|
||||
assert_int_equal(ocf_prepare_clines_miss(&req, NULL), -OCF_ERR_NO_LOCK);
|
||||
expect_function_call(__wrap_space_managment_evict_do);
|
||||
will_return(__wrap_space_managment_evict_do, LOOKUP_MISS);
|
||||
|
||||
ocf_prepare_clines_miss(&req);
|
||||
assert(ocf_req_test_mapping_error(&req));
|
||||
assert(ocf_req_part_evict(&req));
|
||||
}
|
||||
|
||||
static void ocf_prepare_clines_miss_test03(void **state)
|
||||
@@ -131,20 +120,16 @@ static void ocf_prepare_clines_miss_test03(void **state)
|
||||
struct ocf_cache cache;
|
||||
struct ocf_request req = {.cache = &cache };
|
||||
|
||||
print_test_description("Target part is enabled but doesn't have enough space.\n");
|
||||
print_test_description("\tEviction is ok and cachelines lock is acquired.\n");
|
||||
print_test_description("Target part has enough space.\n");
|
||||
print_test_description("\tEviction success\n");
|
||||
|
||||
will_return(__wrap_ocf_user_part_is_enabled, true);
|
||||
will_return_always(__wrap_ocf_user_part_has_space, false);
|
||||
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_INSERTED);
|
||||
will_return_always(__wrap_space_managment_evict_do, LOOKUP_REMAPPED);
|
||||
|
||||
will_return_always(__wrap_ocf_req_test_mapping_error, false);
|
||||
|
||||
will_return(__wrap_lock_clines, 0);
|
||||
expect_function_call(__wrap_lock_clines);
|
||||
|
||||
assert_int_equal(ocf_prepare_clines_miss(&req, NULL), 0);
|
||||
ocf_prepare_clines_miss(&req);
|
||||
assert(!ocf_req_test_mapping_error(&req));
|
||||
assert(!ocf_req_part_evict(&req));
|
||||
}
|
||||
|
||||
static void ocf_prepare_clines_miss_test04(void **state)
|
||||
@@ -152,85 +137,17 @@ static void ocf_prepare_clines_miss_test04(void **state)
|
||||
struct ocf_cache cache;
|
||||
struct ocf_request req = {.cache = &cache };
|
||||
|
||||
print_test_description("Target part is enabled but doesn't have enough space.\n");
|
||||
print_test_description("Target part has enough space.\n");
|
||||
print_test_description("\tEviction failed\n");
|
||||
|
||||
will_return(__wrap_ocf_user_part_is_enabled, true);
|
||||
will_return_always(__wrap_ocf_user_part_has_space, false);
|
||||
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_req_set_mapping_error);
|
||||
will_return_always(__wrap_ocf_req_test_mapping_error, true);
|
||||
|
||||
assert_int_equal(ocf_prepare_clines_miss(&req, NULL), -OCF_ERR_NO_LOCK);
|
||||
}
|
||||
|
||||
static void ocf_prepare_clines_miss_test06(void **state)
|
||||
{
|
||||
struct ocf_cache cache;
|
||||
struct ocf_request req = {.cache = &cache };
|
||||
|
||||
print_test_description("Target part is enabled but doesn't have enough space.\n");
|
||||
print_test_description("Eviction and mapping were ok, but failed to lock cachelines.\n");
|
||||
|
||||
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_HIT);
|
||||
|
||||
will_return(__wrap_ocf_user_part_is_enabled, true);
|
||||
will_return_always(__wrap_ocf_req_test_mapping_error, false);
|
||||
|
||||
expect_function_call(__wrap_lock_clines);
|
||||
will_return(__wrap_lock_clines, -OCF_ERR_NO_LOCK);
|
||||
|
||||
expect_function_call(__wrap_ocf_req_set_mapping_error);
|
||||
|
||||
assert_int_equal(ocf_prepare_clines_miss(&req, NULL), -OCF_ERR_NO_LOCK);
|
||||
}
|
||||
|
||||
static void ocf_prepare_clines_miss_test07(void **state)
|
||||
{
|
||||
struct ocf_cache cache;
|
||||
struct ocf_request req = {.cache = &cache };
|
||||
|
||||
print_test_description("Target part is enabled but doesn't have enough space.\n");
|
||||
print_test_description("Eviction and mapping were ok, lock not acquired.\n");
|
||||
|
||||
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_HIT);
|
||||
|
||||
will_return(__wrap_ocf_user_part_is_enabled, true);
|
||||
|
||||
will_return_always(__wrap_ocf_req_test_mapping_error, false);
|
||||
|
||||
expect_function_call(__wrap_lock_clines);
|
||||
will_return(__wrap_lock_clines, OCF_LOCK_NOT_ACQUIRED);
|
||||
|
||||
assert_int_equal(ocf_prepare_clines_miss(&req, NULL), OCF_LOCK_NOT_ACQUIRED);
|
||||
}
|
||||
|
||||
static void ocf_prepare_clines_miss_test08(void **state)
|
||||
{
|
||||
struct ocf_cache cache;
|
||||
struct ocf_request req = {.cache = &cache };
|
||||
|
||||
print_test_description("Target part is enabled has enough space.\n");
|
||||
print_test_description("\tMapping and cacheline lock are both ok\n");
|
||||
|
||||
will_return(__wrap_ocf_user_part_is_enabled, true);
|
||||
will_return_always(__wrap_ocf_user_part_has_space, true);
|
||||
|
||||
expect_function_call(__wrap_ocf_engine_map);
|
||||
will_return_always(__wrap_ocf_req_test_mapping_error, false);
|
||||
|
||||
expect_function_call(__wrap_lock_clines);
|
||||
will_return(__wrap_lock_clines, OCF_LOCK_ACQUIRED);
|
||||
|
||||
assert_int_equal(ocf_prepare_clines_miss(&req, NULL), OCF_LOCK_ACQUIRED);
|
||||
ocf_prepare_clines_miss(&req);
|
||||
assert(ocf_req_test_mapping_error(&req));
|
||||
assert(!ocf_req_part_evict(&req));
|
||||
}
|
||||
|
||||
int main(void)
|
||||
@@ -240,9 +157,6 @@ int main(void)
|
||||
cmocka_unit_test(ocf_prepare_clines_miss_test02),
|
||||
cmocka_unit_test(ocf_prepare_clines_miss_test03),
|
||||
cmocka_unit_test(ocf_prepare_clines_miss_test04),
|
||||
cmocka_unit_test(ocf_prepare_clines_miss_test06),
|
||||
cmocka_unit_test(ocf_prepare_clines_miss_test07),
|
||||
cmocka_unit_test(ocf_prepare_clines_miss_test08)
|
||||
};
|
||||
|
||||
print_message("Unit test for ocf_prepare_clines_miss\n");
|
||||
|
@@ -27,11 +27,17 @@ struct test_cache
|
||||
{
|
||||
struct ocf_cache cache;
|
||||
struct ocf_user_part_config part[OCF_USER_IO_CLASS_MAX];
|
||||
struct ocf_part_runtime runtime[OCF_USER_IO_CLASS_MAX];
|
||||
uint32_t overflow[OCF_USER_IO_CLASS_MAX];
|
||||
uint32_t evictable[OCF_USER_IO_CLASS_MAX];
|
||||
uint32_t req_unmapped;
|
||||
};
|
||||
|
||||
uint32_t __wrap_ocf_lru_num_free(ocf_cache_t cache)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool __wrap_ocf_eviction_can_evict(ocf_cache_t cache)
|
||||
{
|
||||
return true;
|
||||
@@ -58,7 +64,9 @@ uint32_t __wrap_ocf_eviction_need_space(struct ocf_cache *cache,
|
||||
uint32_t clines)
|
||||
{
|
||||
struct test_cache *tcache = (struct test_cache *)cache;
|
||||
unsigned overflown_consumed = min(clines, tcache->overflow[part->id]);
|
||||
unsigned overflown_consumed;
|
||||
|
||||
overflown_consumed = min(clines, tcache->overflow[part->id]);
|
||||
|
||||
tcache->overflow[part->id] -= overflown_consumed;
|
||||
tcache->evictable[part->id] -= clines;
|
||||
@@ -102,9 +110,11 @@ int ocf_user_part_lst_cmp_valid(struct ocf_cache *cache,
|
||||
struct ocf_user_part *p2 = container_of(e2, struct ocf_user_part,
|
||||
lst_valid);
|
||||
size_t p1_size = ocf_cache_is_device_attached(cache) ?
|
||||
p1->part.runtime->curr_size : 0;
|
||||
env_atomic_read(&p1->part.runtime->curr_size)
|
||||
: 0;
|
||||
size_t p2_size = ocf_cache_is_device_attached(cache) ?
|
||||
p2->part.runtime->curr_size : 0;
|
||||
env_atomic_read(&p2->part.runtime->curr_size)
|
||||
: 0;
|
||||
int v1 = p1->config->priority;
|
||||
int v2 = p2->config->priority;
|
||||
|
||||
|
@@ -39,6 +39,11 @@
|
||||
|
||||
static union eviction_policy_meta meta[META_COUNT];
|
||||
|
||||
struct ocf_cache_line_concurrency *__wrap_ocf_cache_line_concurrency(ocf_cache_t cache)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
union eviction_policy_meta*
|
||||
__wrap_ocf_metadata_get_eviction_policy(ocf_cache_t cache, ocf_cache_line_t line)
|
||||
{
|
||||
|
@@ -40,6 +40,11 @@
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
struct ocf_cache_line_concurrency *__wrap_ocf_cache_line_concurrency(ocf_cache_t cache)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ocf_cache_line_t test_cases[10 * OCF_NUM_EVICTION_LISTS][OCF_NUM_EVICTION_LISTS][20];
|
||||
unsigned num_cases = 20;
|
||||
|
||||
@@ -335,12 +340,17 @@ bool __wrap__lru_lock(struct ocf_lru_iter *iter,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool __wrap__lru_trylock_cacheline(struct ocf_lru_iter *iter,
|
||||
ocf_cache_line_t cline)
|
||||
bool __wrap_ocf_cache_line_try_lock_rd(struct ocf_cache_line_concurrency *c,
|
||||
ocf_cache_line_t line)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool __wrap_ocf_cache_line_try_lock_wr(struct ocf_cache_line_concurrency *c,
|
||||
ocf_cache_line_t line)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
static void _lru_run_test(unsigned test_case)
|
||||
{
|
||||
unsigned start_pos;
|
||||
|
@@ -1,382 +0,0 @@
|
||||
/*
|
||||
* <tested_file_path>src/ocf_freelist.c</tested_file_path>
|
||||
* <tested_function>ocf_freelist_get_cache_line</tested_function>
|
||||
* <functions_to_leave>
|
||||
* ocf_freelist_init
|
||||
* ocf_freelist_deinit
|
||||
* ocf_freelist_populate
|
||||
* next_phys_invalid
|
||||
* ocf_freelist_lock
|
||||
* ocf_freelist_trylock
|
||||
* ocf_freelist_unlock
|
||||
* _ocf_freelist_remove_cache_line
|
||||
* ocf_freelist_get_cache_line_fast
|
||||
* ocf_freelist_get_cache_line_slow
|
||||
* ocf_freelist_add_cache_line
|
||||
* ocf_freelist_get_cache_line_ctx
|
||||
* get_next_victim_freelist
|
||||
* ocf_freelist_put_cache_line
|
||||
* </functions_to_leave>
|
||||
*/
|
||||
|
||||
#undef static
|
||||
|
||||
#undef inline
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include "print_desc.h"
|
||||
|
||||
#include "ocf/ocf.h"
|
||||
#include "metadata/metadata.h"
|
||||
|
||||
#include "ocf_freelist.c/ocf_freelist_get_put_generated_wraps.c"
|
||||
|
||||
ocf_cache_line_t __wrap_ocf_metadata_collision_table_entries(ocf_cache_t cache)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
|
||||
unsigned __wrap_env_get_execution_context_count(void)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
|
||||
unsigned __wrap_env_get_execution_context(void)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
|
||||
void __wrap_env_put_execution_context(unsigned ctx)
|
||||
{
|
||||
}
|
||||
|
||||
/* simulate no striping */
|
||||
ocf_cache_line_t __wrap_ocf_metadata_map_phy2lg(ocf_cache_t cache, ocf_cache_line_t phy)
|
||||
{
|
||||
return phy;
|
||||
}
|
||||
|
||||
bool __wrap_metadata_test_valid_any(ocf_cache_t cache, ocf_cache_line_t cline)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
|
||||
/* metadata partition info interface mock: */
|
||||
|
||||
#define max_clines 100
|
||||
|
||||
struct {
|
||||
ocf_cache_line_t prev;
|
||||
ocf_cache_line_t next;
|
||||
} partition_list[max_clines];
|
||||
|
||||
|
||||
void __wrap_ocf_metadata_set_partition_info(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line, ocf_part_id_t part_id,
|
||||
ocf_cache_line_t next_line, ocf_cache_line_t prev_line)
|
||||
{
|
||||
assert_int_equal(part_id, PARTITION_INVALID);
|
||||
partition_list[line].prev = prev_line;
|
||||
partition_list[line].next = next_line;
|
||||
}
|
||||
|
||||
void __wrap_ocf_metadata_get_partition_info(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line, ocf_part_id_t *part_id,
|
||||
ocf_cache_line_t *next_line, ocf_cache_line_t *prev_line)
|
||||
{
|
||||
if (part_id)
|
||||
*part_id = PARTITION_INVALID;
|
||||
if (prev_line)
|
||||
*prev_line = partition_list[line].prev;
|
||||
if (next_line)
|
||||
*next_line = partition_list[line].next;
|
||||
}
|
||||
|
||||
void __wrap_ocf_metadata_set_partition_prev(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line, ocf_cache_line_t prev_line)
|
||||
{
|
||||
partition_list[line].prev = prev_line;
|
||||
}
|
||||
|
||||
void __wrap_ocf_metadata_set_partition_next(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line, ocf_cache_line_t next_line)
|
||||
{
|
||||
partition_list[line].next = next_line;
|
||||
}
|
||||
|
||||
static void ocf_freelist_get_cache_line_get_fast(void **state)
|
||||
{
|
||||
unsigned num_cls = 8;
|
||||
unsigned num_ctxts = 3;
|
||||
ocf_freelist_t freelist;
|
||||
unsigned ctx_iter, cl_iter;
|
||||
ocf_cache_line_t line;
|
||||
|
||||
print_test_description("Verify get free cache line get fast path");
|
||||
|
||||
will_return_maybe(__wrap_ocf_metadata_collision_table_entries, num_cls);
|
||||
will_return_maybe(__wrap_env_get_execution_context_count, num_ctxts);
|
||||
will_return_maybe(__wrap_metadata_test_valid_any, false);
|
||||
|
||||
ocf_freelist_init(&freelist, NULL);
|
||||
|
||||
ocf_freelist_populate(freelist, num_cls);
|
||||
|
||||
/* now there are following cachelines on per-context lists:
|
||||
* ctx 0: 0, 1, 2
|
||||
* ctx 1: 3, 4, 5
|
||||
* ctx 2: 6, 7
|
||||
*/
|
||||
|
||||
/* get cline from context 1 */
|
||||
will_return(__wrap_env_get_execution_context, 1);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 3);
|
||||
|
||||
/* ctx 0: 0, 1, 2
|
||||
* ctx 1: _, 4, 5
|
||||
* ctx 2: 6, 7 */
|
||||
|
||||
/* get cline from context 2 */
|
||||
will_return(__wrap_env_get_execution_context, 2);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 6);
|
||||
|
||||
/* ctx 0: 0, 1, 2
|
||||
* ctx 1: _, 4, 5
|
||||
* ctx 2: _, 7 */
|
||||
|
||||
/* get cline from context 1 */
|
||||
will_return(__wrap_env_get_execution_context, 1);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 4);
|
||||
|
||||
/* ctx 0: 0, 1, 2
|
||||
* ctx 1: _, _, 5
|
||||
* ctx 2: _, 7 */
|
||||
|
||||
/* get cline from context 0 */
|
||||
will_return(__wrap_env_get_execution_context, 0);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 0);
|
||||
|
||||
/* ctx 0: _, 1, 2
|
||||
* ctx 1: _, _, 5
|
||||
* ctx 2: _, 7 */
|
||||
|
||||
/* get cline from context 0 */
|
||||
will_return(__wrap_env_get_execution_context, 0);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 1);
|
||||
|
||||
/* ctx 0: _, _, 2
|
||||
* ctx 1: _, _, 5
|
||||
* ctx 2: _, 7 */
|
||||
|
||||
/* get cline from context 0 */
|
||||
will_return(__wrap_env_get_execution_context, 0);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 2);
|
||||
|
||||
/* ctx 0: _, _, _,
|
||||
* ctx 1: _, _, 5
|
||||
* ctx 2: _, 7 */
|
||||
|
||||
/* get cline from context 2 */
|
||||
will_return(__wrap_env_get_execution_context, 2);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 7);
|
||||
|
||||
/* ctx 0: _, _, _,
|
||||
* ctx 1: _, _, _5
|
||||
* ctx 2: _, _ */
|
||||
|
||||
/* get cline from context 1 */
|
||||
will_return(__wrap_env_get_execution_context, 1);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 5);
|
||||
|
||||
/* ctx 0: _, _, _,
|
||||
* ctx 1: _, _, _
|
||||
* ctx 2: _, _ */
|
||||
|
||||
ocf_freelist_deinit(freelist);
|
||||
}
|
||||
|
||||
static void ocf_freelist_get_cache_line_get_slow(void **state)
|
||||
{
|
||||
unsigned num_cls = 8;
|
||||
unsigned num_ctxts = 3;
|
||||
ocf_freelist_t freelist;
|
||||
unsigned ctx_iter, cl_iter;
|
||||
ocf_cache_line_t line;
|
||||
|
||||
print_test_description("Verify get free cache line get slow path");
|
||||
|
||||
will_return_maybe(__wrap_ocf_metadata_collision_table_entries, num_cls);
|
||||
will_return_maybe(__wrap_env_get_execution_context_count, num_ctxts);
|
||||
will_return_maybe(__wrap_metadata_test_valid_any, false);
|
||||
|
||||
/* always return exec ctx 0 */
|
||||
will_return_maybe(__wrap_env_get_execution_context, 0);
|
||||
|
||||
ocf_freelist_init(&freelist, NULL);
|
||||
|
||||
ocf_freelist_populate(freelist, num_cls);
|
||||
|
||||
/* now there are following cachelines on per-context lists:
|
||||
* ctx 0: 0, 1, 2
|
||||
* ctx 1: 3, 4, 5
|
||||
* ctx 2: 6, 7
|
||||
*/
|
||||
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 0);
|
||||
|
||||
/* ctx 0: _, 1, 2
|
||||
* ctx 1: 3, 4, 5
|
||||
* ctx 2: 6, 7 */
|
||||
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 1);
|
||||
|
||||
/* ctx 0: _, _, 2
|
||||
* ctx 1: 3, 4, 5
|
||||
* ctx 2: 6, 7 */
|
||||
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 2);
|
||||
|
||||
/* ctx 0: _, _, _
|
||||
* ctx 1: 3, 4, 5
|
||||
* ctx 2: 6, 7 */
|
||||
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 3);
|
||||
|
||||
/* ctx 0: _, _, _
|
||||
* ctx 1: _, 4, 5
|
||||
* ctx 2: 6, 7 */
|
||||
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 6);
|
||||
|
||||
/* ctx 0: _, _, _
|
||||
* ctx 1: _, 4, 5
|
||||
* ctx 2: _, 7 */
|
||||
|
||||
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 4);
|
||||
|
||||
/* ctx 0: _, _, _
|
||||
* ctx 1: _, _, 5
|
||||
* ctx 2: _, 7 */
|
||||
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 7);
|
||||
|
||||
/* ctx 0: _, _, _
|
||||
* ctx 1: _, _, 5
|
||||
* ctx 2: _, _ */
|
||||
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 5);
|
||||
|
||||
/* ctx 0: _, _, _,
|
||||
* ctx 1: _, _, _
|
||||
* ctx 2: _, _ */
|
||||
|
||||
ocf_freelist_deinit(freelist);
|
||||
}
|
||||
|
||||
static void ocf_freelist_get_cache_line_put(void **state)
|
||||
{
|
||||
unsigned num_cls = 8;
|
||||
unsigned num_ctxts = 3;
|
||||
ocf_freelist_t freelist;
|
||||
unsigned ctx_iter, cl_iter;
|
||||
ocf_cache_line_t line;
|
||||
|
||||
print_test_description("Verify freelist cacheline put");
|
||||
|
||||
will_return_maybe(__wrap_ocf_metadata_collision_table_entries, num_cls);
|
||||
will_return_maybe(__wrap_env_get_execution_context_count, num_ctxts);
|
||||
will_return_maybe(__wrap_metadata_test_valid_any, false);
|
||||
|
||||
ocf_freelist_init(&freelist, NULL);
|
||||
|
||||
ocf_freelist_populate(freelist, num_cls);
|
||||
|
||||
/* get some clines from the freelists */
|
||||
will_return(__wrap_env_get_execution_context, 0);
|
||||
ocf_freelist_get_cache_line(freelist, &line);
|
||||
will_return(__wrap_env_get_execution_context, 0);
|
||||
ocf_freelist_get_cache_line(freelist, &line);
|
||||
will_return(__wrap_env_get_execution_context, 0);
|
||||
ocf_freelist_get_cache_line(freelist, &line);
|
||||
will_return(__wrap_env_get_execution_context, 0);
|
||||
ocf_freelist_get_cache_line(freelist, &line);
|
||||
will_return(__wrap_env_get_execution_context, 0);
|
||||
ocf_freelist_get_cache_line(freelist, &line);
|
||||
|
||||
/* ctx 0:
|
||||
* ctx 1: 4, 5
|
||||
* ctx 2: 7 */
|
||||
|
||||
will_return(__wrap_env_get_execution_context, 1);
|
||||
ocf_freelist_put_cache_line(freelist, 0);
|
||||
|
||||
will_return(__wrap_env_get_execution_context, 1);
|
||||
ocf_freelist_put_cache_line(freelist, 2);
|
||||
|
||||
will_return(__wrap_env_get_execution_context, 2);
|
||||
ocf_freelist_put_cache_line(freelist, 3);
|
||||
|
||||
/* ctx 0:
|
||||
* ctx 1: 4, 5, 0, 2
|
||||
* ctx 2: 7, 3*/
|
||||
|
||||
will_return(__wrap_env_get_execution_context, 1);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 4);
|
||||
|
||||
will_return(__wrap_env_get_execution_context, 1);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 5);
|
||||
|
||||
will_return(__wrap_env_get_execution_context, 1);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 0);
|
||||
|
||||
will_return(__wrap_env_get_execution_context, 1);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 2);
|
||||
|
||||
will_return(__wrap_env_get_execution_context, 2);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 7);
|
||||
|
||||
will_return(__wrap_env_get_execution_context, 2);
|
||||
assert(ocf_freelist_get_cache_line(freelist, &line));
|
||||
assert_int_equal(line, 3);
|
||||
|
||||
ocf_freelist_deinit(freelist);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(ocf_freelist_get_cache_line_get_fast),
|
||||
cmocka_unit_test(ocf_freelist_get_cache_line_get_slow),
|
||||
cmocka_unit_test(ocf_freelist_get_cache_line_put)
|
||||
};
|
||||
|
||||
print_message("Unit test for ocf_freelist_get_cache_line\n");
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* <tested_file_path>src/ocf_freelist.c</tested_file_path>
|
||||
* <tested_function>ocf_freelist_populate</tested_function>
|
||||
* <functions_to_leave>
|
||||
* ocf_freelist_init
|
||||
* ocf_freelist_deinit
|
||||
* </functions_to_leave>
|
||||
*/
|
||||
|
||||
#undef static
|
||||
|
||||
#undef inline
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include "print_desc.h"
|
||||
|
||||
#include "ocf/ocf.h"
|
||||
#include "metadata/metadata.h"
|
||||
|
||||
#include "ocf_freelist.c/ocf_freelist_init_generated_wraps.c"
|
||||
|
||||
ocf_cache_line_t __wrap_ocf_metadata_collision_table_entries(ocf_cache_t cache)
|
||||
{
|
||||
function_called();
|
||||
return mock();
|
||||
}
|
||||
|
||||
ocf_cache_line_t __wrap_env_get_execution_context_count(ocf_cache_t cache)
|
||||
{
|
||||
function_called();
|
||||
return mock();
|
||||
}
|
||||
|
||||
static void ocf_freelist_init_test01(void **state)
|
||||
{
|
||||
unsigned num_cls = 9;
|
||||
unsigned num_ctxts = 3;
|
||||
ocf_freelist_t freelist;
|
||||
ocf_cache_t cache = 0x1234;
|
||||
|
||||
print_test_description("Freelist initialization test");
|
||||
|
||||
expect_function_call(__wrap_ocf_metadata_collision_table_entries);
|
||||
will_return(__wrap_ocf_metadata_collision_table_entries, num_cls);
|
||||
|
||||
expect_function_call(__wrap_env_get_execution_context_count);
|
||||
will_return(__wrap_env_get_execution_context_count, num_ctxts);
|
||||
|
||||
ocf_freelist_init(&freelist, cache);
|
||||
assert(freelist != NULL);
|
||||
|
||||
ocf_freelist_deinit(freelist);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(ocf_freelist_init_test01)
|
||||
};
|
||||
|
||||
print_message("Unit test of ocf_freelist_init\n");
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
@@ -1,213 +0,0 @@
|
||||
/*
|
||||
* <tested_file_path>src/ocf_freelist.c</tested_file_path>
|
||||
* <tested_function>ocf_freelist_get_cache_line</tested_function>
|
||||
* <functions_to_leave>
|
||||
* ocf_freelist_init
|
||||
* ocf_freelist_deinit
|
||||
* ocf_freelist_populate
|
||||
* next_phys_invalid
|
||||
* ocf_freelist_unlock
|
||||
* _ocf_freelist_remove_cache_line
|
||||
* ocf_freelist_get_cache_line_fast
|
||||
* ocf_freelist_get_cache_line_slow
|
||||
* ocf_freelist_add_cache_line
|
||||
* ocf_freelist_get_cache_line_ctx
|
||||
* get_next_victim_freelist
|
||||
* ocf_freelist_put_cache_line
|
||||
* </functions_to_leave>
|
||||
*/
|
||||
|
||||
#undef static
|
||||
|
||||
#undef inline
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include "print_desc.h"
|
||||
|
||||
#include "ocf/ocf.h"
|
||||
#include "metadata/metadata.h"
|
||||
|
||||
#include "ocf_freelist.c/ocf_freelist_get_put_generated_wraps.c"
|
||||
|
||||
ocf_cache_line_t __wrap_ocf_metadata_collision_table_entries(ocf_cache_t cache)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
|
||||
unsigned __wrap_env_get_execution_context_count(void)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
|
||||
unsigned __wrap_env_get_execution_context(void)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
|
||||
void __wrap_env_put_execution_context(unsigned ctx)
|
||||
{
|
||||
}
|
||||
|
||||
/* simulate no striping */
|
||||
ocf_cache_line_t __wrap_ocf_metadata_map_phy2lg(ocf_cache_t cache, ocf_cache_line_t phy)
|
||||
{
|
||||
return phy;
|
||||
}
|
||||
|
||||
bool __wrap_metadata_test_valid_any(ocf_cache_t cache, ocf_cache_line_t cline)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
|
||||
void __wrap_ocf_freelist_lock(ocf_freelist_t freelist, uint32_t ctx)
|
||||
{
|
||||
function_called();
|
||||
check_expected(ctx);
|
||||
}
|
||||
|
||||
int __wrap_ocf_freelist_trylock(ocf_freelist_t freelist, uint32_t ctx)
|
||||
{
|
||||
function_called();
|
||||
check_expected(ctx);
|
||||
return mock();
|
||||
}
|
||||
|
||||
/* metadata partition info interface mock: */
|
||||
|
||||
#define max_clines 100
|
||||
|
||||
struct {
|
||||
ocf_cache_line_t prev;
|
||||
ocf_cache_line_t next;
|
||||
} partition_list[max_clines];
|
||||
|
||||
|
||||
void __wrap_ocf_metadata_set_partition_info(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line, ocf_part_id_t part_id,
|
||||
ocf_cache_line_t next_line, ocf_cache_line_t prev_line)
|
||||
{
|
||||
assert_int_equal(part_id, PARTITION_INVALID);
|
||||
partition_list[line].prev = prev_line;
|
||||
partition_list[line].next = next_line;
|
||||
}
|
||||
|
||||
void __wrap_ocf_metadata_get_partition_info(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line, ocf_part_id_t *part_id,
|
||||
ocf_cache_line_t *next_line, ocf_cache_line_t *prev_line)
|
||||
{
|
||||
if (part_id)
|
||||
*part_id = PARTITION_INVALID;
|
||||
if (prev_line)
|
||||
*prev_line = partition_list[line].prev;
|
||||
if (next_line)
|
||||
*next_line = partition_list[line].next;
|
||||
}
|
||||
|
||||
void __wrap_ocf_metadata_set_partition_prev(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line, ocf_cache_line_t prev_line)
|
||||
{
|
||||
partition_list[line].prev = prev_line;
|
||||
}
|
||||
|
||||
void __wrap_ocf_metadata_set_partition_next(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line, ocf_cache_line_t next_line)
|
||||
{
|
||||
partition_list[line].next = next_line;
|
||||
}
|
||||
|
||||
static void ocf_freelist_get_put_locks(void **state)
|
||||
{
|
||||
unsigned num_cls = 4;
|
||||
unsigned num_ctxts = 3;
|
||||
ocf_freelist_t freelist;
|
||||
unsigned ctx_iter, cl_iter;
|
||||
ocf_cache_line_t line;
|
||||
|
||||
print_test_description("Verify lock/trylock sequence in get free cacheline");
|
||||
|
||||
will_return_maybe(__wrap_ocf_metadata_collision_table_entries, num_cls);
|
||||
will_return_maybe(__wrap_env_get_execution_context_count, num_ctxts);
|
||||
will_return_maybe(__wrap_metadata_test_valid_any, false);
|
||||
|
||||
/* simulate context 1 for the entire test duration */
|
||||
will_return_maybe(__wrap_env_get_execution_context, 1);
|
||||
|
||||
ocf_freelist_init(&freelist, NULL);
|
||||
|
||||
ocf_freelist_populate(freelist, num_cls);
|
||||
|
||||
/****************************************************************/
|
||||
/* verify fast path locking - scucessfull trylock */
|
||||
|
||||
/* ctx 0: 0, 3
|
||||
* ctx 1: 1
|
||||
* ctx 2: 2
|
||||
* slowpath next victim: 0
|
||||
*/
|
||||
|
||||
expect_value(__wrap_ocf_freelist_trylock, ctx, 1);
|
||||
expect_function_call(__wrap_ocf_freelist_trylock);
|
||||
will_return(__wrap_ocf_freelist_trylock, 0);
|
||||
ocf_freelist_get_cache_line(freelist, &line);
|
||||
|
||||
/****************************************************************/
|
||||
/* verify fast path locking - scucessfull trylock in slowpath */
|
||||
|
||||
/* ctx 0: 0, 3
|
||||
* ctx 1:
|
||||
* ctx 2: 2
|
||||
* slowpath next victim: 0 */
|
||||
|
||||
/* we expect trylock for context 0, since context 1 has empty list */
|
||||
expect_value(__wrap_ocf_freelist_trylock, ctx, 0);
|
||||
expect_function_call(__wrap_ocf_freelist_trylock);
|
||||
will_return(__wrap_ocf_freelist_trylock, 0);
|
||||
ocf_freelist_get_cache_line(freelist, &line);
|
||||
|
||||
/****************************************************************/
|
||||
/* verify fast path locking - trylock failure in slowpath */
|
||||
|
||||
/* ctx 0: 3
|
||||
* ctx 1:
|
||||
* ctx 2: 2
|
||||
* slowpath next victim: 1 */
|
||||
|
||||
/* fastpath will fail immediately - context 1 list is empty */
|
||||
/* next slowpath victim context (1) is empty - will move to ctx 2 */
|
||||
/* so now we expect trylock for context no 2 - injecting error here*/
|
||||
expect_value(__wrap_ocf_freelist_trylock, ctx, 2);
|
||||
expect_function_call(__wrap_ocf_freelist_trylock);
|
||||
will_return(__wrap_ocf_freelist_trylock, 1);
|
||||
|
||||
/* slowpath will attempt to trylock next non-empty context - 0
|
||||
* - injecting error here as well */
|
||||
expect_value(__wrap_ocf_freelist_trylock, ctx, 0);
|
||||
expect_function_call(__wrap_ocf_freelist_trylock);
|
||||
will_return(__wrap_ocf_freelist_trylock, 1);
|
||||
|
||||
/* slowpath trylock loop failed - expecting full lock */
|
||||
expect_value(__wrap_ocf_freelist_lock, ctx, 2);
|
||||
expect_function_call(__wrap_ocf_freelist_lock);
|
||||
|
||||
/* execute freelist_get_cache_line */
|
||||
ocf_freelist_get_cache_line(freelist, &line);
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
ocf_freelist_deinit(freelist);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(ocf_freelist_get_put_locks)
|
||||
};
|
||||
|
||||
print_message("Unit test for ocf_freelist_get_cache_line locking\n");
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
@@ -1,138 +0,0 @@
|
||||
/*
|
||||
* <tested_file_path>src/ocf_freelist.c</tested_file_path>
|
||||
* <tested_function>ocf_freelist_populate</tested_function>
|
||||
* <functions_to_leave>
|
||||
* ocf_freelist_init
|
||||
* ocf_freelist_deinit
|
||||
* ocf_freelist_populate
|
||||
* next_phys_invalid
|
||||
* </functions_to_leave>
|
||||
*/
|
||||
|
||||
#undef static
|
||||
|
||||
#undef inline
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include "print_desc.h"
|
||||
|
||||
#include "ocf/ocf.h"
|
||||
#include "metadata/metadata.h"
|
||||
|
||||
#include "ocf_freelist.c/ocf_freelist_populate_generated_wraps.c"
|
||||
|
||||
ocf_cache_line_t __wrap_ocf_metadata_collision_table_entries(ocf_cache_t cache)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
|
||||
ocf_cache_line_t __wrap_env_get_execution_context_count(ocf_cache_t cache)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
|
||||
/* simulate no striping */
|
||||
ocf_cache_line_t __wrap_ocf_metadata_map_phy2lg(ocf_cache_t cache, ocf_cache_line_t phy)
|
||||
{
|
||||
return phy;
|
||||
}
|
||||
|
||||
bool __wrap_metadata_test_valid_any(ocf_cache_t cache, ocf_cache_line_t cline)
|
||||
{
|
||||
return mock();
|
||||
}
|
||||
|
||||
void __wrap_ocf_metadata_set_partition_info(struct ocf_cache *cache,
|
||||
ocf_cache_line_t line, ocf_part_id_t part_id,
|
||||
ocf_cache_line_t next_line, ocf_cache_line_t prev_line)
|
||||
{
|
||||
print_message("%s %u %u %u\n", __func__, prev_line, line, next_line);
|
||||
check_expected(line);
|
||||
check_expected(part_id);
|
||||
check_expected(next_line);
|
||||
check_expected(prev_line);
|
||||
}
|
||||
|
||||
#define expect_set_info(curr, part, next, prev) \
|
||||
expect_value(__wrap_ocf_metadata_set_partition_info, line, curr); \
|
||||
expect_value(__wrap_ocf_metadata_set_partition_info, part_id, part); \
|
||||
expect_value(__wrap_ocf_metadata_set_partition_info, next_line, next); \
|
||||
expect_value(__wrap_ocf_metadata_set_partition_info, prev_line, prev);
|
||||
|
||||
static void ocf_freelist_populate_test01(void **state)
|
||||
{
|
||||
unsigned num_cls = 8;
|
||||
unsigned num_ctxts = 3;
|
||||
ocf_freelist_t freelist;
|
||||
unsigned ctx_iter, cl_iter;
|
||||
|
||||
print_test_description("Verify proper set_partition_info order and arguments - empty cache");
|
||||
|
||||
will_return_maybe(__wrap_ocf_metadata_collision_table_entries, num_cls);
|
||||
will_return_maybe(__wrap_env_get_execution_context_count, num_ctxts);
|
||||
will_return_maybe(__wrap_metadata_test_valid_any, false);
|
||||
|
||||
ocf_freelist_init(&freelist, NULL);
|
||||
|
||||
expect_set_info(0, PARTITION_INVALID, 1 , num_cls);
|
||||
expect_set_info(1, PARTITION_INVALID, 2 , 0);
|
||||
expect_set_info(2, PARTITION_INVALID, num_cls, 1);
|
||||
expect_set_info(3, PARTITION_INVALID, 4 , num_cls);
|
||||
expect_set_info(4, PARTITION_INVALID, 5 , 3);
|
||||
expect_set_info(5, PARTITION_INVALID, num_cls, 4);
|
||||
expect_set_info(6, PARTITION_INVALID, 7 , num_cls);
|
||||
expect_set_info(7, PARTITION_INVALID, num_cls, 6);
|
||||
|
||||
ocf_freelist_populate(freelist, num_cls);
|
||||
|
||||
ocf_freelist_deinit(freelist);
|
||||
}
|
||||
|
||||
static void ocf_freelist_populate_test02(void **state)
|
||||
{
|
||||
unsigned num_cls = 8;
|
||||
unsigned num_ctxts = 3;
|
||||
ocf_freelist_t freelist;
|
||||
unsigned ctx_iter, cl_iter;
|
||||
|
||||
print_test_description("Verify proper set_partition_info order and arguments - some valid clines");
|
||||
|
||||
will_return_maybe(__wrap_ocf_metadata_collision_table_entries, num_cls);
|
||||
will_return_maybe(__wrap_env_get_execution_context_count, num_ctxts);
|
||||
|
||||
ocf_freelist_init(&freelist, NULL);
|
||||
|
||||
/* simulate only cachelines 2, 3, 4, 7 invalid */
|
||||
will_return(__wrap_metadata_test_valid_any, true);
|
||||
will_return(__wrap_metadata_test_valid_any, true);
|
||||
will_return(__wrap_metadata_test_valid_any, false);
|
||||
will_return(__wrap_metadata_test_valid_any, false);
|
||||
will_return(__wrap_metadata_test_valid_any, false);
|
||||
will_return(__wrap_metadata_test_valid_any, true);
|
||||
will_return(__wrap_metadata_test_valid_any, true);
|
||||
will_return(__wrap_metadata_test_valid_any, false);
|
||||
|
||||
expect_set_info(2, PARTITION_INVALID, 3 , num_cls);
|
||||
expect_set_info(3, PARTITION_INVALID, num_cls, 2);
|
||||
expect_set_info(4, PARTITION_INVALID, num_cls, num_cls);
|
||||
expect_set_info(7, PARTITION_INVALID, num_cls, num_cls);
|
||||
|
||||
ocf_freelist_populate(freelist, 4);
|
||||
|
||||
ocf_freelist_deinit(freelist);
|
||||
}
|
||||
int main(void)
|
||||
{
|
||||
const struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test(ocf_freelist_populate_test01),
|
||||
cmocka_unit_test(ocf_freelist_populate_test02)
|
||||
};
|
||||
|
||||
print_message("Unit test of src/ocf_freelist.c\n");
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
}
|
Reference in New Issue
Block a user