UT framerwok: Auto generating wrap functions

Test code have to contain wraps only for those functions, which are used by
test itself. Empty wraps are generated automatically by UT framework.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk
2019-05-29 10:30:18 -04:00
parent 2f29e57b97
commit 3e2ee7a7c8
14 changed files with 151 additions and 534 deletions

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)
{