diff --git a/CMakeLists.txt b/CMakeLists.txt index 763a33c..5b72220 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ endif() set(CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE}" CACHE STRING "" FORCE) if (NOT DEFINED ENV{BUILD_BINARIESDIRECTORY}) - MESSAGE(FATAL_ERROR "cannot find BUILD_BINARIESDIRECTORY env variable which is absolutely needed. It can point to any folder where the binaries will pe placed. Here's an example: BUILD_BINARIESDIRECTORY=d:\\BUILD_BINARIESDIRECTORY") + MESSAGE(FATAL_ERROR "cannot find BUILD_BINARIESDIRECTORY env variable which is absolutely needed. It can point to any folder where the binaries will pe placed. Here's an example: \nWindows:\nset BUILD_BINARIESDIRECTORY=d:\\BUILD_BINARIESDIRECTORY\nWSL:\nexport BUILD_BINARIESDIRECTORY=/mnt/d/r/BUILD_BINARIESDIRECTORY/linux") endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG $ENV{BUILD_BINARIESDIRECTORY}/Debug) diff --git a/common/inc/c_pal/thandle_ll.h b/common/inc/c_pal/thandle_ll.h index 11a2cf0..d61fc13 100644 --- a/common/inc/c_pal/thandle_ll.h +++ b/common/inc/c_pal/thandle_ll.h @@ -113,20 +113,44 @@ typedef struct THANDLE_LL_TYPE_STRUCT_TYPE_TAG(T) /*given a previous type T, THANDLE_ASSIGN introduces a new name for a function that does T1=T2 (with inc/dec refs)*/ #define THANDLE_ASSIGN(T) MU_C2(T,_ASSIGN) +/*given a previous type T, THANDLE_ASSIGN_FUNCTION_TYPE introduces the name of the type of the function that does THANDLE_ASSIGN*/ +#define THANDLE_ASSIGN_FUNCTION_TYPE(T) MU_C2(THANDLE_ASSIGN_TYPE_, T) + +/*given a previous type T, THANDLE_ASSIGN_FUNCTION_TYPE_DECLARE(T) introduces the type of the function that does THANDLE_ASSIGN*/ +#define THANDLE_ASSIGN_FUNCTION_TYPE_DECLARE(T) typedef void (* THANDLE_ASSIGN_FUNCTION_TYPE(T))(THANDLE(T) * t1, THANDLE(T) t2); + /*given a previous type T, THANDLE_INITIALIZE introduces a new name for a function that does T1=T2 (with inc ref, and considers T1 as uninitialized memory)*/ #define THANDLE_INITIALIZE(T) MU_C2(T,_INITIALIZE) -/*given a previous type T (and its THANDLE(T)), THANDLE_GET_T introduces a new name for a function that returns the T* from under the THANDLE(T)*/ -#define THANDLE_GET_T(T) MU_C2(T,_GET_T) +/*given a previous type T, THANDLE_INITIALIZE_FUNCTION_TYPE introduces the name of the type of the function that does THANDLE_INITIALIZE*/ +#define THANDLE_INITIALIZE_FUNCTION_TYPE(T) MU_C2(THANDLE_INITIALIZE_TYPE_, T) + +/*given a previous type T, THANDLE_INITIALIZE_FUNCTION_TYPE_DECLARE(T) introduces the type of the function that does THANDLE_INITIALIZE*/ +#define THANDLE_INITIALIZE_FUNCTION_TYPE_DECLARE(T) typedef void (* THANDLE_INITIALIZE_FUNCTION_TYPE(T))(THANDLE(T) * t1, THANDLE(T) t2); /*given a previous type T (and its THANDLE(T)), THANDLE_MOVE introduces a new name for a function that moves a handle to another handle. Move does not increment the ref count, and NULLs the source*/ #define THANDLE_MOVE(T) MU_C2(T,_MOVE) +/*given a previous type T, THANDLE_MOVE_FUNCTION_TYPE introduces the name of the type of the function that does THANDLE_MOVE*/ +#define THANDLE_MOVE_FUNCTION_TYPE(T) MU_C2(THANDLE_MOVE_TYPE_, T) + +/*given a previous type T, THANDLE_MOVE_FUNCTION_TYPE_DECLARE(T) introduces the type of the function that does THANDLE_MOVE*/ +#define THANDLE_MOVE_FUNCTION_TYPE_DECLARE(T) typedef void (* THANDLE_MOVE_FUNCTION_TYPE(T))(THANDLE(T) * t1, THANDLE(T) *t2); + /*given a previous type T (and its THANDLE(T)), THANDLE_INITIALIZE_MOVE introduces a new name for a function that moves a handle to another handle. INITIALIZE_MOVE does not increment the ref count, and NULLs the source. INITIALIZE_MOVE assumes that destination is not initialized and thus it does not decrement the destination ref count */ #define THANDLE_INITIALIZE_MOVE(T) MU_C2(T,_INITIALIZE_MOVE) +/*given a previous type T, THANDLE_INITIALIZE_MOVE_FUNCTION_TYPE introduces the name of the type of the function that does THANDLE_INITIALIZE_MOVE*/ +#define THANDLE_INITIALIZE_MOVE_FUNCTION_TYPE(T) MU_C2(THANDLE_INITIALIZE_MOVE_TYPE_, T) + +/*given a previous type T, THANDLE_INITIALIZE_MOVE_FUNCTION_TYPE_DECLARE(T) introduces the type of the function that does THANDLE_INITIALIZE_MOVE*/ +#define THANDLE_INITIALIZE_MOVE_FUNCTION_TYPE_DECLARE(T) typedef void (* THANDLE_INITIALIZE_MOVE_FUNCTION_TYPE(T))(THANDLE(T) * t1, THANDLE(T) *t2); + +/*given a previous type T (and its THANDLE(T)), THANDLE_GET_T introduces a new name for a function that returns the T* from under the THANDLE(T)*/ +#define THANDLE_GET_T(T) MU_C2(T,_GET_T) + /*THANDLE_MALLOC_WITH_MALLOC_FUNCTIONS returns a new T* using malloc_function (if not NULL) or THANDLE_LL_TYPE_STRUCT_VAR.malloc (if not NULL) or malloc*/ #define THANDLE_LL_MALLOC_WITH_MALLOC_FUNCTIONS_MACRO(C, T) \ static T* THANDLE_MALLOC_WITH_MALLOC_FUNCTIONS(C)(void(*dispose)(T*), THANDLE_LL_MALLOC_FUNCTION_POINTER_T malloc_function, THANDLE_LL_FREE_FUNCTION_POINTER_T free_function) \ @@ -579,6 +603,10 @@ void THANDLE_INITIALIZE_MOVE(C)(THANDLE(T) * t1, THANDLE(T) * t2) /*introduces an incomplete type based on a MU_DEFINE_STRUCT(T...) previously defined;*/ \ #define THANDLE_LL_TYPE_DECLARE(C,T) \ THANDLE_MACRO(T); \ + THANDLE_ASSIGN_FUNCTION_TYPE_DECLARE(T); \ + THANDLE_INITIALIZE_FUNCTION_TYPE_DECLARE(T); \ + THANDLE_MOVE_FUNCTION_TYPE_DECLARE(T); \ + THANDLE_INITIALIZE_MOVE_FUNCTION_TYPE_DECLARE(T); \ MOCKABLE_FUNCTION(, void, THANDLE_ASSIGN(C), THANDLE(T) *, t1, THANDLE(T), t2 ); \ MOCKABLE_FUNCTION(, void, THANDLE_INITIALIZE(C), THANDLE(T) *, t1, THANDLE(T), t2 ); \ MOCKABLE_FUNCTION(, void, THANDLE_MOVE(C), THANDLE(T) *, t1, THANDLE(T)*, t2 ); \ diff --git a/common/inc/c_pal/thandle_log_context_handle.h b/common/inc/c_pal/thandle_log_context_handle.h new file mode 100644 index 0000000..f47f517 --- /dev/null +++ b/common/inc/c_pal/thandle_log_context_handle.h @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#ifndef THANDLE_LOG_CONTEXT_HANDLE_H +#define THANDLE_LOG_CONTEXT_HANDLE_H + +#include "macro_utils/macro_utils.h" + +#include "c_logging/log_context.h" + +#include "c_pal/thandle_ll.h" +#include "c_pal/thandle.h" +#include "c_pal/thandle_ptr.h" + +#include "umock_c/umock_c_prod.h" +#ifdef __cplusplus +extern "C" +{ +#endif + + THANDLE_PTR_DECLARE(LOG_CONTEXT_HANDLE); + +#ifdef __cplusplus +} +#endif + +#endif /*THANDLE_LOG_CONTEXT_HANDLE_H*/ diff --git a/common/inc/c_pal/thandle_ptr.h b/common/inc/c_pal/thandle_ptr.h index 79a0470..91b61e1 100644 --- a/common/inc/c_pal/thandle_ptr.h +++ b/common/inc/c_pal/thandle_ptr.h @@ -34,15 +34,25 @@ typedef struct PTR_STRUCT_TAG_TYPE_NAME(T) /*this introduces one new *name* for a function which is used to capture a T ptr and move it under the THANDLE(PTR(T))*/ #define THANDLE_PTR_CREATE_WITH_MOVE(T) MU_C2(THANDLE_PTR_CREATE_WITH_MOVE_, T) +/*this introduces one new *name* for the function type of THANDLE_PTR_CREATE_WITH_MOVE*/ +#define THANDLE_PTR_CREATE_WITH_MOVE_FUNCTION_TYPE(T) MU_C2(THANDLE_PTR_CREATE_WITH_MOVE_TYPE_, T) + +/*this introduces one new *type* for the function type of THANDLE_PTR_CREATE_WITH_MOVE*/ +#define THANDLE_PTR_CREATE_WITH_MOVE_TYPE(T) typedef THANDLE(PTR(T))(*THANDLE_PTR_CREATE_WITH_MOVE_FUNCTION_TYPE(T))(T pointer, THANDLE_PTR_FREE_FUNC_TYPE_NAME(T) dispose); + + /*this introduces a new *name* for a function that calls the dispose as passed to THANDLE_PTR_CREATE_WITH_MOVE*/ #define THANDLE_PTR_DISPOSE(T) MU_C2(THANDLE_PTR_DISPOSE_, T) +#include "umock_c/umock_c_prod.h" + /*this introduces the declaration of a function that returns a THANDLE(PTR(T))*/ #define THANDLE_PTR_DECLARE(T) \ - THANDLE_PTR_FREE_FUNC_TYPE(T); \ - PTR_STRUCT_TYPE_TYPEDEF(T); \ - THANDLE_TYPE_DECLARE(PTR(T)); \ - THANDLE(PTR(T)) THANDLE_PTR_CREATE_WITH_MOVE(T)(T pointer, THANDLE_PTR_FREE_FUNC_TYPE_NAME(T) dispose ); \ + THANDLE_PTR_FREE_FUNC_TYPE(T); \ + PTR_STRUCT_TYPE_TYPEDEF(T); \ + THANDLE_TYPE_DECLARE(PTR(T)); \ + THANDLE_PTR_CREATE_WITH_MOVE_TYPE(T); \ + MOCKABLE_FUNCTION(,THANDLE(PTR(T)), THANDLE_PTR_CREATE_WITH_MOVE(T), T, pointer, THANDLE_PTR_FREE_FUNC_TYPE_NAME(T), dispose ); \ /*this introduces the definition of the function declared above*/ #define THANDLE_PTR_DEFINE(T) \ diff --git a/common/reals/real_thandle_log_context_handle.c b/common/reals/real_thandle_log_context_handle.c new file mode 100644 index 0000000..653b5c6 --- /dev/null +++ b/common/reals/real_thandle_log_context_handle.c @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#include "real_gballoc_hl_renames.h" // IWYU pragma: keep +#include "real_interlocked_renames.h" // IWYU pragma: keep + +#include "real_thandle_log_context_handle_renames.h" // IWYU pragma: keep + +#include "../src/thandle_log_context_handle.c" + diff --git a/common/reals/real_thandle_log_context_handle.h b/common/reals/real_thandle_log_context_handle.h new file mode 100644 index 0000000..252774e --- /dev/null +++ b/common/reals/real_thandle_log_context_handle.h @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#ifndef REAL_THANDLE_LOG_CONTEXT_HANDLE_H +#define REAL_THANDLE_LOG_CONTEXT_HANDLE_H + +#include "macro_utils/macro_utils.h" + +#include "c_logging/log_context.h" + +#include "c_pal/thandle_ptr.h" + +#include "c_pal/thandle_log_context_handle.h" + +typedef LOG_CONTEXT_HANDLE real_LOG_CONTEXT_HANDLE; /*real_LOG_CONTEXT_HANDLE is "the same type" as LOG_CONTEXT_HANDLE*/ + +THANDLE_PTR_DECLARE(real_LOG_CONTEXT_HANDLE) + +#define REGISTER_THANDLE_LOG_CONTEXT_HANDLE_GLOBAL_MOCK_HOOK() \ + /*regular THANDLE hooks. Note: casts are needed because of C11's 6.7.2.3 Tags - Constraint 5 on "distinct types". The structs which are "distinct" here would be PTR(T) and PTR(real_T).*/ \ + REGISTER_GLOBAL_MOCK_HOOK(THANDLE_MOVE(PTR(LOG_CONTEXT_HANDLE)), (THANDLE_MOVE_FUNCTION_TYPE(PTR(LOG_CONTEXT_HANDLE))) THANDLE_MOVE(PTR(real_LOG_CONTEXT_HANDLE))); \ + REGISTER_GLOBAL_MOCK_HOOK(THANDLE_INITIALIZE(PTR(LOG_CONTEXT_HANDLE)), (THANDLE_INITIALIZE_FUNCTION_TYPE(PTR(LOG_CONTEXT_HANDLE))) THANDLE_INITIALIZE(PTR(real_LOG_CONTEXT_HANDLE))); \ + REGISTER_GLOBAL_MOCK_HOOK(THANDLE_INITIALIZE_MOVE(PTR(LOG_CONTEXT_HANDLE)), (THANDLE_INITIALIZE_MOVE_FUNCTION_TYPE(PTR(LOG_CONTEXT_HANDLE))) THANDLE_INITIALIZE_MOVE(PTR(real_LOG_CONTEXT_HANDLE))); \ + REGISTER_GLOBAL_MOCK_HOOK(THANDLE_ASSIGN(PTR(LOG_CONTEXT_HANDLE)), (THANDLE_ASSIGN_FUNCTION_TYPE(PTR(LOG_CONTEXT_HANDLE))) THANDLE_ASSIGN(PTR(real_LOG_CONTEXT_HANDLE))); \ + /*create hook*/ \ + REGISTER_GLOBAL_MOCK_HOOK(THANDLE_PTR_CREATE_WITH_MOVE(LOG_CONTEXT_HANDLE), (THANDLE_PTR_CREATE_WITH_MOVE_FUNCTION_TYPE(LOG_CONTEXT_HANDLE)) THANDLE_PTR_CREATE_WITH_MOVE(real_LOG_CONTEXT_HANDLE)); \ + + +#endif /*REAL_THANDLE_LOG_CONTEXT_HANDLE_H*/ diff --git a/common/reals/real_thandle_log_context_handle_renames.h b/common/reals/real_thandle_log_context_handle_renames.h new file mode 100644 index 0000000..2c70fc8 --- /dev/null +++ b/common/reals/real_thandle_log_context_handle_renames.h @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#define LOG_CONTEXT_HANDLE real_LOG_CONTEXT_HANDLE diff --git a/common/src/thandle_log_context_handle.c b/common/src/thandle_log_context_handle.c new file mode 100644 index 0000000..42943bf --- /dev/null +++ b/common/src/thandle_log_context_handle.c @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#include "macro_utils/macro_utils.h" + +#include "c_logging/log_context.h" + +#include "c_pal/gballoc_hl.h" // IWYU pragma: keep +#include "c_pal/gballoc_hl_redirect.h" // IWYU pragma: keep +#include "c_pal/interlocked.h" // IWYU pragma: keep + +#include "c_pal/thandle_ll.h" // IWYU pragma: keep +#include "c_pal/thandle.h" // IWYU pragma: keep +#include "c_pal/thandle_ptr.h" + +#include "c_pal/thandle_log_context_handle.h" + +THANDLE_PTR_DEFINE(LOG_CONTEXT_HANDLE); diff --git a/common/tests/CMakeLists.txt b/common/tests/CMakeLists.txt index b990de6..fb367a2 100644 --- a/common/tests/CMakeLists.txt +++ b/common/tests/CMakeLists.txt @@ -20,6 +20,7 @@ if(${run_unittests}) build_test_folder(thandle_2_ut) build_test_folder(thandle_ut) build_test_folder(thandle_ptr_ut) + build_test_folder(real_thandle_log_context_handle_ut) endif() if(${run_int_tests}) diff --git a/common/tests/real_thandle_log_context_handle_ut/CMakeLists.txt b/common/tests/real_thandle_log_context_handle_ut/CMakeLists.txt new file mode 100644 index 0000000..9840f38 --- /dev/null +++ b/common/tests/real_thandle_log_context_handle_ut/CMakeLists.txt @@ -0,0 +1,18 @@ +#Copyright (c) Microsoft. All rights reserved. +#Licensed under the MIT license. See LICENSE file in the project root for full license information. + +set(theseTestsName real_thandle_log_context_handle_ut) + +set(${theseTestsName}_test_files + ${theseTestsName}.c +) + +set(${theseTestsName}_c_files + module.c +) + +set(${theseTestsName}_h_files + module.h +) + +build_test_artifacts(${theseTestsName} "tests/c_pal" ADDITIONAL_LIBS c_pal_reals) diff --git a/common/tests/real_thandle_log_context_handle_ut/module.c b/common/tests/real_thandle_log_context_handle_ut/module.c new file mode 100644 index 0000000..f5d8348 --- /dev/null +++ b/common/tests/real_thandle_log_context_handle_ut/module.c @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#include + +#include "c_logging/log_context.h" + +#include "c_pal/thandle_ll.h" +#include "c_pal/thandle_ptr.h" +#include "c_pal/thandle_log_context_handle.h" + +#include "module.h" + +void function_under_test(void) +{ + + LOG_CONTEXT_HANDLE log_context_handle =(LOG_CONTEXT_HANDLE)0x42; // This is a dummy value that is not used in the test. + + /*create a THANDLE out of the LOG_CONTEXT_HANDLE*/ + THANDLE(PTR(LOG_CONTEXT_HANDLE)) thandle = THANDLE_PTR_CREATE_WITH_MOVE(LOG_CONTEXT_HANDLE)(log_context_handle, NULL); // This is a dummy value that is not used in the test. + + /*here be pretending usage*/ + + /*get rid of it*/ + THANDLE_ASSIGN(PTR(LOG_CONTEXT_HANDLE))(&thandle, NULL); +} diff --git a/common/tests/real_thandle_log_context_handle_ut/module.h b/common/tests/real_thandle_log_context_handle_ut/module.h new file mode 100644 index 0000000..c6db8fe --- /dev/null +++ b/common/tests/real_thandle_log_context_handle_ut/module.h @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/*MODULE is a dummy module that builds a LOG_CONTEXT_HANDLE...*/ + +#ifndef MODULE_H +#define MODULE_H + + void function_under_test(void); + +#endif + diff --git a/common/tests/real_thandle_log_context_handle_ut/real_thandle_log_context_handle_ut.c b/common/tests/real_thandle_log_context_handle_ut/real_thandle_log_context_handle_ut.c new file mode 100644 index 0000000..5934400 --- /dev/null +++ b/common/tests/real_thandle_log_context_handle_ut/real_thandle_log_context_handle_ut.c @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#include + +#include "macro_utils/macro_utils.h" // IWYU pragma: keep + +#include "umock_c/umock_c.h" +#include "umock_c/umocktypes_stdint.h" +#include "testrunnerswitcher.h" + +#include "c_pal/interlocked.h" // IWYU pragma: keep + +#include "c_logging/log_context.h" + +#define ENABLE_MOCKS +#include "c_pal/gballoc_hl.h" // IWYU pragma: keep +#include "c_pal/gballoc_hl_redirect.h" // IWYU pragma: keep +#include "c_pal/thandle_ll.h" +#include "c_pal/thandle_ptr.h" +#include "c_pal/thandle_log_context_handle.h" +#undef ENABLE_MOCKS + + +#include "umock_c/umock_c_prod.h" +#include "real_gballoc_hl.h" +#include "real_thandle_log_context_handle.h" + +#include "module.h" + +MU_DEFINE_ENUM_STRINGS(UMOCK_C_ERROR_CODE, UMOCK_C_ERROR_CODE_VALUES) + +static void on_umock_c_error(UMOCK_C_ERROR_CODE error_code) +{ + ASSERT_FAIL("umock_c reported error :%" PRI_MU_ENUM "", MU_ENUM_VALUE(UMOCK_C_ERROR_CODE, error_code)); +} + +BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE) + +TEST_SUITE_INITIALIZE(TestClassInitialize) +{ + ASSERT_ARE_EQUAL(int, 0, real_gballoc_hl_init(NULL, NULL)); + + ASSERT_ARE_EQUAL(int, 0, umock_c_init(on_umock_c_error), "umock_c_init"); + ASSERT_ARE_EQUAL(int, 0, umocktypes_stdint_register_types(), "umocktypes_charptr_register_types"); + + REGISTER_UMOCK_ALIAS_TYPE(THANDLE_PTR_FREE_FUNC_TYPE_NAME(LOG_CONTEXT_HANDLE), void*); + REGISTER_UMOCK_ALIAS_TYPE(LOG_CONTEXT_HANDLE, void*); + REGISTER_UMOCK_ALIAS_TYPE(THANDLE(PTR(LOG_CONTEXT_HANDLE)), void*); + + REGISTER_UMOCK_ALIAS_TYPE(THANDLE_PTR_FREE_FUNC_TYPE_NAME(real_LOG_CONTEXT_HANDLE), void*); + REGISTER_UMOCK_ALIAS_TYPE(real_LOG_CONTEXT_HANDLE, void*); + REGISTER_UMOCK_ALIAS_TYPE(THANDLE(PTR(real_LOG_CONTEXT_HANDLE)), void*); + + REGISTER_THANDLE_LOG_CONTEXT_HANDLE_GLOBAL_MOCK_HOOK(); + +} + +TEST_SUITE_CLEANUP(TestClassCleanup) +{ + umock_c_deinit(); + real_gballoc_hl_deinit(); +} + +TEST_FUNCTION_INITIALIZE(TestMethodInitialize) +{ + umock_c_reset_all_calls(); +} + +TEST_FUNCTION_CLEANUP(TestMethodCleanup) +{ + +} + +TEST_FUNCTION(thandle_ptr_log_context_handle_with_mocks) +{ + ///arrange + STRICT_EXPECTED_CALL(THANDLE_PTR_CREATE_WITH_MOVE(LOG_CONTEXT_HANDLE)((LOG_CONTEXT_HANDLE)0x42, NULL)); + STRICT_EXPECTED_CALL(THANDLE_ASSIGN(PTR(LOG_CONTEXT_HANDLE))(IGNORED_ARG, NULL)); + + ///act + function_under_test(); + + ///assert + ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls()); + + ///clean; +} + +END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE) diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index 632b2e6..aeb6dda 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -11,6 +11,8 @@ set(pal_common_h_files ../common/inc/c_pal/sm.h ../common/inc/c_pal/thandle_ll.h ../common/inc/c_pal/thandle.h + ../common/inc/c_pal/thandle_ptr.h + ../common/inc/c_pal/thandle_log_context_handle.h ) set(pal_common_c_files @@ -20,6 +22,7 @@ set(pal_common_c_files ../common/src/ps_util.c ../common/src/s_list.c ../common/src/sm.c + ../common/src/thandle_log_context_handle.c ) if(${run_helgrind}) @@ -76,7 +79,7 @@ include_directories(../common/inc) include_directories(../c_pal_ll/interfaces/inc) add_library(pal_linux ${pal_linux_h_files} ${pal_linux_c_files} ${pal_linux_md_files} ${pal_common_md_files}) -target_link_libraries(pal_linux pal_interfaces rt uuid pthread) +target_link_libraries(pal_linux pal_ll_linux pal_interfaces rt uuid pthread) target_include_directories(pal_linux PUBLIC ${CMAKE_CURRENT_LIST_DIR}/inc) # make an install target so we can produce a Linux native client package. diff --git a/linux/linux_reals/CMakeLists.txt b/linux/linux_reals/CMakeLists.txt index c101f55..a449331 100644 --- a/linux/linux_reals/CMakeLists.txt +++ b/linux/linux_reals/CMakeLists.txt @@ -17,6 +17,8 @@ set(linux_reals_c_files ../../common/reals/real_ps_util.c ../../common/reals/real_sm.c ../../common/reals/real_interlocked_hl.c + ../../common/reals/real_thandle_log_context_handle.c + ) set(linux_reals_h_files diff --git a/linux/tests/linux_reals_ut/CMakeLists.txt b/linux/tests/linux_reals_ut/CMakeLists.txt index 796b70f..8bfe4a3 100644 --- a/linux/tests/linux_reals_ut/CMakeLists.txt +++ b/linux/tests/linux_reals_ut/CMakeLists.txt @@ -7,4 +7,4 @@ set(${theseTestsName}_test_files ${theseTestsName}.c ) -build_test_artifacts(${theseTestsName} "tests/c_pal/linux" ADDITIONAL_LIBS pal_linux linux_reals) +build_test_artifacts(${theseTestsName} "tests/c_pal/linux" ADDITIONAL_LIBS c_pal linux_reals) diff --git a/linux/tests/linux_reals_ut/reals_linux_ut.c b/linux/tests/linux_reals_ut/reals_linux_ut.c index 9dd2af3..b61e20c 100644 --- a/linux/tests/linux_reals_ut/reals_linux_ut.c +++ b/linux/tests/linux_reals_ut/reals_linux_ut.c @@ -9,6 +9,8 @@ #include "c_pal/threadpool.h" // IWYU pragma: keep #include "c_pal/uuid.h" // IWYU pragma: keep #include "c_pal/execution_engine.h" // IWYU pragma: keep +#include "c_pal/interlocked.h" // IWYU pragma: keep +#include "c_pal/thandle_log_context_handle.h" // IWYU pragma: keep #define REGISTER_GLOBAL_MOCK_HOOK(original, real) \ (original == real) ? (void)0 : (void)1; @@ -21,6 +23,8 @@ #include "real_threadpool.h" #include "real_uuid.h" #include "real_execution_engine.h" +#include "real_interlocked.h" +#include "real_thandle_log_context_handle.h" BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE) @@ -39,6 +43,8 @@ TEST_FUNCTION(check_all_c_pal_reals) REGISTER_THREADPOOL_GLOBAL_MOCK_HOOK(); REGISTER_UUID_GLOBAL_MOCK_HOOK(); REGISTER_EXECUTION_ENGINE_GLOBAL_MOCK_HOOK(); + REGISTER_INTERLOCKED_GLOBAL_MOCK_HOOK(); + REGISTER_THANDLE_LOG_CONTEXT_HANDLE_GLOBAL_MOCK_HOOK(); // assert // no explicit assert, if it builds it works } diff --git a/win32/CMakeLists.txt b/win32/CMakeLists.txt index c1b054b..680c452 100644 --- a/win32/CMakeLists.txt +++ b/win32/CMakeLists.txt @@ -10,6 +10,8 @@ set(pal_common_h_files ../common/inc/c_pal/sm.h ../common/inc/c_pal/thandle_ll.h ../common/inc/c_pal/thandle.h + ../common/inc/c_pal/thandle_ptr.h + ../common/inc/c_pal/thandle_log_context_handle.h ) set(pal_common_c_files @@ -19,6 +21,7 @@ set(pal_common_c_files ../common/src/ps_util.c ../common/src/s_list.c ../common/src/sm.c + ../common/src/thandle_log_context_handle.c ) #determining which one of the GBALLOC_LL implementations to use. By convention the file is called "gballoc_ll_" followed by "type". diff --git a/win32/reals/CMakeLists.txt b/win32/reals/CMakeLists.txt index d114363..4c8bfba 100644 --- a/win32/reals/CMakeLists.txt +++ b/win32/reals/CMakeLists.txt @@ -21,6 +21,7 @@ set(reals_win32_c_files ../../common/reals/real_sm.c ../../common/reals/real_s_list.c ../../common/reals/real_interlocked_hl.c + ../../common/reals/real_thandle_log_context_handle.c ) set(reals_win32_h_files @@ -50,6 +51,8 @@ set(reals_win32_h_files ../../common/reals/real_interlocked_hl.h ../../common/reals/real_interlocked_hl_renames.h ../../common/reals/real_thandle_helper.h + ../../common/reals/real_thandle_log_context_handle.h + ../../common/reals/real_thandle_log_context_handle_renames.h ) add_library(win32_reals ${reals_win32_c_files} ${reals_win32_h_files}) diff --git a/win32/tests/reals_win32_ut/reals_win32_ut.c b/win32/tests/reals_win32_ut/reals_win32_ut.c index 443d5e2..cb90a2a 100644 --- a/win32/tests/reals_win32_ut/reals_win32_ut.c +++ b/win32/tests/reals_win32_ut/reals_win32_ut.c @@ -17,6 +17,7 @@ #include "c_pal/arithmetic.h" #include "c_pal/uuid.h" #include "c_pal/execution_engine.h" +#include "c_pal/thandle_log_context_handle.h" #include "macro_utils/macro_utils.h" @@ -41,6 +42,7 @@ #include "real_arithmetic.h" #include "real_uuid.h" #include "real_execution_engine.h" +#include "real_thandle_log_context_handle.h" BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE) @@ -65,6 +67,7 @@ TEST_FUNCTION(check_all_c_pal_reals) REGISTER_ARITHMETIC_GLOBAL_MOCK_HOOK(); REGISTER_UUID_GLOBAL_MOCK_HOOK(); REGISTER_EXECUTION_ENGINE_GLOBAL_MOCK_HOOK(); + REGISTER_THANDLE_LOG_CONTEXT_HANDLE_GLOBAL_MOCK_HOOK(); // assert // no explicit assert, if it builds it works