From aff597e27ac23930ce99406a59e3209492c5012d Mon Sep 17 00:00:00 2001 From: Konstantin Drabeniuk Date: Thu, 15 Dec 2016 16:41:00 +0200 Subject: [PATCH] ut: improve code coverage of tdm_capture.c Change-Id: I1c3a3899d03e4f32df5dff77fe6b631f38e8e4ee Signed-off-by: Konstantin Drabeniuk Signed-off-by: SooChan Lim --- ut/src/ut_tdm_capture.cpp | 507 +++++++++++++++++++++++++++++++++++++++++++--- ut/stubs/stub_backend.cpp | 15 ++ ut/stubs/stub_backend.h | 2 + ut/stubs/tdm_list_stubs.h | 99 --------- 4 files changed, 501 insertions(+), 122 deletions(-) delete mode 100644 ut/stubs/tdm_list_stubs.h diff --git a/ut/src/ut_tdm_capture.cpp b/ut/src/ut_tdm_capture.cpp index 62d4155..0f5b7af 100644 --- a/ut/src/ut_tdm_capture.cpp +++ b/ut/src/ut_tdm_capture.cpp @@ -30,20 +30,38 @@ #include "tbm_stubs.h" #include "stub_pthread.h" -#include "tdm_list_stubs.h" #include "stub_stdlib.h" #include "stub_backend.h" +#include "stub_unistd.h" +#include "stub_tdm_thread.h" +#include "stub_tdm_buffer.h" +#include "stub_tdm_helper.h" #include "tdm_capture.c" +//local stubs for callbeck functions +static int stub_tdm_capture_done_handler_called; +static void stub_tdm_capture_done_handler(tdm_capture *capture, + tbm_surface_h buffer, void *user_data) +{ + stub_tdm_capture_done_handler_called = 1; +} + /* UNIT TESTS */ static void _init_test() { + stub_tdm_helper_init(); + stub_tdm_buffer_init(); + stub_tdm_thread_init(); + stub_unistd_init(); stub_pthread_init(); stub_backend_init(); stub_tbm_init(); stub_stdlib_init(); + tdm_debug_dump = TDM_DUMP_FLAG_CAPTURE; + tdm_debug_module = TDM_DEBUG_BUFFER; + stub_tdm_capture_done_handler_called = 0; } /* tdm_capture_commit */ @@ -55,9 +73,16 @@ TEST(tdm_capture_commit, work_flow_success_4) struct _tdm_private_display private_display; tdm_private_output private_output; tdm_error expected_error = TDM_ERROR_NONE; + tdm_pp_private_buffer b_1, b_2; _init_test(); + LIST_INITHEAD(&capture.pending_buffer_list); + LIST_INITHEAD(&capture.buffer_list); + + LIST_ADD(&b_1.link, &capture.pending_buffer_list); + LIST_ADD(&b_2.link, &capture.pending_buffer_list); + capture.private_display = &private_display; private_display.func_capture.capture_commit = capture_commit; CALLOC_RETURN_BUFFER = 1; @@ -67,6 +92,7 @@ TEST(tdm_capture_commit, work_flow_success_4) error = tdm_capture_commit(&capture); ASSERT_EQ(error, expected_error); + ASSERT_EQ(LIST_LENGTH(&capture.buffer_list), 2); } TEST(tdm_capture_commit, work_flow_success_3) @@ -75,10 +101,16 @@ TEST(tdm_capture_commit, work_flow_success_3) struct _tdm_private_capture capture; struct _tdm_private_display private_display; tdm_private_output private_output; - tdm_error not_expected_error = TDM_ERROR_NONE; + tdm_pp_private_buffer b_1, b_2; _init_test(); + LIST_INITHEAD(&capture.pending_buffer_list); + LIST_INITHEAD(&capture.buffer_list); + + LIST_ADD(&b_1.link, &capture.pending_buffer_list); + LIST_ADD(&b_2.link, &capture.pending_buffer_list); + capture.private_display = &private_display; private_display.func_capture.capture_commit = capture_commit; CAPTURE_COMMIT_ERROR = 1; @@ -87,7 +119,10 @@ TEST(tdm_capture_commit, work_flow_success_3) error = tdm_capture_commit(&capture); - ASSERT_NE(error, not_expected_error); + ASSERT_NE(error, TDM_ERROR_NONE); + ASSERT_EQ(LIST_LENGTH(&capture.buffer_list), 0); + ASSERT_EQ(stub_tdm_buffer_remove_release_handler_internal_count, 2); + ASSERT_EQ(stub_tdm_buffer_unref_backend_count, 2); } TEST(tdm_capture_commit, work_flow_success_2) @@ -100,6 +135,8 @@ TEST(tdm_capture_commit, work_flow_success_2) _init_test(); + LIST_INITHEAD(&capture.pending_buffer_list); + capture.private_display = &private_display; private_display.func_capture.capture_commit = NULL; capture.private_output = &private_output; @@ -120,6 +157,8 @@ TEST(tdm_capture_commit, work_flow_success_1) _init_test(); + LIST_INITHEAD(&capture.pending_buffer_list); + capture.private_display = &private_display; private_display.func_capture.capture_commit = NULL; capture.private_output = &private_output; @@ -142,36 +181,25 @@ TEST(tdm_capture_commit, null_ptr_fail_1) ASSERT_EQ(error, expected_error); } -/* tdm_capture_attach */ +/* tdm_capture_set_info */ -TEST(tdm_capture_attach, null_ptr_fail_2) +TEST(tdm_capture_set_info, error_capture_set_info_is_null) { - tdm_error error = TDM_ERROR_NONE; + tdm_info_capture info; + tdm_error error; struct _tdm_private_capture capture; - tdm_error expected_error = TDM_ERROR_INVALID_PARAMETER; + struct _tdm_private_display private_display; _init_test(); - error = tdm_capture_attach(&capture, NULL); - - ASSERT_EQ(error, expected_error); -} - -TEST(tdm_capture_attach, null_ptr_fail_1) -{ - tdm_error error = TDM_ERROR_NONE; - struct _tbm_surface buffer; - tdm_error expected_error = TDM_ERROR_INVALID_PARAMETER; - - _init_test(); + capture.private_display = &private_display; + private_display.func_capture.capture_set_info = NULL; - error = tdm_capture_attach(NULL, &buffer); + error = tdm_capture_set_info(&capture, &info); - ASSERT_EQ(error, expected_error); + ASSERT_EQ(error, TDM_ERROR_NOT_IMPLEMENTED); } -/* tdm_capture_set_info */ - TEST(tdm_capture_set_info, work_flow_success_2) { tdm_info_capture info; @@ -179,15 +207,24 @@ TEST(tdm_capture_set_info, work_flow_success_2) struct _tdm_private_capture capture; struct _tdm_private_display private_display; tdm_error expected_error = TDM_ERROR_NONE; + tdm_private_output private_output; + tdm_output_mode current_mode; _init_test(); + capture.private_output = &private_output; + private_output.current_mode = ¤t_mode; + current_mode.vrefresh = 24; + info.type = TDM_CAPTURE_TYPE_STREAM; + info.frequency = 0; + capture.private_display = &private_display; private_display.func_capture.capture_set_info = capture_set_info; error = tdm_capture_set_info(&capture, &info); ASSERT_EQ(error, expected_error); + ASSERT_EQ(info.frequency, current_mode.vrefresh); } TEST(tdm_capture_set_info, work_flow_success_1) @@ -249,6 +286,9 @@ TEST(tdm_capture_create_layer_internal, work_flow_success_4) _init_test(); + LIST_INITHEAD(&private_layer.capture_list); + LIST_INITHEAD(&private_display.capture_list); + private_layer.private_output = &private_output; private_output.private_display = &private_display; private_display.func_layer.layer_create_capture = layer_create_capture; @@ -275,6 +315,9 @@ TEST(tdm_capture_create_layer_internal, work_flow_success_3) _init_test(); + LIST_INITHEAD(&private_layer.capture_list); + LIST_INITHEAD(&private_display.capture_list); + private_layer.private_output = &private_output; private_output.private_display = &private_display; private_display.func_layer.layer_create_capture = layer_create_capture; @@ -301,6 +344,9 @@ TEST(tdm_capture_create_layer_internal, work_flow_success_2) _init_test(); + LIST_INITHEAD(&private_layer.capture_list); + LIST_INITHEAD(&private_display.capture_list); + private_layer.private_output = &private_output; private_output.private_display = &private_display; private_display.func_layer.layer_create_capture = layer_create_capture; @@ -325,6 +371,9 @@ TEST(tdm_capture_create_layer_internal, work_flow_success_1) _init_test(); + LIST_INITHEAD(&private_layer.capture_list); + LIST_INITHEAD(&private_display.capture_list); + private_layer.private_output = &private_output; private_output.private_display = &private_display; private_display.capabilities = TDM_DISPLAY_CAPABILITY_PP; @@ -345,9 +394,13 @@ TEST(tdm_capture_create_output_internal, work_flow_success_5) tdm_private_capture *actual; tdm_private_capture *not_expected = NULL; tdm_error expected_error = TDM_ERROR_NONE; + tdm_private_capture private_capture; _init_test(); + LIST_INITHEAD(&private_output.capture_list); + LIST_INITHEAD(&private_display.capture_list); + private_output.private_display = &private_display; private_display.func_output.output_create_capture = output_create_capture; private_display.func_capture.capture_destroy = capture_destroy; @@ -356,6 +409,10 @@ TEST(tdm_capture_create_output_internal, work_flow_success_5) private_display.capabilities = TDM_DISPLAY_CAPABILITY_CAPTURE; private_display.caps_capture.capabilities = TDM_CAPTURE_CAPABILITY_OUTPUT; + private_capture.stamp = stub_tdm_helper_get_time_ret_val; + + LIST_ADD(&private_capture.display_link, &private_display.capture_list); + actual = tdm_capture_create_output_internal(&private_output, &error); ASSERT_EQ(error, expected_error); @@ -374,6 +431,9 @@ TEST(tdm_capture_create_output_internal, work_flow_success_4) _init_test(); + LIST_INITHEAD(&private_output.capture_list); + LIST_INITHEAD(&private_display.capture_list); + private_output.private_display = &private_display; private_display.func_output.output_create_capture = output_create_capture; private_display.func_capture.capture_destroy = capture_destroy; @@ -399,6 +459,9 @@ TEST(tdm_capture_create_output_internal, work_flow_success_3) _init_test(); + LIST_INITHEAD(&private_output.capture_list); + LIST_INITHEAD(&private_display.capture_list); + private_output.private_display = &private_display; private_display.func_output.output_create_capture = output_create_capture; private_display.func_capture.capture_destroy = capture_destroy; @@ -423,6 +486,9 @@ TEST(tdm_capture_create_output_internal, work_flow_success_2) _init_test(); + LIST_INITHEAD(&private_output.capture_list); + LIST_INITHEAD(&private_display.capture_list); + private_output.private_display = &private_display; private_display.func_output.output_create_capture = output_create_capture; private_display.capabilities = TDM_DISPLAY_CAPABILITY_CAPTURE; @@ -446,6 +512,9 @@ TEST(tdm_capture_create_output_internal, work_flow_success_1) _init_test(); + LIST_INITHEAD(&private_output.capture_list); + LIST_INITHEAD(&private_display.capture_list); + private_output.private_display = &private_display; private_display.capabilities = TDM_DISPLAY_CAPABILITY_PP; actual = tdm_capture_create_output_internal(&private_output, &error); @@ -453,3 +522,395 @@ TEST(tdm_capture_create_output_internal, work_flow_success_1) ASSERT_EQ(error, expected_error); ASSERT_TRUE(actual == expected); } + +TEST(tdm_capture_create_output_internal, TDM_CAPTURE_CAPABILITY_OUTPUT_is_not_set) +{ + tdm_error error = TDM_ERROR_NONE; + struct _tdm_private_output private_output; + struct _tdm_private_display private_display; + tdm_private_capture *actual; + tdm_private_capture *expected = NULL; + tdm_error expected_error = TDM_ERROR_NO_CAPABILITY; + + _init_test(); + + LIST_INITHEAD(&private_output.capture_list); + LIST_INITHEAD(&private_display.capture_list); + + private_output.private_display = &private_display; + private_display.capabilities = TDM_DISPLAY_CAPABILITY_CAPTURE; + private_display.caps_capture.capabilities = TDM_CAPTURE_CAPABILITY_LAYER; + + actual = tdm_capture_create_output_internal(&private_output, &error); + + ASSERT_EQ(error, expected_error); + ASSERT_TRUE(actual == expected); +} + +/* tdm_capture_cb_done() */ + +TEST(tdm_capture_cb_done, success_not_in_display_thread) +{ + tdm_private_capture private_capture; + struct _tbm_surface buffer; + tdm_thread_cb_capture_done *capture_done; + tdm_private_display private_display; + + _init_test(); + + private_capture.private_display = &private_display; + stub_syscall_return_value = 50; + private_capture.owner_tid = stub_syscall_return_value + 1; + private_capture.stamp = 10.15; + + tdm_capture_cb_done(&private_capture, &buffer, &private_capture); + + capture_done = (tdm_thread_cb_capture_done *)stub_tdm_thread_send_cb_buff; + + ASSERT_EQ(capture_done->base.type, TDM_THREAD_CB_CAPTURE_DONE); + ASSERT_EQ(capture_done->base.length, sizeof * capture_done); + ASSERT_DOUBLE_EQ(capture_done->capture_stamp, private_capture.stamp); + ASSERT_TRUE(capture_done->buffer == &buffer); + ASSERT_TRUE(capture_done->user_data == &private_capture); +} + +TEST(tdm_capture_cb_done, success_in_display_thread) +{ + tdm_private_capture private_capture; + struct _tbm_surface buffer; + tdm_thread_cb_capture_done *capture_done; + tdm_private_display private_display; + tdm_capture_private_buffer *capture_buffer_1; + tdm_capture_private_buffer *capture_buffer_2; + + _init_test(); + + capture_buffer_1 = (tdm_capture_private_buffer *) + calloc(1, sizeof * capture_buffer_1); + capture_buffer_2 = (tdm_capture_private_buffer *) + calloc(1, sizeof * capture_buffer_2); + + LIST_INITHEAD(&private_capture.buffer_list); + LIST_ADD(&capture_buffer_1->link, &private_capture.buffer_list); + LIST_ADD(&capture_buffer_2->link, &private_capture.buffer_list); + + capture_buffer_1->buffer = &buffer; + + private_capture.private_display = &private_display; + stub_syscall_return_value = 50; + stub_syscall_reset = 1; + private_capture.owner_tid = stub_syscall_return_value; + private_capture.done_func = stub_tdm_capture_done_handler; + + tdm_capture_cb_done(&private_capture, &buffer, &private_capture); + + ASSERT_EQ(FREE_CALLED, 1); + ASSERT_EQ(stub_tdm_capture_done_handler_called, 1); + ASSERT_EQ(stub_tdm_buffer_unref_backend_count, 1); + ASSERT_TRUE(!_tdm_capture_find_tbm_buffer(&private_capture.buffer_list, &buffer)); +} + +/* tdm_capture_find_stamp() */ + +TEST(tdm_capture_find_stamp, success_capture_list_is_empty) +{ + tdm_private_capture *capture_ret; + tdm_private_display private_display; + + _init_test(); + + LIST_INITHEAD(&private_display.capture_list); + + capture_ret = tdm_capture_find_stamp(&private_display, 0.5); + + ASSERT_EQ(capture_ret, NULL); +} + +TEST(tdm_capture_find_stamp, success) +{ + tdm_private_capture *capture_ret; + tdm_private_display private_display; + double stamp = 54.54; + tdm_private_capture capture; + + _init_test(); + + capture.stamp = stamp; + + LIST_INITHEAD(&private_display.capture_list); + LIST_ADD(&capture.display_link, &private_display.capture_list); + + capture_ret = tdm_capture_find_stamp(&private_display, stamp); + + ASSERT_EQ(capture_ret, &capture); +} + +/* tdm_capture_destroy_internal() */ + +TEST(tdm_capture_destroy_internal, success) +{ + tdm_private_capture *capture; + tdm_private_display private_display; + struct list_head list; + struct list_head dsp_list; + tdm_buffer_info *b1, *b2; + + _init_test(); + + b1 = (tdm_buffer_info *)calloc(1, sizeof * b1); + b2 = (tdm_buffer_info *)calloc(1, sizeof * b2); + + capture = (tdm_private_capture *)calloc(1, sizeof * capture); + capture->private_display = &private_display; + + private_display.func_capture.capture_destroy = capture_destroy; + + LIST_INITHEAD(&list); + LIST_INITHEAD(&dsp_list); + LIST_INITHEAD(&capture->pending_buffer_list); + LIST_INITHEAD(&capture->buffer_list); + + LIST_ADD(&capture->link, &list); + LIST_ADD(&capture->display_link, &dsp_list); + LIST_ADD(&b1->link, &capture->pending_buffer_list); + LIST_ADD(&b2->link, &capture->buffer_list); + + tdm_capture_destroy_internal(capture); + + ASSERT_TRUE(LIST_IS_EMPTY(&list)); + ASSERT_TRUE(LIST_IS_EMPTY(&dsp_list)); + ASSERT_EQ(stub_tdm_buffer_unref_backend_count, 2); + ASSERT_EQ(FREE_CALLED, 1); + ASSERT_EQ(capture_destroy_is_called, 1); +} + +/* tdm_capture_destroy() */ + +TEST(tdm_capture_destroy, success) +{ + tdm_private_capture *capture; + tdm_private_display private_display; + struct list_head list; + struct list_head dsp_list; + tdm_buffer_info *b1, *b2; + + _init_test(); + + b1 = (tdm_buffer_info *)calloc(1, sizeof * b1); + b2 = (tdm_buffer_info *)calloc(1, sizeof * b2); + + capture = (tdm_private_capture *)calloc(1, sizeof * capture); + capture->private_display = &private_display; + + private_display.func_capture.capture_destroy = capture_destroy; + + LIST_INITHEAD(&list); + LIST_INITHEAD(&dsp_list); + LIST_INITHEAD(&capture->pending_buffer_list); + LIST_INITHEAD(&capture->buffer_list); + + LIST_ADD(&capture->link, &list); + LIST_ADD(&capture->display_link, &dsp_list); + LIST_ADD(&b1->link, &capture->pending_buffer_list); + LIST_ADD(&b2->link, &capture->buffer_list); + + tdm_capture_destroy(capture); + + ASSERT_TRUE(LIST_IS_EMPTY(&list)); + ASSERT_TRUE(LIST_IS_EMPTY(&dsp_list)); + ASSERT_EQ(stub_tdm_buffer_unref_backend_count, 2); + ASSERT_EQ(FREE_CALLED, 1); + ASSERT_EQ(capture_destroy_is_called, 1); +} + +/* tdm_capture_set_done_handler() */ + +TEST(tdm_capture_set_done_handler, error_capture_is_null) +{ + tdm_error error; + + error = tdm_capture_set_done_handler(NULL, stub_tdm_capture_done_handler, NULL); + + ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER); +} + +TEST(tdm_capture_set_done_handler, error_func_is_null) +{ + tdm_error error; + tdm_private_capture capture; + + error = tdm_capture_set_done_handler(&capture, NULL, NULL); + + ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER); +} + +TEST(tdm_capture_set_done_handler, success) +{ + tdm_error error; + tdm_private_capture capture; + int user_data; + + error = tdm_capture_set_done_handler(&capture, stub_tdm_capture_done_handler, &user_data); + + ASSERT_EQ(error, TDM_ERROR_NONE); + ASSERT_TRUE(capture.done_func == stub_tdm_capture_done_handler); + ASSERT_TRUE(capture.done_user_data == &user_data); +} + +/* tdm_capture_attach() */ + +TEST(tdm_capture_attach, error_buffer_is_null) +{ + tdm_error error = TDM_ERROR_NONE; + struct _tdm_private_capture capture; + tdm_error expected_error = TDM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = tdm_capture_attach(&capture, NULL); + + ASSERT_EQ(error, expected_error); +} + +TEST(tdm_capture_attach, error_capture_is_null) +{ + tdm_error error = TDM_ERROR_NONE; + struct _tbm_surface buffer; + + _init_test(); + + error = tdm_capture_attach(NULL, &buffer); + + ASSERT_EQ(error, TDM_ERROR_INVALID_PARAMETER); +} + +TEST(tdm_capture_attach, error_func_capture_attach_is_null) +{ + tdm_error error = TDM_ERROR_NONE; + struct _tdm_private_capture capture; + struct _tbm_surface buffer; + tdm_private_display dsp; + + _init_test(); + + capture.private_display = &dsp; + dsp.func_capture.capture_attach = NULL; + + error = tdm_capture_attach(&capture, &buffer); + + ASSERT_EQ(error, TDM_ERROR_NOT_IMPLEMENTED); +} + +TEST(tdm_capture_attach, error_length_of_pending_buffer_list_ge_max_attach_count) +{ + tdm_error error = TDM_ERROR_NONE; + struct _tdm_private_capture capture; + struct _tbm_surface buffer; + tdm_private_display dsp; + tdm_backend_module module; + tdm_capture_private_buffer b1, b2; + + _init_test(); + + capture.private_display = &dsp; + dsp.func_capture.capture_attach = capture_attach; + + dsp.module_data = &module; + module.abi_version = 0x000100002; + + LIST_INITHEAD(&capture.pending_buffer_list); + LIST_INITHEAD(&capture.buffer_list); + LIST_ADD(&b1.link, &capture.pending_buffer_list); + LIST_ADD(&b2.link, &capture.pending_buffer_list); + + dsp.caps_capture.max_attach_count = 1; + + error = tdm_capture_attach(&capture, &buffer); + + ASSERT_EQ(error, TDM_ERROR_BAD_REQUEST); +} + +TEST(tdm_capture_attach, error_calloc) +{ + tdm_error error = TDM_ERROR_NONE; + struct _tdm_private_capture capture; + struct _tbm_surface buffer; + tdm_private_display dsp; + tdm_backend_module module; + + _init_test(); + + capture.private_display = &dsp; + dsp.func_capture.capture_attach = capture_attach; + + dsp.module_data = &module; + module.abi_version = 0x000100002; + + LIST_INITHEAD(&capture.pending_buffer_list); + LIST_INITHEAD(&capture.buffer_list); + + dsp.caps_capture.max_attach_count = 3; + + CALLOC_ERROR = 1; + + error = tdm_capture_attach(&capture, &buffer); + + ASSERT_EQ(error, TDM_ERROR_OUT_OF_MEMORY); +} + +TEST(tdm_capture_attach, error_capture_attach) +{ + tdm_error error = TDM_ERROR_NONE; + struct _tdm_private_capture capture; + struct _tbm_surface buffer; + tdm_private_display dsp; + tdm_backend_module module; + + _init_test(); + + capture.private_display = &dsp; + dsp.func_capture.capture_attach = capture_attach; + + dsp.module_data = &module; + module.abi_version = 0x000100002; + + LIST_INITHEAD(&capture.pending_buffer_list); + LIST_INITHEAD(&capture.buffer_list); + + dsp.caps_capture.max_attach_count = 3; + + CAPTURE_ATTACH_ERROR = 1; + + error = tdm_capture_attach(&capture, &buffer); + + ASSERT_NE(error, TDM_ERROR_NONE); +} + +TEST(tdm_capture_attach, success) +{ + tdm_error error = TDM_ERROR_NONE; + struct _tdm_private_capture capture; + struct _tbm_surface buffer; + tdm_private_display dsp; + tdm_backend_module module; + tdm_capture_private_buffer *capture_buffer; + + _init_test(); + + capture.private_display = &dsp; + dsp.func_capture.capture_attach = capture_attach; + + dsp.module_data = &module; + module.abi_version = 0x000100002; + + LIST_INITHEAD(&capture.pending_buffer_list); + LIST_INITHEAD(&capture.buffer_list); + + dsp.caps_capture.max_attach_count = 3; + + error = tdm_capture_attach(&capture, &buffer); + + ASSERT_EQ(error, TDM_ERROR_NONE); + ASSERT_TRUE(!LIST_IS_EMPTY(&capture.pending_buffer_list)); + free(container_of(capture.pending_buffer_list.next, capture_buffer, link)); +} diff --git a/ut/stubs/stub_backend.cpp b/ut/stubs/stub_backend.cpp index 3d28349..5c78afa 100644 --- a/ut/stubs/stub_backend.cpp +++ b/ut/stubs/stub_backend.cpp @@ -25,6 +25,7 @@ int LAYER_SET_VIDEO_POS_ERROR; int PP_SET_INFO_ERROR; int PP_COMMIT_ERROR; unsigned int layer_get_buffer_flags_ret; +int capture_destroy_is_called; void stub_backend_init() { @@ -52,6 +53,7 @@ void stub_backend_init() PP_SET_INFO_ERROR = 0; PP_COMMIT_ERROR = 0; layer_get_buffer_flags_ret = 20; + capture_destroy_is_called = 0; } tdm_capture *output_create_capture(tdm_output *output, tdm_error *error) @@ -72,6 +74,8 @@ tdm_capture *output_create_capture(tdm_output *output, tdm_error *error) void capture_destroy(tdm_capture *capture) { (void)capture; + + capture_destroy_is_called = 1; } tdm_error capture_set_done_handler(tdm_capture *capture, @@ -360,3 +364,14 @@ tdm_error layer_get_buffer_flags(tdm_layer *layer, unsigned int *flags) return TDM_ERROR_NONE; } + +tdm_error capture_attach(tdm_capture *capture, tbm_surface_h buffer) +{ + (void)capture; + (void)buffer; + + if (CAPTURE_ATTACH_ERROR) + return TDM_ERROR_OPERATION_FAILED; + + return TDM_ERROR_NONE; +} diff --git a/ut/stubs/stub_backend.h b/ut/stubs/stub_backend.h index a47f1b3..a9c30d9 100644 --- a/ut/stubs/stub_backend.h +++ b/ut/stubs/stub_backend.h @@ -29,6 +29,7 @@ extern int LAYER_SET_VIDEO_POS_ERROR; extern int PP_SET_INFO_ERROR; extern int PP_COMMIT_ERROR; extern unsigned int layer_get_buffer_flags_ret; +extern int capture_destroy_is_called; void stub_backend_init(); @@ -91,5 +92,6 @@ tdm_error output_set_dpms_handler(tdm_output *output, tdm_error layer_get_buffer_flags(tdm_layer *layer, unsigned int *flags); +tdm_error capture_attach(tdm_capture *capture, tbm_surface_h buffer); #endif /* _TDM_CAPTURE_STUBS_H */ diff --git a/ut/stubs/tdm_list_stubs.h b/ut/stubs/tdm_list_stubs.h deleted file mode 100644 index ae1c20b..0000000 --- a/ut/stubs/tdm_list_stubs.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * \file - * List macros heavily inspired by the Linux kernel - * list handling. No list looping yet. - * - * Is not threadsafe, so common operations need to - * be protected using an external mutex. - */ -#ifndef _U_DOUBLE_LIST_H_ -#define _U_DOUBLE_LIST_H_ - -#include - -struct list_head { - struct list_head *prev; - struct list_head *next; -}; - -static inline void list_inithead(struct list_head *item) -{ - (void)item; -} - -static inline void list_add(struct list_head *item, struct list_head *list) -{ - (void)item; - (void)list; -} - -static inline void list_addtail(struct list_head *item, struct list_head *list) -{ - (void)item; - (void)list; -} - -static inline void list_replace(struct list_head *from, struct list_head *to) -{ - (void)from; - (void)to; -} - -static inline void list_del(struct list_head *item) -{ - (void)item; -} - -static inline void list_delinit(struct list_head *item) -{ - (void)item; -} - -#define LIST_INITHEAD(__item) list_inithead(__item) -#define LIST_ADD(__item, __list) list_add(__item, __list) -#define LIST_ADDTAIL(__item, __list) list_addtail(__item, __list) -#define LIST_REPLACE(__from, __to) list_replace(__from, __to) -#define LIST_DEL(__item) list_del(__item) -#define LIST_DELINIT(__item) list_delinit(__item) - -#define LIST_ENTRY(__type, __item, __field) \ - ((__type *)(((char *)(__item)) - offsetof(__type, __field))) - -#define LIST_IS_EMPTY(__list) \ - ((__list)->next == (__list)) - -#ifndef container_of -#define container_of(ptr, sample, member) \ - (void *)((char *)(ptr) \ - - ((char *)&(sample)->member - (char *)(sample))) -#endif - -#define LIST_FOR_EACH_ENTRY(pos, head, member) \ - for (; \ - 1 < 0; \ - ) - -#define LIST_FOR_EACH_ENTRY_SAFE(pos, storage, head, member) \ - for (; \ - 1 < 0; \ - ) - -#define LIST_FOR_EACH_ENTRY_SAFE_REV(pos, storage, head, member) \ - for (pos = container_of((head)->prev, pos, member), \ - storage = container_of(pos->member.prev, pos, member); \ - &pos->member != (head); \ - pos = storage, storage = container_of(storage->member.prev, storage, member)) - -#define LIST_FOR_EACH_ENTRY_FROM(pos, start, head, member) \ - for (pos = container_of((start), pos, member); \ - &pos->member != (head); \ - pos = container_of(pos->member.next, pos, member)) - -#define LIST_FOR_EACH_ENTRY_FROM_REV(pos, start, head, member) \ - for (pos = container_of((start), pos, member); \ - &pos->member != (head); \ - pos = container_of(pos->member.prev, pos, member)) - -#define LIST_LENGTH(__item) 1 - -#endif /*_U_DOUBLE_LIST_H_*/ -- 2.7.4