* use latest dependencies 06 Oct 2023

* remove mymalloc
This commit is contained in:
anporumb 2023-10-06 15:15:40 -07:00 коммит произвёл GitHub
Родитель e89ca804d3
Коммит bdcd1ad58e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
17 изменённых файлов: 54 добавлений и 139 удалений

Просмотреть файл

@ -2,22 +2,11 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "umock_c/umocktypes.h"
static void* my_gballoc_malloc(size_t size)
{
return malloc(size);
}
static void my_gballoc_free(void* s)
{
free(s);
}
#include "umock_c/umocktypes.h"
#include "testrunnerswitcher.h"
@ -32,6 +21,7 @@ static void my_gballoc_free(void* s)
#include "real_interlocked.h"
#include "real_sync.h"
#include "real_gballoc_hl.h"
#include "c_pal/interlocked_hl.h"
MU_DEFINE_ENUM_STRINGS(UMOCK_C_ERROR_CODE, UMOCK_C_ERROR_CODE_VALUES)
@ -161,7 +151,7 @@ TEST_FUNCTION(InterlockedHL_Add64WithCeiling_when_underflow_it_fails)
{ INT64_MIN, INT64_MIN}
}, *cloneOfInputValues;
cloneOfInputValues = my_gballoc_malloc(sizeof(inputValues));
cloneOfInputValues = real_gballoc_hl_malloc(sizeof(inputValues));
ASSERT_IS_NOT_NULL(cloneOfInputValues);
(void)memcpy(cloneOfInputValues, inputValues, sizeof(inputValues));
@ -182,7 +172,7 @@ TEST_FUNCTION(InterlockedHL_Add64WithCeiling_when_underflow_it_fails)
}
///cleanup
my_gballoc_free(cloneOfInputValues);
real_gballoc_hl_free(cloneOfInputValues);
}
/*Tests_SRS_INTERLOCKED_HL_02_003: [ If Addend + Value would overflow then InterlockedHL_Add64WithCeiling shall fail and return INTERLOCKED_HL_ERROR. ]*/
@ -199,7 +189,7 @@ TEST_FUNCTION(InterlockedHL_Add64WithCeiling_when_overflow_it_fails)
{ INT64_MAX, INT64_MAX }
}, *cloneOfInputValues;
cloneOfInputValues = my_gballoc_malloc(sizeof(inputValues));
cloneOfInputValues = real_gballoc_hl_malloc(sizeof(inputValues));
ASSERT_IS_NOT_NULL(cloneOfInputValues);
(void)memcpy(cloneOfInputValues, inputValues, sizeof(inputValues));
@ -219,7 +209,7 @@ TEST_FUNCTION(InterlockedHL_Add64WithCeiling_when_overflow_it_fails)
}
///cleanup
my_gballoc_free(cloneOfInputValues);
real_gballoc_hl_free(cloneOfInputValues);
}
/*Tests_SRS_INTERLOCKED_HL_02_004: [ If Addend + Value would be greater than Ceiling then InterlockedHL_Add64WithCeiling shall fail and return INTERLOCKED_HL_ERROR. ]*/
@ -240,7 +230,7 @@ TEST_FUNCTION(InterlockedHL_Add64WithCeiling_when_over_the_ceiling_it_fails)
{ 2, INT64_MIN + 1, INT64_MIN },
}, *cloneOfInputValues;
cloneOfInputValues = my_gballoc_malloc(sizeof(inputValues));
cloneOfInputValues = real_gballoc_hl_malloc(sizeof(inputValues));
ASSERT_IS_NOT_NULL(cloneOfInputValues);
(void)memcpy(cloneOfInputValues, inputValues, sizeof(inputValues));
@ -260,7 +250,7 @@ TEST_FUNCTION(InterlockedHL_Add64WithCeiling_when_over_the_ceiling_it_fails)
}
///cleanup
my_gballoc_free(cloneOfInputValues);
real_gballoc_hl_free(cloneOfInputValues);
}
/*Tests_SRS_INTERLOCKED_HL_02_005: [ Otherwise, InterlockedHL_Add64WithCeiling shall atomically write in Addend the sum of Addend and Value, succeed and return INTERLOCKED_HL_OK. ]*/
@ -281,7 +271,7 @@ TEST_FUNCTION(InterlockedHL_Add64WithCeiling_succeeds)
{ 1, INT64_MIN + 1, INT64_MIN },
}, *cloneOfInputValues;
cloneOfInputValues = my_gballoc_malloc(sizeof(inputValues));
cloneOfInputValues = real_gballoc_hl_malloc(sizeof(inputValues));
ASSERT_IS_NOT_NULL(cloneOfInputValues);
(void)memcpy(cloneOfInputValues, inputValues, sizeof(inputValues));
@ -303,7 +293,7 @@ TEST_FUNCTION(InterlockedHL_Add64WithCeiling_succeeds)
}
///cleanup
my_gballoc_free(cloneOfInputValues);
real_gballoc_hl_free(cloneOfInputValues);
}
/* InterlockedHL_WaitForValue */

Просмотреть файл

@ -6,24 +6,6 @@
#include <stddef.h>
#include <stdint.h>
#include "real_gballoc_ll.h"
static void* my_malloc(size_t size)
{
return real_gballoc_ll_malloc(size);
}
static void* my_malloc_flex(size_t base, size_t nmemb, size_t size)
{
return real_gballoc_ll_malloc_flex(base, nmemb, size);
}
static void my_free(void* ptr)
{
real_gballoc_ll_free(ptr);
}
#include "macro_utils/macro_utils.h" // IWYU pragma: keep
#include "testrunnerswitcher.h"
@ -55,11 +37,11 @@ typedef struct TEST_STRUCT_TAG
} TEST_STRUCT;
MOCK_FUNCTION_WITH_CODE(, void*, test_malloc, size_t, size)
MOCK_FUNCTION_END(my_malloc(size))
MOCK_FUNCTION_END(real_gballoc_hl_malloc(size))
MOCK_FUNCTION_WITH_CODE(, void*, test_malloc_flex, size_t, base, size_t, nmemb, size_t, size)
MOCK_FUNCTION_END(my_malloc_flex(base, nmemb, size))
MOCK_FUNCTION_END(real_gballoc_hl_malloc_flex(base, nmemb, size))
MOCK_FUNCTION_WITH_CODE(, void, test_free, void*, ptr)
my_free(ptr);
real_gballoc_hl_free(ptr);
MOCK_FUNCTION_END()
/* Tests_SRS_REFCOUNT_01_011: [ DEFINE_REFCOUNT_TYPE_WITH_CUSTOM_ALLOC shall behave like DEFINE_REFCOUNT_TYPE, but use malloc_func, malloc_flex and free_func for memory allocation and free. ]*/
@ -75,12 +57,9 @@ BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
REGISTER_UMOCK_ALIAS_TYPE(POS_HANDLE, void*);
REGISTER_GLOBAL_MOCK_HOOK(malloc, my_malloc);
REGISTER_GLOBAL_MOCK_HOOK(malloc_flex, my_malloc_flex);
REGISTER_GLOBAL_MOCK_HOOK(free, my_free);
ASSERT_ARE_EQUAL(int, 0, umocktypes_stdint_register_types());
REGISTER_GBALLOC_HL_GLOBAL_MOCK_HOOK();
REGISTER_INTERLOCKED_GLOBAL_MOCK_HOOK();
}

Просмотреть файл

@ -8,16 +8,6 @@
#include "testrunnerswitcher.h"
static void* my_gballoc_malloc(size_t size)
{
return malloc(size);
}
static void my_gballoc_free(void* ptr)
{
free(ptr);
}
#define ENABLE_MOCKS
#include "umock_c/umock_c.h"
#include "c_pal/gballoc_hl.h"
@ -508,7 +498,7 @@ TEST_FUNCTION(THANDLE_GET_T_with_t_not_NULL_returns_original_pointer) /*direct t
/*returns a pointer to an array of 2 THANDLE(LL)*/
static void builds_out_arg(THANDLE(LL)** x)
{
*x = my_gballoc_malloc(sizeof(THANDLE(LL)) * 2);
*x = real_gballoc_hl_malloc(sizeof(THANDLE(LL)) * 2);
ASSERT_IS_NOT_NULL(*x);
}
@ -531,7 +521,7 @@ TEST_FUNCTION(THANDLE_T_can_build_an_array)
THANDLE_ASSIGN(LL)(&arr[0], NULL);
THANDLE_ASSIGN(LL)(&arr[1], NULL);
my_gballoc_free((void*)arr);
real_gballoc_hl_free((void*)arr);
}
/*Tests_SRS_THANDLE_02_053: [ If source is NULL then THANDLE_CREATE_FROM_CONTENT_FLEX_WITH_MALLOC_FUNCTIONS shall fail and return NULL. ]*/
@ -655,7 +645,7 @@ TEST_FUNCTION(THANDLE_CREATE_FROM_CONTENT_FLEX_calls_get_sizeof)
{
///arrange
int n = 4; /*number of elements in the flexible array*/
A_FLEX* source = my_gballoc_malloc(sizeof(A_FLEX) + n * sizeof(int));
A_FLEX* source = real_gballoc_hl_malloc(sizeof(A_FLEX) + n * sizeof(int));
ASSERT_IS_NOT_NULL(source);
source->n = 4;
@ -678,7 +668,7 @@ TEST_FUNCTION(THANDLE_CREATE_FROM_CONTENT_FLEX_calls_get_sizeof)
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
///clean
my_gballoc_free(source);
real_gballoc_hl_free(source);
THANDLE_ASSIGN(A_FLEX)(&copy, NULL);
}
@ -688,7 +678,7 @@ TEST_FUNCTION(THANDLE_CREATE_FROM_CONTENT_FLEX_calls_get_sizeof_2)
{
///arrange
int n = 4; /*number of elements in the flexible array*/
A_S_FLEX* source = my_gballoc_malloc(sizeof(A_S_FLEX) + n * sizeof(int));
A_S_FLEX* source = real_gballoc_hl_malloc(sizeof(A_S_FLEX) + n * sizeof(int));
ASSERT_IS_NOT_NULL(source);
source->s = "abc";
@ -716,7 +706,7 @@ TEST_FUNCTION(THANDLE_CREATE_FROM_CONTENT_FLEX_calls_get_sizeof_2)
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
///clean
my_gballoc_free(source);
real_gballoc_hl_free(source);
THANDLE_ASSIGN(A_S_FLEX)(&copy, NULL);
}

2
deps/c-build-tools поставляемый

@ -1 +1 @@
Subproject commit 157d11f5a5ee9e9bf238c8846312bcffd7a0d85e
Subproject commit ee291fd9a89bff4c5fdb8a978f8c5426a99e4c4c

2
deps/c-logging поставляемый

@ -1 +1 @@
Subproject commit d370c6f08c28648912a772cf7133d54b363dccbc
Subproject commit e748c4391023b5d6c52f19c9f309fddc46012288

2
deps/c-testrunnerswitcher поставляемый

@ -1 +1 @@
Subproject commit 4fd1a5b06e092b25dc4a1e02913895fa27de41be
Subproject commit 05542fd1b9723e579f04f9d98613c409f0974c2b

2
deps/ctest поставляемый

@ -1 +1 @@
Subproject commit 756423a86a025f830c7b3d05a394be01ae5c9ea4
Subproject commit 2049f82f96c575b67d2af182b86b0719ed0020c8

2
deps/macro-utils-c поставляемый

@ -1 +1 @@
Subproject commit 6b1f351a1d55ccea442d3b777db14ed80c5620f7
Subproject commit 5ef7fcafb86bf7568f9a8c55bed17199c4b4e000

2
deps/umock-c поставляемый

@ -1 +1 @@
Subproject commit 5c745d27b98b03fd7e52f25bfa09f624d37584d9
Subproject commit 01600750cdbfba8a01c923c62cb8b48de1cf6543

Просмотреть файл

@ -1,7 +1,7 @@
// 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_ll_renames.h" // IWYU pragma: keep
#include "real_gballoc_hl_renames.h" // IWYU pragma: keep
#include "real_timer_renames.h" // IWYU pragma: keep

Просмотреть файл

@ -6,8 +6,8 @@
#include "macro_utils/macro_utils.h"
#include "c_logging/logger.h"
#include "c_pal/gballoc_ll.h" // IWYU pragma: keep
#include "c_pal/gballoc_ll_redirect.h" // IWYU pragma: keep
#include "c_pal/gballoc_hl.h" // IWYU pragma: keep
#include "c_pal/gballoc_hl_redirect.h" // IWYU pragma: keep
#include "c_pal/timer.h"

Просмотреть файл

@ -5,23 +5,13 @@
#include "macro_utils/macro_utils.h" // IWYU pragma: keep
static void* my_gballoc_malloc(size_t size)
{
return malloc(size);
}
static void my_gballoc_free(void* s)
{
free(s);
}
#include "testrunnerswitcher.h"
#include "umock_c/umock_c.h"
#include "umock_c/umock_c_negative_tests.h"
#define ENABLE_MOCKS
#include "c_pal/gballoc_ll.h"
#include "c_pal/gballoc_ll_redirect.h" // IWYU pragma: keep
#include "c_pal/gballoc_hl.h"
#include "c_pal/gballoc_hl_redirect.h" // IWYU pragma: keep
MOCKABLE_FUNCTION(, int, mocked_clock_gettime, clockid_t, clockid, struct timespec*, tp)
@ -29,7 +19,7 @@ static void my_gballoc_free(void* s)
#undef ENABLE_MOCKS
#include "real_gballoc_ll.h"
#include "real_gballoc_hl.h"
#include "c_pal/timer.h"
@ -47,12 +37,11 @@ BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
TEST_SUITE_INITIALIZE(suite_init)
{
ASSERT_ARE_EQUAL(int, 0, real_gballoc_ll_init(NULL));
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");
REGISTER_GLOBAL_MOCK_HOOK(gballoc_ll_malloc, my_gballoc_malloc);
REGISTER_GLOBAL_MOCK_HOOK(gballoc_ll_free, my_gballoc_free);
REGISTER_GBALLOC_HL_GLOBAL_MOCK_HOOK();
REGISTER_GLOBAL_MOCK_FAIL_RETURN(malloc, NULL);
REGISTER_GLOBAL_MOCK_RETURNS(mocked_clock_gettime, 0, -1);
@ -65,7 +54,7 @@ TEST_SUITE_CLEANUP(suite_cleanup)
umock_c_deinit();
umock_c_negative_tests_deinit();
real_gballoc_ll_deinit();
real_gballoc_hl_deinit();
}
TEST_FUNCTION_INITIALIZE(function_init)

Просмотреть файл

@ -1,7 +1,7 @@
// 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_ll_renames.h" // IWYU pragma: keep
#include "real_gballoc_hl_renames.h" // IWYU pragma: keep
#include "real_timer_renames.h" // IWYU pragma: keep

Просмотреть файл

@ -3,8 +3,8 @@
#include "windows.h"
#include "c_logging/logger.h"
#include "c_pal/gballoc_ll.h"
#include "c_pal/gballoc_ll_redirect.h"
#include "c_pal/gballoc_hl.h"
#include "c_pal/gballoc_hl_redirect.h"
#include "c_pal/timer.h"

Просмотреть файл

@ -9,16 +9,6 @@
#include <winsock2.h>
static void* my_gballoc_malloc(size_t size)
{
return malloc(size);
}
static void my_gballoc_free(void* ptr)
{
free(ptr);
}
#include "testrunnerswitcher.h"
#include "umock_c/umock_c.h"
#include "umock_c/umocktypes_charptr.h"

Просмотреть файл

@ -9,17 +9,6 @@
#include "macro_utils/macro_utils.h"
#include "real_gballoc_ll.h"
static void* my_malloc(size_t size)
{
return real_gballoc_ll_malloc(size);
}
static void my_free(void* s)
{
real_gballoc_ll_free(s);
}
#include "testrunnerswitcher.h"
#include "umock_c/umock_c.h"
#include "umock_c/umocktypes.h"
@ -54,7 +43,7 @@ static void on_umock_c_error(UMOCK_C_ERROR_CODE error_code)
static void my_timer_destroy(TIMER_HANDLE timer)
{
my_free(timer);
real_gballoc_hl_free(timer);
}
static SRW_LOCK_HANDLE TEST_srw_lock_create(bool do_statistics, const char* lock_name)
@ -65,7 +54,7 @@ static SRW_LOCK_HANDLE TEST_srw_lock_create(bool do_statistics, const char* lock
{
STRICT_EXPECTED_CALL(malloc(IGNORED_ARG));
STRICT_EXPECTED_CALL(timer_create_new())
.SetReturn((TIMER_HANDLE)my_malloc(2));
.SetReturn((TIMER_HANDLE)real_gballoc_hl_malloc(2));
}
STRICT_EXPECTED_CALL(mocked_InitializeSRWLock(IGNORED_ARG));
result = srw_lock_create(do_statistics, lock_name);
@ -113,8 +102,8 @@ TEST_SUITE_INITIALIZE(suite_init)
ASSERT_ARE_EQUAL(int, 0, umock_c_init(on_umock_c_error), "umock_c_init");
ASSERT_ARE_EQUAL(int, 0, umocktypes_windows_register_types(), "umocktypes_windows_register_types");
REGISTER_GLOBAL_MOCK_HOOK(malloc, my_malloc);
REGISTER_GLOBAL_MOCK_HOOK(free, my_free);
REGISTER_GBALLOC_HL_GLOBAL_MOCK_HOOK();
REGISTER_GLOBAL_MOCK_HOOK(timer_destroy, my_timer_destroy);
REGISTER_GLOBAL_MOCK_RETURNS(mocked_TryAcquireSRWLockExclusive, TRUE, FALSE);
@ -122,7 +111,7 @@ TEST_SUITE_INITIALIZE(suite_init)
REGISTER_UMOCK_ALIAS_TYPE(TIMER_HANDLE, void*);
REGISTER_UMOCK_ALIAS_TYPE(PSRWLOCK, void*);
}
TEST_SUITE_CLEANUP(suite_cleanup)
@ -154,7 +143,7 @@ TEST_FUNCTION(srw_lock_create_succeeds)
STRICT_EXPECTED_CALL(malloc(IGNORED_ARG));
STRICT_EXPECTED_CALL(malloc(IGNORED_ARG));
STRICT_EXPECTED_CALL(timer_create_new())
.SetReturn((TIMER_HANDLE)my_malloc(2));
.SetReturn((TIMER_HANDLE)real_gballoc_hl_malloc(2));
STRICT_EXPECTED_CALL(mocked_InitializeSRWLock(IGNORED_ARG));
///act
@ -457,7 +446,7 @@ TEST_FUNCTION(srw_lock_release_exclusive_succeeds)
///arrange
SRW_LOCK_HANDLE bsdlLock = TEST_srw_lock_create(true, "test_lock");
TEST_srw_lock_acquire_exclusive(bsdlLock, 1);
STRICT_EXPECTED_CALL(mocked_ReleaseSRWLockExclusive(IGNORED_ARG));
@ -489,7 +478,7 @@ TEST_FUNCTION(srw_lock_destroy_free_used_resources)
{
///arrange
SRW_LOCK_HANDLE bsdlLock = TEST_srw_lock_create(true, "test_lock");
STRICT_EXPECTED_CALL(timer_destroy(IGNORED_ARG));
STRICT_EXPECTED_CALL(free(IGNORED_ARG));
STRICT_EXPECTED_CALL(free(IGNORED_ARG));

Просмотреть файл

@ -3,19 +3,8 @@
#include <stdlib.h>
#include "macro_utils/macro_utils.h"
static void* my_gballoc_malloc(size_t size)
{
return malloc(size);
}
static void my_gballoc_free(void* s)
{
free(s);
}
#include "testrunnerswitcher.h"
#include "windows.h"
#include "umock_c/umock_c.h"
@ -26,8 +15,8 @@ static void my_gballoc_free(void* s)
#include "umock_c/umocktypes_bool.h"
#define ENABLE_MOCKS
#include "c_pal/gballoc_ll.h"
#include "c_pal/gballoc_ll_redirect.h"
#include "c_pal/gballoc_hl.h"
#include "c_pal/gballoc_hl_redirect.h"
MOCKABLE_FUNCTION(, BOOLEAN, mocked_QueryPerformanceCounter, LARGE_INTEGER*, lpPerformanceCount)
@ -36,7 +25,7 @@ static void my_gballoc_free(void* s)
#undef ENABLE_MOCKS
#include "real_gballoc_ll.h"
#include "real_gballoc_hl.h"
#include "c_pal/timer.h"
@ -53,7 +42,7 @@ TEST_SUITE_INITIALIZE(suite_init)
{
int result;
ASSERT_ARE_EQUAL(int, 0, real_gballoc_ll_init(NULL));
ASSERT_ARE_EQUAL(int, 0, real_gballoc_hl_init(NULL, NULL));
result = umock_c_init(on_umock_c_error);
ASSERT_ARE_EQUAL(int, 0, result, "umock_c_init");
@ -67,8 +56,7 @@ TEST_SUITE_INITIALIZE(suite_init)
result = umocktypes_bool_register_types();
ASSERT_ARE_EQUAL(int, 0, result, "umocktypes_bool_register_types failed");
REGISTER_GLOBAL_MOCK_HOOK(gballoc_ll_malloc, my_gballoc_malloc);
REGISTER_GLOBAL_MOCK_HOOK(gballoc_ll_free, my_gballoc_free);
REGISTER_GBALLOC_HL_GLOBAL_MOCK_HOOK();
}
TEST_SUITE_CLEANUP(suite_cleanup)
@ -76,7 +64,7 @@ TEST_SUITE_CLEANUP(suite_cleanup)
umock_c_deinit();
umock_c_negative_tests_deinit();
real_gballoc_ll_deinit();
real_gballoc_hl_deinit();
}
TEST_FUNCTION_INITIALIZE(init)
@ -183,7 +171,7 @@ TEST_FUNCTION(timer_get_elapsed_success)
umock_c_reset_all_calls();
STRICT_EXPECTED_CALL(mocked_QueryPerformanceCounter(IGNORED_ARG))
.CopyOutArgumentBuffer_lpPerformanceCount(&stop_time, sizeof(stop_time));
//act
double elapsed_time = timer_get_elapsed(timer);
@ -257,7 +245,7 @@ TEST_FUNCTION(g_timer_get_elapsed_in_ms_succeeds)
///arrange
LARGE_INTEGER pretendFreq;
pretendFreq.QuadPart = 1000;
STRICT_EXPECTED_CALL(mocked_QueryPerformanceFrequency(IGNORED_ARG))
.CopyOutArgumentBuffer_lpFrequency(&pretendFreq, sizeof(pretendFreq));