зеркало из https://github.com/Azure/c-pal.git
Merge branch 'master' into file_spec
This commit is contained in:
Коммит
4012905b09
|
@ -1 +1 @@
|
|||
#Copyright (C) Microsoft Corporation. All rights reserved.
|
||||
#Copyright (C) Microsoft Corporation. All rights reserved.
|
||||
|
|
|
@ -19,13 +19,6 @@ extern void* gballoc_malloc(size_t size);
|
|||
extern void* gballoc_calloc(size_t nmemb, size_t size);
|
||||
extern void* gballoc_realloc(void* ptr, size_t size);
|
||||
extern void gballoc_free(void* ptr);
|
||||
|
||||
|
||||
extern int gballoc_resetCounters(void);
|
||||
extern size_t gballoc_getMaximumMemoryUsed(void);
|
||||
extern size_t gballoc_getCurrentMemoryUsed(void);
|
||||
extern size_t gballoc_getAllocationCount(void));
|
||||
extern void gballoc_resetMetrics(void);
|
||||
```
|
||||
|
||||
### gballoc_init
|
||||
|
@ -42,8 +35,6 @@ extern int gballoc_init(void);
|
|||
|
||||
**SRS_GBALLOC_01_027: [** If the Lock creation fails, gballoc_init shall return a non-zero value. **]**
|
||||
|
||||
**SRS_GBALLOC_01_002: [** Upon initialization the total memory used and maximum total memory used tracked by the module shall be set to 0. **]**
|
||||
|
||||
### gballoc_deinit
|
||||
|
||||
```c
|
||||
|
@ -62,9 +53,7 @@ extern void* gballoc_malloc(size_t size);
|
|||
|
||||
**SRS_GBALLOC_01_003: [** gballoc_malloc shall call the C99 malloc function and return its result. **]**
|
||||
|
||||
**SRS_GBALLOC_01_004: [** If the underlying malloc call is successful, gballoc_malloc shall increment the total memory used with the amount indicated by size. **]**
|
||||
|
||||
**SRS_GBALLOC_01_012: [** When the underlying malloc call fails, gballoc_malloc shall return NULL and size should not be counted towards total memory used. **]**
|
||||
**SRS_GBALLOC_01_012: [** When the underlying malloc call fails, gballoc_malloc shall return NULL. **]**
|
||||
|
||||
**SRS_GBALLOC_01_013: [** When gballoc_malloc fails allocating memory for its internal use, gballoc_malloc shall return NULL. **]**
|
||||
|
||||
|
@ -82,9 +71,7 @@ extern void* gballoc_calloc(size_t nmemb, size_t size);
|
|||
|
||||
**SRS_GBALLOC_01_020: [** gballoc_calloc shall call the C99 calloc function and return its result. **]**
|
||||
|
||||
**SRS_GBALLOC_01_021: [** If the underlying calloc call is successful, gballoc_calloc shall increment the total memory used with nmemb*size. **]**
|
||||
|
||||
**SRS_GBALLOC_01_022: [** When the underlying calloc call fails, gballoc_calloc shall return NULL and size should not be counted towards total memory used. **]**
|
||||
**SRS_GBALLOC_01_022: [** When the underlying calloc call fails, gballoc_calloc shall return NULL. **]**
|
||||
|
||||
**SRS_GBALLOC_01_023: [** When gballoc_calloc fails allocating memory for its internal use, gballoc_calloc shall return NULL. **]**
|
||||
|
||||
|
@ -102,13 +89,9 @@ extern void* gballoc_realloc(void* ptr, size_t size);
|
|||
|
||||
**SRS_GBALLOC_01_005: [** gballoc_realloc shall call the C99 realloc function and return its result. **]**
|
||||
|
||||
**SRS_GBALLOC_01_006: [** If the underlying realloc call is successful, gballoc_realloc shall look up the size associated with the pointer ptr and decrease the total memory used with that size. **]**
|
||||
**SRS_GBALLOC_01_014: [** When the underlying realloc call fails, gballoc_realloc shall return NULL. **]**
|
||||
|
||||
**SRS_GBALLOC_01_007: [** If realloc is successful, gballoc_realloc shall also increment the total memory used value tracked by this module. **]**
|
||||
|
||||
**SRS_GBALLOC_01_014: [** When the underlying realloc call fails, gballoc_realloc shall return NULL and no change should be made to the counted total memory usage. **]**
|
||||
|
||||
**SRS_GBALLOC_01_015: [** When allocating memory used for tracking by gballoc_realloc fails, gballoc_realloc shall return NULL and no change should be made to the counted total memory usage. **]**
|
||||
**SRS_GBALLOC_01_015: [** When allocating memory used for tracking by gballoc_realloc fails, gballoc_realloc shall return NULL. **]**
|
||||
|
||||
**SRS_GBALLOC_01_016: [** When the ptr pointer cannot be found in the pointers tracked by gballoc, gballoc_realloc shall return NULL and the underlying realloc shall not be called. **]**
|
||||
|
||||
|
@ -128,7 +111,7 @@ extern void gballoc_free(void* ptr);
|
|||
|
||||
**SRS_GBALLOC_01_008: [** gballoc_free shall call the C99 free function. **]**
|
||||
|
||||
**SRS_GBALLOC_01_009: [** gballoc_free shall also look up the size associated with the ptr pointer and decrease the total memory used with the associated size amount. **]**
|
||||
**SRS_GBALLOC_01_009: [** gballoc_free shall also look up the size associated with the ptr pointer and release the used memory. **]**
|
||||
|
||||
**SRS_GBALLOC_01_019: [** When the ptr pointer cannot be found in the pointers tracked by gballoc, gballoc_free shall not free any memory. **]**
|
||||
|
||||
|
@ -137,61 +120,3 @@ extern void gballoc_free(void* ptr);
|
|||
**SRS_GBALLOC_01_042: [** If gballoc was not initialized gballoc_free shall shall simply call free. **]**
|
||||
|
||||
**SRS_GBALLOC_01_049: [** If acquiring the lock fails, gballoc_free shall do nothing. **]**
|
||||
|
||||
### gballoc_getMaximumMemoryUsed
|
||||
|
||||
```c
|
||||
extern size_t gballoc_getMaximumMemoryUsed(void);
|
||||
```
|
||||
|
||||
**SRS_GBALLOC_01_010: [** gballoc_getMaximumMemoryUsed shall return the maximum amount of total memory used recorded since the module initialization. **]**
|
||||
|
||||
**SRS_GBALLOC_01_011: [** The maximum total memory used shall be the maximum of the total memory used at any point. **]**
|
||||
|
||||
**SRS_GBALLOC_01_034: [** gballoc_getMaximumMemoryUsed shall ensure thread safety by using the lock created by gballoc_Init. **]**
|
||||
|
||||
**SRS_GBALLOC_01_038: [** If gballoc was not initialized gballoc_getMaximumMemoryUsed shall return MAX_INT_SIZE. **]**
|
||||
|
||||
**SRS_GBALLOC_01_050: [** If the lock cannot be acquired, gballoc_getMaximumMemoryUsed shall return SIZE_MAX. **]**
|
||||
|
||||
### gballoc_getCurrentMemoryUsed
|
||||
|
||||
```c
|
||||
extern size_t gballoc_getCurrentMemoryUsed(void);
|
||||
```
|
||||
|
||||
**SRS_GBALLOC_02_001: [** gballoc_getCurrentMemoryUsed shall return the currently used memory size. **]**
|
||||
|
||||
**SRS_GBALLOC_01_036: [** gballoc_getCurrentMemoryUsed shall ensure thread safety by using the lock created by gballoc_Init. **]**
|
||||
|
||||
**SRS_GBALLOC_01_044: [** If gballoc was not initialized gballoc_getCurrentMemoryUsed shall return SIZE_MAX. **]**
|
||||
|
||||
**SRS_GBALLOC_01_051: [** If the lock cannot be acquired, gballoc_getCurrentMemoryUsed shall return SIZE_MAX. **]**
|
||||
|
||||
### gballoc_getAllocationCount
|
||||
|
||||
```c
|
||||
extern size_t gballoc_getAllocationCount(void));
|
||||
```
|
||||
|
||||
**SRS_GBALLOC_07_001: [** If `gballoc` was not initialized `gballoc_getAllocationCount` shall return `0`. **]**
|
||||
|
||||
**SRS_GBALLOC_07_002: [** `gballoc_getAllocationCount` shall ensure thread safety by using the lock created by `gballoc_Init` **]**
|
||||
|
||||
**SRS_GBALLOC_07_003: [** If the lock cannot be acquired, `gballoc_getAllocationCount` shall return `0`. **]**
|
||||
|
||||
**SRS_GBALLOC_07_004: [** `gballoc_getAllocationCount` shall return the currently number of allocations. **]**
|
||||
|
||||
### gballoc_resetMetrics
|
||||
|
||||
```c
|
||||
extern void gballoc_resetMetrics(void);
|
||||
```
|
||||
|
||||
**SRS_GBALLOC_07_005: [** If `gballoc` was not initialized `gballoc_resetMetrics` shall do nothing.**]**
|
||||
|
||||
**SRS_GBALLOC_07_006: [** `gballoc_resetMetrics` shall ensure thread safety by using the lock created by `gballoc_Init` **]**
|
||||
|
||||
**SRS_GBALLOC_07_007: [** If the lock cannot be acquired, `gballoc_reset Metrics` shall do nothing.**]**
|
||||
|
||||
**SRS_GBALLOC_07_008: [** `gballoc_resetMetrics` shall reset the total allocation size, max allocation size and number of allocation to zero. **]**
|
||||
|
|
|
@ -42,11 +42,6 @@ MOCKABLE_FUNCTION(, void*, gballoc_calloc, size_t, nmemb, size_t, size);
|
|||
MOCKABLE_FUNCTION(, void*, gballoc_realloc, void*, ptr, size_t, size);
|
||||
MOCKABLE_FUNCTION(, void, gballoc_free, void*, ptr);
|
||||
|
||||
MOCKABLE_FUNCTION(, size_t, gballoc_getMaximumMemoryUsed);
|
||||
MOCKABLE_FUNCTION(, size_t, gballoc_getCurrentMemoryUsed);
|
||||
MOCKABLE_FUNCTION(, size_t, gballoc_getAllocationCount);
|
||||
MOCKABLE_FUNCTION(, void, gballoc_resetMetrics);
|
||||
|
||||
/* if GB_MEASURE_MEMORY_FOR_THIS is defined then we want to redirect memory allocation functions to gballoc_xxx functions */
|
||||
#ifdef GB_MEASURE_MEMORY_FOR_THIS
|
||||
/* Unfortunately this is still needed here for things to still compile when using _CRTDBG_MAP_ALLOC.
|
||||
|
@ -73,11 +68,6 @@ That is because there is a rogue component (most likely CppUnitTest) including c
|
|||
#define gballoc_init() 0
|
||||
#define gballoc_deinit() ((void)0)
|
||||
|
||||
#define gballoc_getMaximumMemoryUsed() SIZE_MAX
|
||||
#define gballoc_getCurrentMemoryUsed() SIZE_MAX
|
||||
#define gballoc_getAllocationCount() SIZE_MAX
|
||||
#define gballoc_resetMetrics() ((void)0)
|
||||
|
||||
#endif /* GB_DEBUG_ALLOC */
|
||||
|
||||
#ifdef __cplusplus
|
|
@ -5,7 +5,7 @@
|
|||
#include <stdint.h>
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "lock.h"
|
||||
#include "azure_c_pal/lock.h"
|
||||
|
||||
#ifndef GB_USE_CUSTOM_HEAP
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
|||
|
||||
typedef struct ALLOCATION_TAG
|
||||
{
|
||||
size_t size;
|
||||
void* ptr;
|
||||
void* next;
|
||||
} ALLOCATION;
|
||||
|
@ -27,9 +26,6 @@ typedef enum GBALLOC_STATE_TAG
|
|||
} GBALLOC_STATE;
|
||||
|
||||
static ALLOCATION* head = NULL;
|
||||
static size_t totalSize = 0;
|
||||
static size_t maxSize = 0;
|
||||
static size_t g_allocations = 0;
|
||||
static GBALLOC_STATE gballocState = GBALLOC_STATE_NOT_INIT;
|
||||
|
||||
static LOCK_HANDLE gballocThreadSafeLock = NULL;
|
||||
|
@ -53,11 +49,6 @@ int gballoc_init(void)
|
|||
{
|
||||
gballocState = GBALLOC_STATE_INIT;
|
||||
|
||||
/* Codes_SRS_GBALLOC_01_002: [Upon initialization the total memory used and maximum total memory used tracked by the module shall be set to 0.] */
|
||||
totalSize = 0;
|
||||
maxSize = 0;
|
||||
g_allocations = 0;
|
||||
|
||||
/* Codes_SRS_GBALLOC_01_024: [gballoc_init shall initialize the gballoc module and return 0 upon success.] */
|
||||
result = 0;
|
||||
}
|
||||
|
@ -109,24 +100,14 @@ void* gballoc_malloc(size_t size)
|
|||
result = malloc(size);
|
||||
if (result == NULL)
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_01_012: [When the underlying malloc call fails, gballoc_malloc shall return NULL and size should not be counted towards total memory used.] */
|
||||
/* Codes_SRS_GBALLOC_01_012: [When the underlying malloc call fails, gballoc_malloc shall return NULL.] */
|
||||
free(allocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_01_004: [If the underlying malloc call is successful, gb_malloc shall increment the total memory used with the amount indicated by size.] */
|
||||
allocation->ptr = result;
|
||||
allocation->size = size;
|
||||
allocation->next = head;
|
||||
head = allocation;
|
||||
|
||||
g_allocations++;
|
||||
totalSize += size;
|
||||
/* Codes_SRS_GBALLOC_01_011: [The maximum total memory used shall be the maximum of the total memory used at any point.] */
|
||||
if (maxSize < totalSize)
|
||||
{
|
||||
maxSize = totalSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,24 +147,14 @@ void* gballoc_calloc(size_t nmemb, size_t size)
|
|||
result = calloc(nmemb, size);
|
||||
if (result == NULL)
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_01_022: [When the underlying calloc call fails, gballoc_calloc shall return NULL and size should not be counted towards total memory used.] */
|
||||
/* Codes_SRS_GBALLOC_01_022: [When the underlying calloc call fails, gballoc_calloc shall return NULL.] */
|
||||
free(allocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_01_021: [If the underlying calloc call is successful, gballoc_calloc shall increment the total memory used with nmemb*size.] */
|
||||
allocation->ptr = result;
|
||||
allocation->size = nmemb * size;
|
||||
allocation->next = head;
|
||||
head = allocation;
|
||||
g_allocations++;
|
||||
|
||||
totalSize += allocation->size;
|
||||
/* Codes_SRS_GBALLOC_01_011: [The maximum total memory used shall be the maximum of the total memory used at any point.] */
|
||||
if (maxSize < totalSize)
|
||||
{
|
||||
maxSize = totalSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,7 +208,7 @@ void* gballoc_realloc(void* ptr, size_t size)
|
|||
|
||||
if (allocation == NULL)
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_01_015: [When allocating memory used for tracking by gballoc_realloc fails, gballoc_realloc shall return NULL and no change should be made to the counted total memory usage.] */
|
||||
/* Codes_SRS_GBALLOC_01_015: [When allocating memory used for tracking by gballoc_realloc fails, gballoc_realloc shall return NULL.] */
|
||||
/* Codes_SRS_GBALLOC_01_016: [When the ptr pointer cannot be found in the pointers tracked by gballoc, gballoc_realloc shall return NULL and the underlying realloc shall not be called.] */
|
||||
result = NULL;
|
||||
}
|
||||
|
@ -247,7 +218,7 @@ void* gballoc_realloc(void* ptr, size_t size)
|
|||
result = realloc(ptr, size);
|
||||
if (result == NULL)
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_01_014: [When the underlying realloc call fails, gballoc_realloc shall return NULL and no change should be made to the counted total memory usage.] */
|
||||
/* Codes_SRS_GBALLOC_01_014: [When the underlying realloc call fails, gballoc_realloc shall return NULL.] */
|
||||
if (ptr == NULL)
|
||||
{
|
||||
free(allocation);
|
||||
|
@ -257,32 +228,15 @@ void* gballoc_realloc(void* ptr, size_t size)
|
|||
{
|
||||
if (ptr != NULL)
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_01_006: [If the underlying realloc call is successful, gballoc_realloc shall look up the size associated with the pointer ptr and decrease the total memory used with that size.] */
|
||||
allocation->ptr = result;
|
||||
totalSize -= allocation->size;
|
||||
allocation->size = size;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* add block */
|
||||
allocation->ptr = result;
|
||||
allocation->size = size;
|
||||
allocation->next = head;
|
||||
head = allocation;
|
||||
}
|
||||
|
||||
/* Codes_SRS_GBALLOC_01_007: [If realloc is successful, gballoc_realloc shall also increment the total memory used value tracked by this module.] */
|
||||
totalSize += size;
|
||||
if (ptr == NULL)
|
||||
{
|
||||
g_allocations++;
|
||||
}
|
||||
|
||||
/* Codes_SRS_GBALLOC_01_011: [The maximum total memory used shall be the maximum of the total memory used at any point.] */
|
||||
if (maxSize < totalSize)
|
||||
{
|
||||
maxSize = totalSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,14 +264,13 @@ void gballoc_free(void* ptr)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_01_009: [gballoc_free shall also look up the size associated with the ptr pointer and decrease the total memory used with the associated size amount.] */
|
||||
/* Codes_SRS_GBALLOC_01_009: [gballoc_free shall also look up the size associated with the ptr pointer and release the used memory.] */
|
||||
while (curr != NULL)
|
||||
{
|
||||
if (curr->ptr == ptr)
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_01_008: [gballoc_free shall call the C99 free function.] */
|
||||
free(ptr);
|
||||
totalSize -= curr->size;
|
||||
if (prev != NULL)
|
||||
{
|
||||
prev->next = curr->next;
|
||||
|
@ -346,108 +299,4 @@ void gballoc_free(void* ptr)
|
|||
}
|
||||
}
|
||||
|
||||
size_t gballoc_getMaximumMemoryUsed(void)
|
||||
{
|
||||
size_t result;
|
||||
|
||||
/* Codes_SRS_GBALLOC_01_038: [If gballoc was not initialized gballoc_getMaximumMemoryUsed shall return MAX_INT_SIZE.] */
|
||||
if (gballocState != GBALLOC_STATE_INIT)
|
||||
{
|
||||
LogError("gballoc is not initialized.");
|
||||
result = SIZE_MAX;
|
||||
}
|
||||
/* Codes_SRS_GBALLOC_01_034: [gballoc_getMaximumMemoryUsed shall ensure thread safety by using the lock created by gballoc_Init.] */
|
||||
else if (LOCK_OK != Lock(gballocThreadSafeLock))
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_01_050: [If the lock cannot be acquired, gballoc_getMaximumMemoryUsed shall return SIZE_MAX.] */
|
||||
LogError("Failed to get the Lock.");
|
||||
result = SIZE_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_01_010: [gballoc_getMaximumMemoryUsed shall return the maximum amount of total memory used recorded since the module initialization.] */
|
||||
result = maxSize;
|
||||
(void)Unlock(gballocThreadSafeLock);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t gballoc_getCurrentMemoryUsed(void)
|
||||
{
|
||||
size_t result;
|
||||
|
||||
/* Codes_SRS_GBALLOC_01_044: [If gballoc was not initialized gballoc_getCurrentMemoryUsed shall return SIZE_MAX.] */
|
||||
if (gballocState != GBALLOC_STATE_INIT)
|
||||
{
|
||||
LogError("gballoc is not initialized.");
|
||||
result = SIZE_MAX;
|
||||
}
|
||||
/* Codes_SRS_GBALLOC_01_036: [gballoc_getCurrentMemoryUsed shall ensure thread safety by using the lock created by gballoc_Init.]*/
|
||||
else if (LOCK_OK != Lock(gballocThreadSafeLock))
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_01_051: [If the lock cannot be acquired, gballoc_getCurrentMemoryUsed shall return SIZE_MAX.] */
|
||||
LogError("Failed to get the Lock.");
|
||||
result = SIZE_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*Codes_SRS_GBALLOC_02_001: [gballoc_getCurrentMemoryUsed shall return the currently used memory size.] */
|
||||
result = totalSize;
|
||||
(void)Unlock(gballocThreadSafeLock);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t gballoc_getAllocationCount(void)
|
||||
{
|
||||
size_t result;
|
||||
|
||||
/* Codes_SRS_GBALLOC_07_001: [ If gballoc was not initialized gballoc_getAllocationCount shall return 0. ] */
|
||||
if (gballocState != GBALLOC_STATE_INIT)
|
||||
{
|
||||
LogError("gballoc is not initialized.");
|
||||
result = 0;
|
||||
}
|
||||
/* Codes_SRS_GBALLOC_07_002: [ gballoc_getAllocationCount shall ensure thread safety by using the lock created by gballoc_Init ] */
|
||||
else if (LOCK_OK != Lock(gballocThreadSafeLock))
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_07_003: [ If the lock cannot be acquired, gballoc_getAllocationCount shall return 0. ] */
|
||||
LogError("Failed to get the Lock.");
|
||||
result = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_07_004: [ gballoc_getAllocationCount shall return the currently number of allocations. ] */
|
||||
result = g_allocations;
|
||||
(void)Unlock(gballocThreadSafeLock);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void gballoc_resetMetrics()
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_07_005: [ If gballoc was not initialized gballoc_resetMetrics shall do nothing.] */
|
||||
if (gballocState != GBALLOC_STATE_INIT)
|
||||
{
|
||||
LogError("gballoc is not initialized.");
|
||||
}
|
||||
/* Codes_SRS_GBALLOC_07_006: [ gballoc_resetMetrics shall ensure thread safety by using the lock created by gballoc_Init ]*/
|
||||
else if (LOCK_OK != Lock(gballocThreadSafeLock))
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_07_007: [ If the lock cannot be acquired, gballoc_reset Metrics shall do nothing.] */
|
||||
LogError("Failed to get the Lock.");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Codes_SRS_GBALLOC_07_008: [ gballoc_resetMetrics shall reset the total allocation size, max allocation size and number of allocation to zero. ] */
|
||||
totalSize = 0;
|
||||
maxSize = 0;
|
||||
g_allocations = 0;
|
||||
(void)Unlock(gballocThreadSafeLock);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GB_USE_CUSTOM_HEAP
|
||||
|
|
|
@ -14,7 +14,7 @@ set(${theseTestsName}_c_files
|
|||
)
|
||||
|
||||
set(${theseTestsName}_h_files
|
||||
../../../interfaces/inc/lock.h
|
||||
../../../interfaces/inc/azure_c_pal/lock.h
|
||||
)
|
||||
|
||||
build_c_tests(${theseTestsName} ON "tests/azure_c_pal/common" ADDITIONAL_LIBS pal_interfaces)
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -13,8 +13,8 @@
|
|||
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "testrunnerswitcher.h"
|
||||
#include "lock.h"
|
||||
#include "gballoc.h"
|
||||
#include "azure_c_pal/lock.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX ((size_t)~(size_t)0)
|
||||
|
@ -179,48 +179,4 @@ TEST_FUNCTION(when_gballoc_is_not_initialized_then_gballoc_free_does_nothing)
|
|||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/* gballoc_getMaximumMemoryUsed */
|
||||
|
||||
/* Tests_SRS_GBALLOC_01_038: [If gballoc was not initialized gballoc_getMaximumMemoryUsed shall return MAX_INT_SIZE.] */
|
||||
TEST_FUNCTION(without_gballoc_being_initialized_gballoc_getMaximumMemoryUsed_fails)
|
||||
{
|
||||
// arrange
|
||||
|
||||
// act
|
||||
size_t result = gballoc_getMaximumMemoryUsed();
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(size_t, SIZE_MAX, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/* gballoc_getCurrentMemoryUsed */
|
||||
|
||||
/* Tests_SRS_GBALLOC_01_044: [If gballoc was not initialized gballoc_getCurrentMemoryUsed shall return SIZE_MAX.] */
|
||||
TEST_FUNCTION(without_gballoc_being_initialized_gballoc_getCurrentMemoryUsed_fails)
|
||||
{
|
||||
// arrange
|
||||
|
||||
// act
|
||||
size_t result = gballoc_getCurrentMemoryUsed();
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(size_t, SIZE_MAX, result);
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
/* gballoc_resetMetrics */
|
||||
|
||||
/* Tests_SRS_GBALLOC_07_005: [ If gballoc was not initialized gballoc_resetMetrics shall do nothing.] */
|
||||
TEST_FUNCTION(without_gballoc_being_initialized_gballoc_resetMetrics_returns)
|
||||
{
|
||||
// arrange
|
||||
|
||||
// act
|
||||
gballoc_resetMetrics();
|
||||
|
||||
// assert
|
||||
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
|
||||
}
|
||||
|
||||
END_TEST_SUITE(GBAlloc_For_Init_UnitTests)
|
||||
|
|
|
@ -28,7 +28,7 @@ static TEST_MUTEX_HANDLE g_testByTest;
|
|||
|
||||
#define ENABLE_MOCKS
|
||||
|
||||
#include "gballoc.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
|
||||
MU_DEFINE_ENUM_STRINGS(UMOCK_C_ERROR_CODE, UMOCK_C_ERROR_CODE_VALUES)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
#include <stddef.h>
|
||||
#include "refcount.h"
|
||||
#include "azure_c_pal/refcount.h"
|
||||
#include "some_refcount_impl.h"
|
||||
|
||||
typedef struct pos_TAG
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
#Copyright (C) Microsoft Corporation. All rights reserved.
|
||||
|
||||
set(pal_interfaces_h_files
|
||||
inc/execution_engine.h
|
||||
inc/async_socket.h
|
||||
inc/socket_handle.h
|
||||
inc/threadpool.h
|
||||
inc/interlocked.h
|
||||
inc/interlocked_hl.h
|
||||
inc/lock.h
|
||||
inc/platform.h
|
||||
inc/threadapi.h
|
||||
inc/timer.h
|
||||
inc/uniqueid.h
|
||||
inc/srw_lock.h
|
||||
inc/string_utils.h
|
||||
inc/sync.h
|
||||
inc/file.h
|
||||
inc/refcount.h
|
||||
inc/azure_c_pal/execution_engine.h
|
||||
inc/azure_c_pal/async_socket.h
|
||||
inc/azure_c_pal/socket_handle.h
|
||||
inc/azure_c_pal/threadpool.h
|
||||
inc/azure_c_pal/interlocked.h
|
||||
inc/azure_c_pal/interlocked_hl.h
|
||||
inc/azure_c_pal/lock.h
|
||||
inc/azure_c_pal/platform.h
|
||||
inc/azure_c_pal/threadapi.h
|
||||
inc/azure_c_pal/timer.h
|
||||
inc/azure_c_pal/uniqueid.h
|
||||
inc/azure_c_pal/srw_lock.h
|
||||
inc/azure_c_pal/string_utils.h
|
||||
inc/azure_c_pal/sync.h
|
||||
inc/azure_c_pal/file.h
|
||||
inc/azure_c_pal/refcount.h
|
||||
)
|
||||
|
||||
FILE(GLOB pal_interfaces_md_files "devdoc/*.md")
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#define ASYNC_SOCKET_H
|
||||
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "execution_engine.h"
|
||||
#include "azure_c_pal/execution_engine.h"
|
||||
#include "socket_handle.h"
|
||||
#include "umock_c/umock_c_prod.h"
|
||||
|
|
@ -23,7 +23,7 @@ will interact with deallocated memory / resources resulting in an undefined beha
|
|||
#endif
|
||||
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "gballoc.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
|
||||
// Include the platform-specific file that defines atomic functionality
|
||||
#include "refcount_os.h"
|
|
@ -1,29 +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 SYNC_H
|
||||
#define SYNC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <cstdint>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include "umock_c/umock_c_prod.h"
|
||||
#include "interlocked.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MOCKABLE_FUNCTION(, bool, wait_on_address, volatile_atomic int32_t*, address, int32_t*, compare_address, uint32_t, timeout_ms);
|
||||
MOCKABLE_FUNCTION(, void, wake_by_address_all, volatile_atomic int32_t*, address);
|
||||
MOCKABLE_FUNCTION(, void, wake_by_address_single, volatile_atomic int32_t*, address);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
#ifndef SYNC_H
|
||||
#define SYNC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <cstdint>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include "umock_c/umock_c_prod.h"
|
||||
#include "azure_c_pal/interlocked.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MOCKABLE_FUNCTION(, bool, wait_on_address, volatile_atomic int32_t*, address, int32_t*, compare_address, uint32_t, timeout_ms);
|
||||
MOCKABLE_FUNCTION(, void, wake_by_address_all, volatile_atomic int32_t*, address);
|
||||
MOCKABLE_FUNCTION(, void, wake_by_address_single, volatile_atomic int32_t*, address);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -10,7 +10,7 @@
|
|||
#endif
|
||||
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "execution_engine.h"
|
||||
#include "azure_c_pal/execution_engine.h"
|
||||
#include "umock_c/umock_c_prod.h"
|
||||
|
||||
#ifdef __cplusplus
|
|
@ -8,7 +8,7 @@ set(${theseTestsName}_test_files
|
|||
)
|
||||
|
||||
set(${theseTestsName}_h_files
|
||||
../../inc/interlocked.h
|
||||
../../inc/azure_c_pal/interlocked.h
|
||||
)
|
||||
|
||||
build_c_tests(${theseTestsName} ON "tests/azure_c_pal/int" ADDITIONAL_LIBS azure_c_pal)
|
||||
|
|
|
@ -18,7 +18,7 @@ static TEST_MUTEX_HANDLE g_testByTest;
|
|||
|
||||
|
||||
|
||||
#include "interlocked.h"
|
||||
#include "azure_c_pal/interlocked.h"
|
||||
|
||||
|
||||
BEGIN_TEST_SUITE(interlocked_int)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
InterlockedHL_CompareExchange64If \
|
||||
)
|
||||
|
||||
#include "interlocked_hl.h"
|
||||
#include "azure_c_pal/interlocked_hl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
|
||||
#include "srw_lock.h"
|
||||
#include "azure_c_pal/srw_lock.h"
|
||||
|
||||
#define R2(X) REGISTER_GLOBAL_MOCK_HOOK(X, real_##X);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
|
||||
#include "srw_lock.h"
|
||||
#include "azure_c_pal/srw_lock.h"
|
||||
|
||||
#define R2(X) REGISTER_GLOBAL_MOCK_HOOK(X, real_##X);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
|
||||
#include "threadapi.h"
|
||||
#include "azure_c_pal/threadapi.h"
|
||||
|
||||
#define R2(X) REGISTER_GLOBAL_MOCK_HOOK(X, real_##X);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
|
||||
#include "timer.h"
|
||||
#include "azure_c_pal/timer.h"
|
||||
|
||||
#define R2(X) REGISTER_GLOBAL_MOCK_HOOK(X, real_##X);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ set(${theseTestsName}_test_files
|
|||
)
|
||||
|
||||
set(${theseTestsName}_h_files
|
||||
../../inc/sync.h
|
||||
../../inc/azure_c_pal/sync.h
|
||||
)
|
||||
|
||||
build_c_tests(${theseTestsName} ON "tests/azure_c_pal/int" ADDITIONAL_LIBS azure_c_pal)
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
#endif
|
||||
|
||||
#include "testrunnerswitcher.h"
|
||||
#include "interlocked.h"
|
||||
#include "threadapi.h"
|
||||
#include "sync.h"
|
||||
#include "timer.h"
|
||||
#include "azure_c_pal/interlocked.h"
|
||||
#include "azure_c_pal/threadapi.h"
|
||||
#include "azure_c_pal/sync.h"
|
||||
#include "azure_c_pal/timer.h"
|
||||
|
||||
TEST_DEFINE_ENUM_TYPE(THREADAPI_RESULT, THREADAPI_RESULT_VALUES)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#else
|
||||
#include <stdatomic.h>
|
||||
#endif
|
||||
#include "interlocked.h"
|
||||
#include "azure_c_pal/interlocked.h"
|
||||
|
||||
IMPLEMENT_MOCKABLE_FUNCTION(, int32_t, interlocked_add, volatile_atomic int32_t*, addend, int32_t, value)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "lock.h"
|
||||
#include "azure_c_pal/lock.h"
|
||||
|
||||
|
||||
LOCK_HANDLE Lock_Init(void)
|
||||
|
|
|
@ -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 "platform.h"
|
||||
#include "azure_c_pal/platform.h"
|
||||
|
||||
int platform_init(void)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
#include "sync.h"
|
||||
#include "azure_c_pal/sync.h"
|
||||
|
||||
IMPLEMENT_MOCKABLE_FUNCTION(, bool, wait_on_address, volatile_atomic int32_t*, address, int32_t*, compare_address, uint32_t, timeout_ms)
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <time.h>
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
|
||||
#include "threadapi.h"
|
||||
#include "azure_c_pal/threadapi.h"
|
||||
|
||||
|
||||
MU_DEFINE_ENUM_STRINGS(THREADAPI_RESULT, THREADAPI_RESULT_VALUES);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "uniqueid.h"
|
||||
#include "azure_c_pal/uniqueid.h"
|
||||
|
||||
MU_DEFINE_ENUM_STRINGS(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ mock_interlocked.c
|
|||
)
|
||||
|
||||
set(${theseTestsName}_h_files
|
||||
../../../interfaces/inc/interlocked.h
|
||||
../../../interfaces/inc/azure_c_pal/interlocked.h
|
||||
mock_interlocked.h
|
||||
)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "umock_c/umock_c.h"
|
||||
#include "umock_c/umocktypes_stdint.h"
|
||||
|
||||
#include "interlocked.h"
|
||||
#include "azure_c_pal/interlocked.h"
|
||||
|
||||
|
||||
static TEST_MUTEX_HANDLE g_testByTest;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#endif
|
||||
|
||||
#include "umock_c/umock_c_prod.h"
|
||||
#include "interlocked.h"
|
||||
#include "azure_c_pal/interlocked.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#define REGISTER_GLOBAL_MOCK_HOOK(original, real) \
|
||||
(original == real) ? (void)0 : (void)1;
|
||||
|
||||
#include "threadapi.h"
|
||||
#include "azure_c_pal/threadapi.h"
|
||||
|
||||
#include "real_threadapi.h"
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ mock_sync.c
|
|||
)
|
||||
|
||||
set(${theseTestsName}_h_files
|
||||
../../../interfaces/inc/sync.h
|
||||
../../../interfaces/inc/azure_c_pal/sync.h
|
||||
mock_sync.h
|
||||
)
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "testrunnerswitcher.h"
|
||||
#include "umock_c/umock_c.h"
|
||||
|
||||
#include "sync.h"
|
||||
#include "azure_c_pal/sync.h"
|
||||
|
||||
static TEST_MUTEX_HANDLE g_testByTest;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ set(${theseTestsName}_c_files
|
|||
)
|
||||
|
||||
set(${theseTestsName}_h_files
|
||||
../../../interfaces/inc/uniqueid.h
|
||||
../../../interfaces/inc/azure_c_pal/uniqueid.h
|
||||
)
|
||||
|
||||
build_c_tests(${theseTestsName} ON "tests/azure_c_pal" ADDITIONAL_LIBS pal_interfaces uuid)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#endif
|
||||
|
||||
#include "testrunnerswitcher.h"
|
||||
#include "uniqueid.h"
|
||||
#include "azure_c_pal/uniqueid.h"
|
||||
|
||||
static TEST_MUTEX_HANDLE g_testByTest;
|
||||
static TEST_MUTEX_HANDLE g_dllByDll;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#endif
|
||||
|
||||
#include "windows.h"
|
||||
#include "execution_engine.h"
|
||||
#include "azure_c_pal/execution_engine.h"
|
||||
|
||||
#include "umock_c/umock_c_prod.h"
|
||||
|
||||
|
|
|
@ -7,14 +7,11 @@
|
|||
#include "windows.h"
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "gballoc.h"
|
||||
#include "async_socket.h"
|
||||
#include "execution_engine.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
#include "azure_c_pal/async_socket.h"
|
||||
#include "azure_c_pal/execution_engine.h"
|
||||
#include "execution_engine_win32.h"
|
||||
|
||||
#include "../inc/async_socket.h"
|
||||
|
||||
|
||||
#define ASYNC_SOCKET_WIN32_STATE_VALUES \
|
||||
ASYNC_SOCKET_WIN32_STATE_CLOSED, \
|
||||
ASYNC_SOCKET_WIN32_STATE_OPENING, \
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#include "windows.h"
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "execution_engine.h"
|
||||
#include "azure_c_pal/execution_engine.h"
|
||||
#include "execution_engine_win32.h"
|
||||
#include "refcount.h"
|
||||
#include "azure_c_pal/refcount.h"
|
||||
|
||||
typedef struct EXECUTION_ENGINE_TAG
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
|
||||
#include "interlocked_hl.h"
|
||||
#include "azure_c_pal/interlocked_hl.h"
|
||||
|
||||
MU_DEFINE_ENUM_STRINGS(INTERLOCKED_HL_RESULT, INTERLOCKED_HL_RESULT_VALUES)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
#include <stdint.h>
|
||||
#include "windows.h"
|
||||
#include "interlocked.h"
|
||||
#include "azure_c_pal/interlocked.h"
|
||||
|
||||
IMPLEMENT_MOCKABLE_FUNCTION(, int32_t, interlocked_add, volatile int32_t*, addend, int32_t, value)
|
||||
{
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include <windows.h>
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "lock.h"
|
||||
#include "gballoc.h"
|
||||
#include "azure_c_pal/lock.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
|
||||
LOCK_HANDLE Lock_Init(void)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "platform.h"
|
||||
#include "azure_c_pal/platform.h"
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "winsock2.h"
|
||||
#include "minwindef.h"
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
#include "windows.h"
|
||||
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "gballoc.h"
|
||||
#include "timer.h"
|
||||
#include "string_utils.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
#include "azure_c_pal/timer.h"
|
||||
#include "azure_c_pal/string_utils.h"
|
||||
|
||||
#include "srw_lock.h"
|
||||
#include "azure_c_pal/srw_lock.h"
|
||||
|
||||
/*
|
||||
vocabulary:
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
|
||||
#include "gballoc.h"
|
||||
#include "string_utils.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
#include "azure_c_pal/string_utils.h"
|
||||
|
||||
IMPLEMENT_MOCKABLE_FUNCTION(, char*, vsprintf_char, const char*, format, va_list, va)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
#include "windows.h"
|
||||
#include "sync.h"
|
||||
#include "azure_c_pal/sync.h"
|
||||
|
||||
IMPLEMENT_MOCKABLE_FUNCTION(, bool, wait_on_address, volatile_atomic int32_t*, address, int32_t*, compare_address, uint32_t, timeout_ms)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "windows.h"
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "threadapi.h"
|
||||
#include "azure_c_pal/threadapi.h"
|
||||
|
||||
MU_DEFINE_ENUM_STRINGS(THREADAPI_RESULT, THREADAPI_RESULT_VALUES);
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "windows.h"
|
||||
#include "gballoc.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "threadpool.h"
|
||||
#include "execution_engine.h"
|
||||
#include "azure_c_pal/threadpool.h"
|
||||
#include "azure_c_pal/execution_engine.h"
|
||||
#include "execution_engine_win32.h"
|
||||
|
||||
#define THREADPOOL_WIN32_STATE_VALUES \
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
#include "windows.h"
|
||||
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "gballoc.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
|
||||
#include "timer.h"
|
||||
#include "azure_c_pal/timer.h"
|
||||
|
||||
typedef struct TIMER_HANDLE_DATA_TAG
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <stdint.h>
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "rpc.h"
|
||||
#include "uniqueid.h"
|
||||
#include "azure_c_pal/uniqueid.h"
|
||||
|
||||
MU_DEFINE_ENUM_STRINGS(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES);
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include "windows.h"
|
||||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "testrunnerswitcher.h"
|
||||
#include "async_socket.h"
|
||||
#include "execution_engine.h"
|
||||
#include "azure_c_pal/async_socket.h"
|
||||
#include "azure_c_pal/execution_engine.h"
|
||||
#include "execution_engine_win32.h"
|
||||
|
||||
static TEST_MUTEX_HANDLE test_serialize_mutex;
|
||||
|
|
|
@ -14,7 +14,7 @@ async_socket_win32_mocked.c
|
|||
)
|
||||
|
||||
set(${theseTestsName}_h_files
|
||||
../../../interfaces/inc/async_socket.h
|
||||
../../../interfaces/inc/azure_c_pal/async_socket.h
|
||||
)
|
||||
|
||||
build_c_tests(${theseTestsName} ON "tests/azure_c_pal/win32" ADDITIONAL_LIBS pal_interfaces synchronization ws2_32)
|
||||
|
|
|
@ -31,13 +31,13 @@ void real_free(void* ptr)
|
|||
|
||||
#define ENABLE_MOCKS
|
||||
|
||||
#include "gballoc.h"
|
||||
#include "execution_engine.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
#include "azure_c_pal/execution_engine.h"
|
||||
#include "execution_engine_win32.h"
|
||||
|
||||
#undef ENABLE_MOCKS
|
||||
|
||||
#include "async_socket.h"
|
||||
#include "azure_c_pal/async_socket.h"
|
||||
|
||||
static TEST_MUTEX_HANDLE test_serialize_mutex;
|
||||
static SOCKET_HANDLE test_socket = (SOCKET_HANDLE)0x4242;
|
||||
|
|
|
@ -15,7 +15,7 @@ execution_engine_win32_mocked.c
|
|||
|
||||
set(${theseTestsName}_h_files
|
||||
../../inc/execution_engine_win32.h
|
||||
../../../interfaces/inc/execution_engine.h
|
||||
../../../interfaces/inc/azure_c_pal/execution_engine.h
|
||||
)
|
||||
|
||||
build_c_tests(${theseTestsName} ON "tests/azure_c_pal/win32" ADDITIONAL_LIBS pal_interfaces)
|
||||
|
|
|
@ -25,11 +25,11 @@ void real_free(void* ptr)
|
|||
#include "umock_c/umock_c.h"
|
||||
#include "umock_c/umocktypes_stdint.h"
|
||||
#include "umock_c/umock_c_negative_tests.h"
|
||||
#include "execution_engine.h"
|
||||
#include "azure_c_pal/execution_engine.h"
|
||||
|
||||
#define ENABLE_MOCKS
|
||||
|
||||
#include "gballoc.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
|
||||
#undef ENABLE_MOCKS
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ set(${theseTestsName}_c_files
|
|||
)
|
||||
|
||||
set(${theseTestsName}_h_files
|
||||
../../../interfaces/inc/interlocked_hl.h
|
||||
../../../interfaces/inc/azure_c_pal/interlocked_hl.h
|
||||
../mocked/inc/windows.h
|
||||
)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ static TEST_MUTEX_HANDLE g_testByTest;
|
|||
#include "umock_c/umock_c.h"
|
||||
#include "umock_c/umocktypes_stdint.h"
|
||||
|
||||
#include "interlocked_hl.h"
|
||||
#include "azure_c_pal/interlocked_hl.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)
|
||||
|
|
|
@ -15,7 +15,7 @@ mock_interlocked.c
|
|||
)
|
||||
|
||||
set(${theseTestsName}_h_files
|
||||
../../../interfaces/inc/interlocked.h
|
||||
../../../interfaces/inc/azure_c_pal/interlocked.h
|
||||
mock_interlocked.h
|
||||
)
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "umock_c/umock_c.h"
|
||||
#include "umock_c/umocktypes_windows.h"
|
||||
|
||||
#include "interlocked.h"
|
||||
#include "azure_c_pal/interlocked.h"
|
||||
|
||||
static TEST_MUTEX_HANDLE g_testByTest;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ set(${theseTestsName}_c_files
|
|||
)
|
||||
|
||||
set(${theseTestsName}_h_files
|
||||
../../../interfaces/inc/lock.h
|
||||
../../../interfaces/inc/azure_c_pal/lock.h
|
||||
)
|
||||
|
||||
build_c_tests(${theseTestsName} ON "tests/azure_c_pal/win32" ADDITIONAL_LIBS pal_interfaces)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "testrunnerswitcher.h"
|
||||
#include "umock_c/umock_c.h"
|
||||
#include "lock.h"
|
||||
#include "azure_c_pal/lock.h"
|
||||
|
||||
static void* my_gballoc_malloc(size_t size)
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ static void my_gballoc_free(void* ptr)
|
|||
}
|
||||
|
||||
#define ENABLE_MOCKS
|
||||
#include "gballoc.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
#undef ENABLE_MOCKS
|
||||
|
||||
TEST_DEFINE_ENUM_TYPE(LOCK_RESULT, LOCK_RESULT_VALUES);
|
||||
|
|
|
@ -35,7 +35,7 @@ void my_gballoc_free(void* ptr)
|
|||
#include "umock_c/umock_c_prod.h"
|
||||
#undef ENABLE_MOCKS
|
||||
|
||||
#include "platform.h"
|
||||
#include "azure_c_pal/platform.h"
|
||||
|
||||
#define ENABLE_MOCKS
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
#define REGISTER_GLOBAL_MOCK_HOOK(original, real) \
|
||||
(original == real) ? (void)0 : (void)1;
|
||||
|
||||
#include "threadapi.h"
|
||||
#include "srw_lock.h"
|
||||
#include "string_utils.h"
|
||||
#include "timer.h"
|
||||
#include "interlocked_hl.h"
|
||||
#include "azure_c_pal/threadapi.h"
|
||||
#include "azure_c_pal/srw_lock.h"
|
||||
#include "azure_c_pal/string_utils.h"
|
||||
#include "azure_c_pal/timer.h"
|
||||
#include "azure_c_pal/interlocked_hl.h"
|
||||
|
||||
#include "real_threadapi.h"
|
||||
#include "real_srw_lock.h"
|
||||
|
|
|
@ -26,8 +26,8 @@ static void my_gballoc_free(void* s)
|
|||
#include "umock_c/umocktypes.h"
|
||||
|
||||
#define ENABLE_MOCKS
|
||||
#include "gballoc.h"
|
||||
#include "timer.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
#include "azure_c_pal/timer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"{
|
||||
|
@ -45,7 +45,7 @@ MOCKABLE_FUNCTION(, void, mocked_ReleaseSRWLockShared, PSRWLOCK, SRWLock);
|
|||
|
||||
#undef ENABLE_MOCKS
|
||||
|
||||
#include "srw_lock.h"
|
||||
#include "azure_c_pal/srw_lock.h"
|
||||
|
||||
static TEST_MUTEX_HANDLE test_serialize_mutex;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include "testrunnerswitcher.h"
|
||||
|
||||
#include "string_utils.h"
|
||||
#include "azure_c_pal/string_utils.h"
|
||||
|
||||
|
||||
BEGIN_TEST_SUITE(string_utils_int_tests)
|
||||
|
|
|
@ -15,7 +15,7 @@ mock_sync.c
|
|||
)
|
||||
|
||||
set(${theseTestsName}_h_files
|
||||
../../../interfaces/inc/sync.h
|
||||
../../../interfaces/inc/azure_c_pal/sync.h
|
||||
mock_sync.h
|
||||
)
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "umock_c/umock_c.h"
|
||||
#include "umock_c/umocktypes_windows.h"
|
||||
|
||||
#include "sync.h"
|
||||
#include "azure_c_pal/sync.h"
|
||||
|
||||
static TEST_MUTEX_HANDLE g_testByTest;
|
||||
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
#include "azure_macro_utils/macro_utils.h"
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "testrunnerswitcher.h"
|
||||
#include "interlocked_hl.h"
|
||||
#include "timer.h"
|
||||
#include "threadpool.h"
|
||||
#include "execution_engine.h"
|
||||
#include "azure_c_pal/interlocked_hl.h"
|
||||
#include "azure_c_pal/timer.h"
|
||||
#include "azure_c_pal/threadpool.h"
|
||||
#include "azure_c_pal/execution_engine.h"
|
||||
#include "execution_engine_win32.h"
|
||||
|
||||
TEST_DEFINE_ENUM_TYPE(INTERLOCKED_HL_RESULT, INTERLOCKED_HL_RESULT_VALUES);
|
||||
|
|
|
@ -15,8 +15,8 @@ threadpool_win32_mocked.c
|
|||
)
|
||||
|
||||
set(${theseTestsName}_h_files
|
||||
../../../interfaces/inc/threadpool.h
|
||||
../../../interfaces/inc/string_utils.h
|
||||
../../../interfaces/inc/azure_c_pal/threadpool.h
|
||||
../../../interfaces/inc/azure_c_pal/string_utils.h
|
||||
)
|
||||
|
||||
build_c_tests(${theseTestsName} ON "tests/azure_c_pal/win32" ADDITIONAL_LIBS pal_interfaces synchronization)
|
||||
|
|
|
@ -31,16 +31,16 @@ void real_free(void* ptr)
|
|||
|
||||
#define ENABLE_MOCKS
|
||||
|
||||
#include "gballoc.h"
|
||||
#include "execution_engine.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
#include "azure_c_pal/execution_engine.h"
|
||||
#include "execution_engine_win32.h"
|
||||
|
||||
#undef ENABLE_MOCKS
|
||||
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
|
||||
#include "string_utils.h"
|
||||
#include "threadpool.h"
|
||||
#include "azure_c_pal/string_utils.h"
|
||||
#include "azure_c_pal/threadpool.h"
|
||||
|
||||
static TEST_MUTEX_HANDLE test_serialize_mutex;
|
||||
static EXECUTION_ENGINE_HANDLE test_execution_engine = (EXECUTION_ENGINE_HANDLE)0x4243;
|
||||
|
|
|
@ -26,10 +26,10 @@ static void my_gballoc_free(void* s)
|
|||
#include "umock_c/umocktypes.h"
|
||||
#include "umock_c/umock_c_negative_tests.h"
|
||||
#include "umock_c/umocktypes_bool.h"
|
||||
#include "timer.h"
|
||||
#include "azure_c_pal/timer.h"
|
||||
|
||||
#define ENABLE_MOCKS
|
||||
#include "gballoc.h"
|
||||
#include "azure_c_pal/gballoc.h"
|
||||
#undef ENABLE_MOCKS
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -14,7 +14,7 @@ set(${theseTestsName}_c_files
|
|||
)
|
||||
|
||||
set(${theseTestsName}_h_files
|
||||
../../../interfaces/inc/uniqueid.h
|
||||
../../../interfaces/inc/azure_c_pal/uniqueid.h
|
||||
)
|
||||
|
||||
build_c_tests(${theseTestsName} ON "tests/azure_c_pal/win32" ADDITIONAL_LIBS rpcrt4.lib pal_interfaces)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "testrunnerswitcher.h"
|
||||
#include "umock_c/umock_c.h"
|
||||
#include "umock_c/umock_c_negative_tests.h"
|
||||
#include "uniqueid.h"
|
||||
#include "azure_c_pal/uniqueid.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Загрузка…
Ссылка в новой задаче