Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of azure_c_shared_utility by
Revision 2:20b88da3e604, committed 2016-05-09
- Comitter:
- AzureIoTClient
- Date:
- Mon May 09 14:37:45 2016 -0700
- Parent:
- 1:9190c0f4d23a
- Child:
- 3:1229e35d5f3c
- Commit message:
- 1.0.6
Changed in this revision
--- a/azure_c_shared_utility/agenttime.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/agenttime.h Mon May 09 14:37:45 2016 -0700 @@ -13,6 +13,7 @@ #define AGENTTIME_H #include <time.h> +#include "azure_c_shared_utility/umock_c_prod.h" #ifdef __cplusplus extern "C" @@ -24,21 +25,21 @@ * @details This function provides the same functionality as the * standard C @c time() function. */ -extern time_t get_time(time_t* currentTime); +MOCKABLE_FUNCTION(, time_t, get_time, time_t*, currentTime); /** @brief Get UTC in @c tm struct. * * @details This function provides the same functionality as the * standard C @c gmtime() function. */ -extern struct tm* get_gmtime(time_t* currentTime); +MOCKABLE_FUNCTION(, struct tm*, get_gmtime, time_t*, currentTime); /** @brief Gets a C-string representation of the given time. * * @details This function provides the same functionality as the * standard C @c ctime() function. */ -extern char* get_ctime(time_t* timeToGet); +MOCKABLE_FUNCTION(, char*, get_ctime, time_t*, timeToGet); /** @brief Gets the difference in seconds between @c stopTime and * @c startTime. @@ -46,7 +47,7 @@ * @details This function provides the same functionality as the * standard C @c difftime() function. */ -extern double get_difftime(time_t stopTime, time_t startTime); +MOCKABLE_FUNCTION(, double, get_difftime, time_t, stopTime, time_t, startTime); #ifdef __cplusplus }
--- a/azure_c_shared_utility/base64.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/base64.h Mon May 09 14:37:45 2016 -0700 @@ -19,6 +19,8 @@ #include <stddef.h> #endif +#include "azure_c_shared_utility/umock_c_prod.h" + /** * @brief Base64 encodes a buffer and returns the resulting string. * @@ -34,7 +36,7 @@ * * @return A @c STRING_HANDLE containing the base64 encoding of @p input. */ -extern STRING_HANDLE Base64_Encode(BUFFER_HANDLE input); +MOCKABLE_FUNCTION(, STRING_HANDLE, Base64_Encode, BUFFER_HANDLE, input); /** * @brief Base64 encodes the buffer pointed to by @p source and returns the resulting string. @@ -54,7 +56,7 @@ * of @p input. * */ -extern STRING_HANDLE Base64_Encode_Bytes(const unsigned char* source, size_t size); +MOCKABLE_FUNCTION(, STRING_HANDLE, Base64_Encode_Bytes, const unsigned char*, source, size_t, size); /** * @brief Base64 decodes the buffer pointed to by @p source and returns the resulting buffer. @@ -71,7 +73,7 @@ * @return A @c BUFFER_HANDLE pointing to a buffer containing the result of base64 decoding @p * source. */ -extern BUFFER_HANDLE Base64_Decoder(const char* source); +MOCKABLE_FUNCTION(, BUFFER_HANDLE, Base64_Decoder, const char*, source); #ifdef __cplusplus }
--- a/azure_c_shared_utility/buffer_.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/buffer_.h Mon May 09 14:37:45 2016 -0700 @@ -12,22 +12,24 @@ #include <stddef.h> #endif +#include "azure_c_shared_utility/umock_c_prod.h" + typedef struct BUFFER_TAG* BUFFER_HANDLE; -extern BUFFER_HANDLE BUFFER_new(void); -extern BUFFER_HANDLE BUFFER_create(const unsigned char* source, size_t size); -extern void BUFFER_delete(BUFFER_HANDLE handle); -extern int BUFFER_pre_build(BUFFER_HANDLE handle, size_t size); -extern int BUFFER_build(BUFFER_HANDLE handle, const unsigned char* source, size_t size); -extern int BUFFER_unbuild(BUFFER_HANDLE handle); -extern int BUFFER_enlarge(BUFFER_HANDLE handle, size_t enlargeSize); -extern int BUFFER_content(BUFFER_HANDLE handle, const unsigned char** content); -extern int BUFFER_size(BUFFER_HANDLE handle, size_t* size); -extern int BUFFER_append(BUFFER_HANDLE handle1, BUFFER_HANDLE handle2); -extern int BUFFER_prepend(BUFFER_HANDLE handle1, BUFFER_HANDLE handle2); -extern unsigned char* BUFFER_u_char(BUFFER_HANDLE handle); -extern size_t BUFFER_length(BUFFER_HANDLE handle); -extern BUFFER_HANDLE BUFFER_clone(BUFFER_HANDLE handle); +MOCKABLE_FUNCTION(, BUFFER_HANDLE, BUFFER_new); +MOCKABLE_FUNCTION(, BUFFER_HANDLE, BUFFER_create, const unsigned char*, source, size_t, size); +MOCKABLE_FUNCTION(, void, BUFFER_delete, BUFFER_HANDLE, handle); +MOCKABLE_FUNCTION(, int, BUFFER_pre_build, BUFFER_HANDLE, handle, size_t, size); +MOCKABLE_FUNCTION(, int, BUFFER_build, BUFFER_HANDLE, handle, const unsigned char*, source, size_t, size); +MOCKABLE_FUNCTION(, int, BUFFER_unbuild, BUFFER_HANDLE, handle); +MOCKABLE_FUNCTION(, int, BUFFER_enlarge, BUFFER_HANDLE, handle, size_t, enlargeSize); +MOCKABLE_FUNCTION(, int, BUFFER_content, BUFFER_HANDLE, handle, const unsigned char**, content); +MOCKABLE_FUNCTION(, int, BUFFER_size, BUFFER_HANDLE, handle, size_t*, size); +MOCKABLE_FUNCTION(, int, BUFFER_append, BUFFER_HANDLE, handle1, BUFFER_HANDLE, handle2); +MOCKABLE_FUNCTION(, int, BUFFER_prepend, BUFFER_HANDLE, handle1, BUFFER_HANDLE, handle2); +MOCKABLE_FUNCTION(, unsigned char*, BUFFER_u_char, BUFFER_HANDLE, handle); +MOCKABLE_FUNCTION(, size_t, BUFFER_length, BUFFER_HANDLE, handle); +MOCKABLE_FUNCTION(, BUFFER_HANDLE, BUFFER_clone, BUFFER_HANDLE, handle); #ifdef __cplusplus }
--- a/azure_c_shared_utility/condition.h Sun Apr 24 16:41:14 2016 -0700
+++ b/azure_c_shared_utility/condition.h Mon May 09 14:37:45 2016 -0700
@@ -6,6 +6,7 @@
#include "azure_c_shared_utility/macro_utils.h"
#include "azure_c_shared_utility/lock.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
#ifdef __cplusplus
extern "C" {
@@ -29,7 +30,7 @@
*
* @return A valid @c COND_HANDLE when successful or @c NULL otherwise.
*/
-extern COND_HANDLE Condition_Init(void);
+MOCKABLE_FUNCTION(, COND_HANDLE, Condition_Init);
/**
* @brief unblock all currently working condition.
@@ -40,7 +41,7 @@
* destroyed and @c COND_ERROR when an error occurs
* and @c COND_TIMEOUT when the handle times out.
*/
-extern COND_RESULT Condition_Post(COND_HANDLE handle);
+MOCKABLE_FUNCTION(, COND_RESULT, Condition_Post, COND_HANDLE, handle);
/**
* @brief block on the condition handle unti the thread is signalled
@@ -52,7 +53,7 @@
* destroyed and @c COND_ERROR when an error occurs
* and @c COND_TIMEOUT when the handle times out.
*/
-extern COND_RESULT Condition_Wait(COND_HANDLE handle, LOCK_HANDLE lock, int timeout_milliseconds);
+MOCKABLE_FUNCTION(, COND_RESULT, Condition_Wait, COND_HANDLE, handle, LOCK_HANDLE, lock, int, timeout_milliseconds);
/**
* @brief The condition instance is deinitialized.
@@ -62,10 +63,10 @@
* @return Returns @c COND_OK when the condition object has been
* destroyed and @c COND_ERROR when an error occurs.
*/
-extern void Condition_Deinit(COND_HANDLE handle);
+MOCKABLE_FUNCTION(, void, Condition_Deinit, COND_HANDLE, handle);
#ifdef __cplusplus
}
#endif
-#endif /* LOCK_H */
+#endif /* CONDITION_H */
--- a/azure_c_shared_utility/constbuffer.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/constbuffer.h Mon May 09 14:37:45 2016 -0700 @@ -14,6 +14,8 @@ #include <stddef.h> #endif +#include "azure_c_shared_utility/umock_c_prod.h" + /*this is the handle*/ typedef struct CONSTBUFFER_HANDLE_DATA_TAG* CONSTBUFFER_HANDLE; @@ -25,16 +27,16 @@ } CONSTBUFFER; /*this creates a new constbuffer from a memory area*/ -extern CONSTBUFFER_HANDLE CONSTBUFFER_Create(const unsigned char* source, size_t size); +MOCKABLE_FUNCTION(, CONSTBUFFER_HANDLE, CONSTBUFFER_Create, const unsigned char*, source, size_t, size); /*this creates a new constbuffer from an existing BUFFER_HANDLE*/ -extern CONSTBUFFER_HANDLE CONSTBUFFER_CreateFromBuffer(BUFFER_HANDLE buffer); +MOCKABLE_FUNCTION(, CONSTBUFFER_HANDLE, CONSTBUFFER_CreateFromBuffer, BUFFER_HANDLE, buffer); -extern CONSTBUFFER_HANDLE CONSTBUFFER_Clone(CONSTBUFFER_HANDLE constbufferHandle); +MOCKABLE_FUNCTION(, CONSTBUFFER_HANDLE, CONSTBUFFER_Clone, CONSTBUFFER_HANDLE, constbufferHandle); -extern const CONSTBUFFER* CONSTBUFFER_GetContent(CONSTBUFFER_HANDLE constbufferHandle); +MOCKABLE_FUNCTION(, const CONSTBUFFER*, CONSTBUFFER_GetContent, CONSTBUFFER_HANDLE, constbufferHandle); -extern void CONSTBUFFER_Destroy(CONSTBUFFER_HANDLE constbufferHandle); +MOCKABLE_FUNCTION(, void, CONSTBUFFER_Destroy, CONSTBUFFER_HANDLE, constbufferHandle); #ifdef __cplusplus }
--- a/azure_c_shared_utility/constmap.h Sun Apr 24 16:41:14 2016 -0700
+++ b/azure_c_shared_utility/constmap.h Mon May 09 14:37:45 2016 -0700
@@ -21,6 +21,7 @@
#include "azure_c_shared_utility/macro_utils.h"
#include "azure_c_shared_utility/crt_abstractions.h"
#include "azure_c_shared_utility/map.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
#define CONSTMAP_RESULT_VALUES \
CONSTMAP_OK, \
@@ -44,20 +45,20 @@
*
* @return A valid @c CONSTMAP_HANDLE or @c NULL in case an error occurs.
*/
-extern CONSTMAP_HANDLE ConstMap_Create(MAP_HANDLE sourceMap);
+MOCKABLE_FUNCTION(, CONSTMAP_HANDLE, ConstMap_Create, MAP_HANDLE, sourceMap);
/**
* @brief Destroy a read-only map. Deallocate memory associated with handle.
* @param handle Handle to a read-only map.
*/
-extern void ConstMap_Destroy(CONSTMAP_HANDLE handle);
+MOCKABLE_FUNCTION(, void, ConstMap_Destroy, CONSTMAP_HANDLE, handle);
/**
* @brief Clone a read-only map from another read-only map.
* @param handle Handle to a read-only map.
* @return A valid @c CONSTMAP_HANDLE or @c NULL in case an error occurs.
*/
-extern CONSTMAP_HANDLE ConstMap_Clone(CONSTMAP_HANDLE handle);
+MOCKABLE_FUNCTION(, CONSTMAP_HANDLE, ConstMap_Clone, CONSTMAP_HANDLE, handle);
/**
* @brief Create a map handle populated from the read-only map.
@@ -66,7 +67,7 @@
*
* The new MAP_HANDLE needs to be destroyed when it is no longer needed.
*/
-extern MAP_HANDLE ConstMap_CloneWriteable(CONSTMAP_HANDLE handle);
+MOCKABLE_FUNCTION(, MAP_HANDLE, ConstMap_CloneWriteable, CONSTMAP_HANDLE, handle);
/**
* @brief This function returns a true if the map contains a key
@@ -79,7 +80,7 @@
* in the map and @c false if key is not found or
* parameters are invalid.
*/
-extern bool ConstMap_ContainsKey(CONSTMAP_HANDLE handle, const char* key);
+MOCKABLE_FUNCTION(, bool, ConstMap_ContainsKey, CONSTMAP_HANDLE, handle, const char*, key);
/**
* @brief This function returns @c true if at least one <key,value> pair
@@ -93,7 +94,7 @@
* in the map and @c false if value is not found or
* parameters are invalid.
*/
-extern bool ConstMap_ContainsValue(CONSTMAP_HANDLE handle, const char* value);
+MOCKABLE_FUNCTION(, bool, ConstMap_ContainsValue, CONSTMAP_HANDLE, handle, const char*, value);
/**
* @brief Retrieves the value of a stored key.
@@ -105,7 +106,7 @@
* requested key is not found in the map. Returns a pointer to the
* key's value otherwise.
*/
-extern const char* ConstMap_GetValue(CONSTMAP_HANDLE handle, const char* key);
+MOCKABLE_FUNCTION(, const char*, ConstMap_GetValue, CONSTMAP_HANDLE, handle, const char*, key);
/**
* @brief Retrieves the complete list of keys and values from the map
@@ -121,7 +122,7 @@
* @return Returns @c CONSTMAP_OK if the keys and values are retrieved
* and written successfully or an error code otherwise.
*/
-extern CONSTMAP_RESULT ConstMap_GetInternals(CONSTMAP_HANDLE handle, const char*const** keys, const char*const** values, size_t* count);
+MOCKABLE_FUNCTION(, CONSTMAP_RESULT, ConstMap_GetInternals, CONSTMAP_HANDLE, handle, const char*const**, keys, const char*const**, values, size_t*, count);
#ifdef __cplusplus
--- a/azure_c_shared_utility/crt_abstractions.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/crt_abstractions.h Mon May 09 14:37:45 2016 -0700 @@ -4,6 +4,8 @@ #ifndef CRT_ABSTRACTIONS_H #define CRT_ABSTRACTIONS_H +#include "azure_c_shared_utility/umock_c_prod.h" + #ifdef __cplusplus #include <cstdio> #include <cstring> @@ -96,9 +98,9 @@ extern int sprintf_s(char* dst, size_t dstSizeInBytes, const char* format, ...); #endif -extern int mallocAndStrcpy_s(char** destination, const char*source); -extern int unsignedIntToString(char* destination, size_t destinationSize, unsigned int value); -extern int size_tToString(char* destination, size_t destinationSize, size_t value); +MOCKABLE_FUNCTION(, int, mallocAndStrcpy_s, char**, destination, const char*, source); +MOCKABLE_FUNCTION(, int, unsignedIntToString, char*, destination, size_t, destinationSize, unsigned int, value); +MOCKABLE_FUNCTION(, int, size_tToString, char*, destination, size_t, destinationSize, size_t, value); /*following logic shall define the ISNAN macro*/ /*if runing on Microsoft Visual C compiler, than ISNAN shall be _isnan*/ /*else if running on C99 or C11, ISNAN shall be isnan*/
--- a/azure_c_shared_utility/doublylinkedlist.h Sun Apr 24 16:41:14 2016 -0700
+++ b/azure_c_shared_utility/doublylinkedlist.h Mon May 09 14:37:45 2016 -0700
@@ -12,19 +12,21 @@
#include <stddef.h>
#endif
+#include "azure_c_shared_utility/umock_c_prod.h"
+
typedef struct DLIST_ENTRY_TAG
{
struct DLIST_ENTRY_TAG *Flink;
struct DLIST_ENTRY_TAG *Blink;
} DLIST_ENTRY, *PDLIST_ENTRY;
-extern void DList_InitializeListHead(PDLIST_ENTRY listHead);
-extern int DList_IsListEmpty(const PDLIST_ENTRY listHead);
-extern void DList_InsertTailList(PDLIST_ENTRY listHead, PDLIST_ENTRY listEntry);
-extern void DList_InsertHeadList(PDLIST_ENTRY listHead, PDLIST_ENTRY listEntry);
-extern void DList_AppendTailList(PDLIST_ENTRY listHead, PDLIST_ENTRY ListToAppend);
-extern int DList_RemoveEntryList(PDLIST_ENTRY listEntry);
-extern PDLIST_ENTRY DList_RemoveHeadList(PDLIST_ENTRY listHead);
+MOCKABLE_FUNCTION(, void, DList_InitializeListHead, PDLIST_ENTRY, listHead);
+MOCKABLE_FUNCTION(, int, DList_IsListEmpty, const PDLIST_ENTRY, listHead);
+MOCKABLE_FUNCTION(, void, DList_InsertTailList, PDLIST_ENTRY, listHead, PDLIST_ENTRY, listEntry);
+MOCKABLE_FUNCTION(, void, DList_InsertHeadList, PDLIST_ENTRY, listHead, PDLIST_ENTRY, listEntry);
+MOCKABLE_FUNCTION(, void, DList_AppendTailList, PDLIST_ENTRY, listHead, PDLIST_ENTRY, ListToAppend);
+MOCKABLE_FUNCTION(, int, DList_RemoveEntryList, PDLIST_ENTRY, listEntry);
+MOCKABLE_FUNCTION(, PDLIST_ENTRY, DList_RemoveHeadList, PDLIST_ENTRY, listHead);
//
// Calculate the address of the base of the structure given its type, and an
--- a/azure_c_shared_utility/gb_stdio.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/gb_stdio.h Mon May 09 14:37:45 2016 -0700 @@ -27,6 +27,7 @@ #define ftell ftell_never_called_never_implemented_always_forgotten #define fprintf fprintf_never_called_never_implemented_always_forgotten +#include "azure_c_shared_utility/umock_c_prod.h" #ifdef __cplusplus @@ -39,20 +40,20 @@ #undef fopen #define fopen gb_fopen -extern FILE* gb_fopen(const char* filename, const char* mode); +MOCKABLE_FUNCTION(, FILE*, gb_fopen, const char*, filename, const char*, mode); #undef fclose #define fclose gb_fclose -extern int fclose(FILE *stream); +MOCKABLE_FUNCTION(, int, fclose, FILE *, stream); #undef fseek #define fseek gb_fseek -extern int fseek(FILE *stream, long int offset, int whence); +MOCKABLE_FUNCTION(, int, fseek, FILE *,stream, long int, offset, int, whence); #undef ftell #define ftell gb_ftell -extern long int ftell(FILE *stream); +MOCKABLE_FUNCTION(, long int, ftell, FILE *, stream); #undef fprintf #define fprintf gb_fprintf
--- a/azure_c_shared_utility/gb_time.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/gb_time.h Mon May 09 14:37:45 2016 -0700 @@ -33,17 +33,19 @@ #include <time.h> #endif +#include "azure_c_shared_utility/umock_c_prod.h" + #undef time #define time gb_time -extern time_t time(time_t *timer); +MOCKABLE_FUNCTION(, time_t, time, time_t *, timer); #undef localtime #define localtime gb_localtime -extern struct tm *localtime(const time_t *timer); +MOCKABLE_FUNCTION(, struct tm *, localtime, const time_t *, timer); #undef strftime #define strftime gb_strftime -extern size_t strftime(char * s, size_t maxsize, const char * format, const struct tm * timeptr); +MOCKABLE_FUNCTION(, size_t, strftime, char *, s, size_t, maxsize, const char *, format, const struct tm *, timeptr); #ifdef __cplusplus
--- a/azure_c_shared_utility/gballoc.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/gballoc.h Mon May 09 14:37:45 2016 -0700 @@ -16,19 +16,21 @@ #include <crtdbg.h> #endif +#include "azure_c_shared_utility/umock_c_prod.h" + /* all translation units that need memory measurement need to have GB_MEASURE_MEMORY_FOR_THIS defined */ /* GB_DEBUG_ALLOC is the switch that turns the measurement on/off, so that it is not on always */ #if defined(GB_DEBUG_ALLOC) -extern int gballoc_init(void); -extern void gballoc_deinit(void); -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); +MOCKABLE_FUNCTION(, int, gballoc_init); +MOCKABLE_FUNCTION(, void, gballoc_deinit); +MOCKABLE_FUNCTION(, void*, gballoc_malloc, size_t, size); +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); -extern size_t gballoc_getMaximumMemoryUsed(void); -extern size_t gballoc_getCurrentMemoryUsed(void); +MOCKABLE_FUNCTION(, size_t, gballoc_getMaximumMemoryUsed); +MOCKABLE_FUNCTION(, size_t, gballoc_getCurrentMemoryUsed); /* 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
--- a/azure_c_shared_utility/hmac.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/hmac.h Mon May 09 14:37:45 2016 -0700 @@ -9,10 +9,11 @@ #endif #include "azure_c_shared_utility/sha.h" +#include "azure_c_shared_utility/umock_c_prod.h" -extern int hmac(SHAversion whichSha, const unsigned char *text, int text_len, - const unsigned char *key, int key_len, - uint8_t digest[USHAMaxHashSize]); + MOCKABLE_FUNCTION(, int, hmac, SHAversion, whichSha, const unsigned char *, text, int, text_len, + const unsigned char *, key, int, key_len, + uint8_t, digest[USHAMaxHashSize]); #ifdef __cplusplus }
--- a/azure_c_shared_utility/hmacsha256.h Sun Apr 24 16:41:14 2016 -0700
+++ b/azure_c_shared_utility/hmacsha256.h Mon May 09 14:37:45 2016 -0700
@@ -6,6 +6,7 @@
#include "azure_c_shared_utility/macro_utils.h"
#include "azure_c_shared_utility/buffer_.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
#ifdef __cplusplus
extern "C" {
@@ -18,7 +19,7 @@
DEFINE_ENUM(HMACSHA256_RESULT, HMACSHA256_RESULT_VALUES)
-extern HMACSHA256_RESULT HMACSHA256_ComputeHash(const unsigned char* key, size_t keyLen, const unsigned char* payload, size_t payloadLen, BUFFER_HANDLE hash);
+MOCKABLE_FUNCTION(, HMACSHA256_RESULT, HMACSHA256_ComputeHash, const unsigned char*, key, size_t, keyLen, const unsigned char*, payload, size_t, payloadLen, BUFFER_HANDLE, hash);
#ifdef __cplusplus
}
--- a/azure_c_shared_utility/httpapi.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/httpapi.h Mon May 09 14:37:45 2016 -0700 @@ -16,6 +16,7 @@ #include "azure_c_shared_utility/httpheaders.h" #include "azure_c_shared_utility/macro_utils.h" #include "azure_c_shared_utility/buffer_.h" +#include "azure_c_shared_utility/umock_c_prod.h" #ifdef __cplusplus #include <cstddef> @@ -74,10 +75,10 @@ * @return @c HTTPAPI_OK if initialization is successful or an error * code in case it fails. */ -extern HTTPAPI_RESULT HTTPAPI_Init(void); +MOCKABLE_FUNCTION(, HTTPAPI_RESULT, HTTPAPI_Init); /** @brief Free resources allocated in ::HTTPAPI_Init. */ -extern void HTTPAPI_Deinit(void); +MOCKABLE_FUNCTION(, void, HTTPAPI_Deinit); /** * @brief Creates an HTTPS connection to the host specified by the @p @@ -92,7 +93,7 @@ * @return A @c HTTP_HANDLE to the newly created connection or @c NULL in * case an error occurs. */ -extern HTTP_HANDLE HTTPAPI_CreateConnection(const char* hostName); +MOCKABLE_FUNCTION(, HTTP_HANDLE, HTTPAPI_CreateConnection, const char*, hostName); /** * @brief Closes a connection created with ::HTTPAPI_CreateConnection. @@ -102,7 +103,7 @@ * All resources allocated by ::HTTPAPI_CreateConnection should be * freed in ::HTTPAPI_CloseConnection. */ -extern void HTTPAPI_CloseConnection(HTTP_HANDLE handle); +MOCKABLE_FUNCTION(, void, HTTPAPI_CloseConnection, HTTP_HANDLE, handle); /** * @brief Sends the HTTP request to the host and handles the response for @@ -152,10 +153,10 @@ * @return @c HTTPAPI_OK if the API call is successful or an error * code in case it fails. */ -extern HTTPAPI_RESULT HTTPAPI_ExecuteRequest(HTTP_HANDLE handle, HTTPAPI_REQUEST_TYPE requestType, const char* relativePath, - HTTP_HEADERS_HANDLE httpHeadersHandle, const unsigned char* content, - size_t contentLength, unsigned int* statusCode, - HTTP_HEADERS_HANDLE responseHeadersHandle, BUFFER_HANDLE responseContent); +MOCKABLE_FUNCTION(, HTTPAPI_RESULT, HTTPAPI_ExecuteRequest, HTTP_HANDLE, handle, HTTPAPI_REQUEST_TYPE, requestType, const char*, relativePath, + HTTP_HEADERS_HANDLE, httpHeadersHandle, const unsigned char*, content, + size_t, contentLength, unsigned int*, statusCode, + HTTP_HEADERS_HANDLE, responseHeadersHandle, BUFFER_HANDLE, responseContent); /** * @brief Sets the option named @p optionName bearing the value @@ -170,7 +171,7 @@ * @return @c HTTPAPI_OK if initialization is successful or an error * code in case it fails. */ -extern HTTPAPI_RESULT HTTPAPI_SetOption(HTTP_HANDLE handle, const char* optionName, const void* value); +MOCKABLE_FUNCTION(, HTTPAPI_RESULT, HTTPAPI_SetOption, HTTP_HANDLE, handle, const char*, optionName, const void*, value); /** * @brief Clones the option named @p optionName bearing the value @p value @@ -185,7 +186,7 @@ * @return @c HTTPAPI_OK if initialization is successful or an error * code in case it fails. */ -extern HTTPAPI_RESULT HTTPAPI_CloneOption(const char* optionName, const void* value, const void** savedValue); +MOCKABLE_FUNCTION(, HTTPAPI_RESULT, HTTPAPI_CloneOption, const char*, optionName, const void*, value, const void**, savedValue); #ifdef __cplusplus }
--- a/azure_c_shared_utility/httpapiex.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/httpapiex.h Mon May 09 14:37:45 2016 -0700 @@ -18,6 +18,7 @@ #include "azure_c_shared_utility/macro_utils.h" #include "azure_c_shared_utility/httpapi.h" +#include "azure_c_shared_utility/umock_c_prod.h" #ifdef __cplusplus #include <cstddef> @@ -53,7 +54,7 @@ * * @return An @c HTTAPIEX_HANDLE suitable for further calls to the module. */ -extern HTTPAPIEX_HANDLE HTTPAPIEX_Create(const char* hostName); +MOCKABLE_FUNCTION(, HTTPAPIEX_HANDLE, HTTPAPIEX_Create, const char*, hostName); /** * @brief Tries to execute an HTTP request. @@ -78,14 +79,14 @@ * * @return An @c HTTAPIEX_HANDLE suitable for further calls to the module. */ -extern HTTPAPIEX_RESULT HTTPAPIEX_ExecuteRequest(HTTPAPIEX_HANDLE handle, HTTPAPI_REQUEST_TYPE requestType, const char* relativePath, HTTP_HEADERS_HANDLE requestHttpHeadersHandle, BUFFER_HANDLE requestContent, unsigned int* statusCode, HTTP_HEADERS_HANDLE responseHttpHeadersHandle, BUFFER_HANDLE responseContent); +MOCKABLE_FUNCTION(, HTTPAPIEX_RESULT, HTTPAPIEX_ExecuteRequest, HTTPAPIEX_HANDLE, handle, HTTPAPI_REQUEST_TYPE, requestType, const char*, relativePath, HTTP_HEADERS_HANDLE, requestHttpHeadersHandle, BUFFER_HANDLE, requestContent, unsigned int*, statusCode, HTTP_HEADERS_HANDLE, responseHttpHeadersHandle, BUFFER_HANDLE, responseContent); /** * @brief Frees all resources used by the @c HTTPAPIEX_HANDLE object. * * @param handle The @c HTTPAPIEX_HANDLE object to be freed. */ -extern void HTTPAPIEX_Destroy(HTTPAPIEX_HANDLE handle); +MOCKABLE_FUNCTION(, void, HTTPAPIEX_Destroy, HTTPAPIEX_HANDLE, handle); /** * @brief Sets the option @p optionName to the value pointed to by @p value. @@ -96,7 +97,7 @@ * * @return An @c HTTPAPIEX_RESULT indicating the status of the call. */ -extern HTTPAPIEX_RESULT HTTPAPIEX_SetOption(HTTPAPIEX_HANDLE handle, const char* optionName, const void* value); +MOCKABLE_FUNCTION(, HTTPAPIEX_RESULT, HTTPAPIEX_SetOption, HTTPAPIEX_HANDLE, handle, const char*, optionName, const void*, value); #ifdef __cplusplus }
--- a/azure_c_shared_utility/httpapiexsas.h Sun Apr 24 16:41:14 2016 -0700
+++ b/azure_c_shared_utility/httpapiexsas.h Mon May 09 14:37:45 2016 -0700
@@ -8,6 +8,7 @@
#include "azure_c_shared_utility/buffer_.h"
#include "azure_c_shared_utility/httpheaders.h"
#include "azure_c_shared_utility/httpapiex.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
#ifdef __cplusplus
extern "C" {
@@ -16,11 +17,11 @@
typedef struct HTTPAPIEX_SAS_STATE_TAG* HTTPAPIEX_SAS_HANDLE;
-extern HTTPAPIEX_SAS_HANDLE HTTPAPIEX_SAS_Create(STRING_HANDLE key, STRING_HANDLE uriResource, STRING_HANDLE keyName);
+MOCKABLE_FUNCTION(, HTTPAPIEX_SAS_HANDLE, HTTPAPIEX_SAS_Create, STRING_HANDLE, key, STRING_HANDLE, uriResource, STRING_HANDLE, keyName);
-extern void HTTPAPIEX_SAS_Destroy(HTTPAPIEX_SAS_HANDLE handle);
+MOCKABLE_FUNCTION(, void, HTTPAPIEX_SAS_Destroy, HTTPAPIEX_SAS_HANDLE, handle);
-extern HTTPAPIEX_RESULT HTTPAPIEX_SAS_ExecuteRequest(HTTPAPIEX_SAS_HANDLE sasHandle, HTTPAPIEX_HANDLE handle, HTTPAPI_REQUEST_TYPE requestType, const char* relativePath, HTTP_HEADERS_HANDLE requestHttpHeadersHandle, BUFFER_HANDLE requestContent, unsigned int* statusCode, HTTP_HEADERS_HANDLE responseHeadersHandle, BUFFER_HANDLE responseContent);
+MOCKABLE_FUNCTION(, HTTPAPIEX_RESULT, HTTPAPIEX_SAS_ExecuteRequest, HTTPAPIEX_SAS_HANDLE, sasHandle, HTTPAPIEX_HANDLE, handle, HTTPAPI_REQUEST_TYPE, requestType, const char*, relativePath, HTTP_HEADERS_HANDLE, requestHttpHeadersHandle, BUFFER_HANDLE, requestContent, unsigned int*, statusCode, HTTP_HEADERS_HANDLE, responseHeadersHandle, BUFFER_HANDLE, responseContent);
#ifdef __cplusplus
}
--- a/azure_c_shared_utility/httpheaders.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/httpheaders.h Mon May 09 14:37:45 2016 -0700 @@ -21,6 +21,7 @@ #define HTTPHEADERS_H #include "azure_c_shared_utility/macro_utils.h" +#include "azure_c_shared_utility/umock_c_prod.h" #ifdef __cplusplus #include <cstddef> @@ -51,14 +52,14 @@ * * @return A HTTP_HEADERS_HANDLE representing the newly created collection of HTTP headers. */ -extern HTTP_HEADERS_HANDLE HTTPHeaders_Alloc(void); +MOCKABLE_FUNCTION(, HTTP_HEADERS_HANDLE, HTTPHeaders_Alloc); /** * @brief De-allocates the data structures allocated by previous API calls to the same handle. * * @param httpHeadersHandle A valid @c HTTP_HEADERS_HANDLE value. */ -extern void HTTPHeaders_Free(HTTP_HEADERS_HANDLE httpHeadersHandle); +MOCKABLE_FUNCTION(, void, HTTPHeaders_Free, HTTP_HEADERS_HANDLE, httpHeadersHandle); /** * @brief Adds a header record from the @p name and @p value parameters. @@ -79,7 +80,7 @@ * @return Returns @c HTTP_HEADERS_OK when execution is successful or an error code from * the ::HTTPAPIEX_RESULT enum. */ -extern HTTP_HEADERS_RESULT HTTPHeaders_AddHeaderNameValuePair(HTTP_HEADERS_HANDLE httpHeadersHandle, const char* name, const char* value); +MOCKABLE_FUNCTION(, HTTP_HEADERS_RESULT, HTTPHeaders_AddHeaderNameValuePair, HTTP_HEADERS_HANDLE, httpHeadersHandle, const char*, name, const char*, value); /** * @brief This API performs exactly the same as ::HTTPHeaders_AddHeaderNameValuePair @@ -95,7 +96,7 @@ * @return Returns @c HTTP_HEADERS_OK when execution is successful or an error code from * the ::HTTPAPIEX_RESULT enum. */ -extern HTTP_HEADERS_RESULT HTTPHeaders_ReplaceHeaderNameValuePair(HTTP_HEADERS_HANDLE httpHeadersHandle, const char* name, const char* value); +MOCKABLE_FUNCTION(, HTTP_HEADERS_RESULT, HTTPHeaders_ReplaceHeaderNameValuePair, HTTP_HEADERS_HANDLE, httpHeadersHandle, const char*, name, const char*, value); /** * @brief Retrieves the value for a previously stored name. @@ -106,7 +107,7 @@ * @return The return value points to a string that shall be @c strcmp equal * to the original stored string. */ -extern const char* HTTPHeaders_FindHeaderValue(HTTP_HEADERS_HANDLE httpHeadersHandle, const char* name); +MOCKABLE_FUNCTION(, const char*, HTTPHeaders_FindHeaderValue, HTTP_HEADERS_HANDLE, httpHeadersHandle, const char*, name); /** * @brief This API retrieves the number of stored headers. @@ -118,7 +119,7 @@ * @return Returns @c HTTP_HEADERS_OK when execution is successful or * @c HTTP_HEADERS_ERROR when an error occurs. */ -extern HTTP_HEADERS_RESULT HTTPHeaders_GetHeaderCount(HTTP_HEADERS_HANDLE httpHeadersHandle, size_t* headersCount); +MOCKABLE_FUNCTION(, HTTP_HEADERS_RESULT, HTTPHeaders_GetHeaderCount, HTTP_HEADERS_HANDLE, httpHeadersHandle, size_t*, headersCount); /** * @brief This API retrieves the string name+": "+value for the header @@ -135,7 +136,7 @@ * @return Returns @c HTTP_HEADERS_OK when execution is successful or * @c HTTP_HEADERS_ERROR when an error occurs. */ -extern HTTP_HEADERS_RESULT HTTPHeaders_GetHeader(HTTP_HEADERS_HANDLE handle, size_t index, char** destination); +MOCKABLE_FUNCTION(, HTTP_HEADERS_RESULT, HTTPHeaders_GetHeader, HTTP_HEADERS_HANDLE, handle, size_t, index, char**, destination); /** * @brief This API produces a clone of the @p handle parameter. @@ -148,7 +149,7 @@ * @return A @c HTTP_HEADERS_HANDLE containing a cloned copy of the * contents of @p handle. */ -extern HTTP_HEADERS_HANDLE HTTPHeaders_Clone(HTTP_HEADERS_HANDLE handle); +MOCKABLE_FUNCTION(, HTTP_HEADERS_HANDLE, HTTPHeaders_Clone, HTTP_HEADERS_HANDLE, handle); #ifdef __cplusplus }
--- a/azure_c_shared_utility/list.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/list.h Mon May 09 14:37:45 2016 -0700 @@ -11,19 +11,20 @@ #include "stdbool.h" #endif /* __cplusplus */ +#include "azure_c_shared_utility/umock_c_prod.h" + typedef struct LIST_INSTANCE_TAG* LIST_HANDLE; typedef struct LIST_ITEM_INSTANCE_TAG* LIST_ITEM_HANDLE; typedef bool (*LIST_MATCH_FUNCTION)(LIST_ITEM_HANDLE list_item, const void* match_context); -extern LIST_HANDLE list_create(void); -extern void list_destroy(LIST_HANDLE list); -extern LIST_ITEM_HANDLE list_add(LIST_HANDLE list, const void* item); -extern int list_remove(LIST_HANDLE list, LIST_ITEM_HANDLE item_handle); -extern LIST_ITEM_HANDLE list_get_head_item(LIST_HANDLE list); -extern LIST_ITEM_HANDLE list_get_next_item(LIST_ITEM_HANDLE item_handle); -extern LIST_ITEM_HANDLE list_find(LIST_HANDLE list, LIST_MATCH_FUNCTION match_function, const void* match_context); - -extern const void* list_item_get_value(LIST_ITEM_HANDLE item_handle); +MOCKABLE_FUNCTION(, LIST_HANDLE, list_create); +MOCKABLE_FUNCTION(, void, list_destroy, LIST_HANDLE, list); +MOCKABLE_FUNCTION(, LIST_ITEM_HANDLE, list_add, LIST_HANDLE, list, const void*, item); +MOCKABLE_FUNCTION(, int, list_remove, LIST_HANDLE, list, LIST_ITEM_HANDLE, item_handle); +MOCKABLE_FUNCTION(, LIST_ITEM_HANDLE, list_get_head_item, LIST_HANDLE, list); +MOCKABLE_FUNCTION(, LIST_ITEM_HANDLE, list_get_next_item, LIST_ITEM_HANDLE, item_handle); +MOCKABLE_FUNCTION(, LIST_ITEM_HANDLE, list_find, LIST_HANDLE, list, LIST_MATCH_FUNCTION, match_function, const void*, match_context); +MOCKABLE_FUNCTION(, const void*, list_item_get_value, LIST_ITEM_HANDLE, item_handle); #ifdef __cplusplus }
--- a/azure_c_shared_utility/lock.h Sun Apr 24 16:41:14 2016 -0700
+++ b/azure_c_shared_utility/lock.h Mon May 09 14:37:45 2016 -0700
@@ -15,6 +15,7 @@
#define LOCK_H
#include "azure_c_shared_utility/macro_utils.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
#ifdef __cplusplus
extern "C" {
@@ -35,7 +36,7 @@
*
* @return A valid @c LOCK_HANDLE when successful or @c NULL otherwise.
*/
-extern LOCK_HANDLE Lock_Init(void);
+MOCKABLE_FUNCTION(, LOCK_HANDLE, Lock_Init);
/**
* @brief Acquires a lock on the given lock handle. Uses platform
@@ -46,7 +47,7 @@
* @return Returns @c LOCK_OK when a lock has been acquired and
* @c LOCK_ERROR when an error occurs.
*/
-extern LOCK_RESULT Lock(LOCK_HANDLE handle);
+MOCKABLE_FUNCTION(, LOCK_RESULT, Lock, LOCK_HANDLE, handle);
/**
* @brief Releases the lock on the given lock handle. Uses platform
@@ -57,7 +58,7 @@
* @return Returns @c LOCK_OK when the lock has been released and
* @c LOCK_ERROR when an error occurs.
*/
-extern LOCK_RESULT Unlock(LOCK_HANDLE handle);
+MOCKABLE_FUNCTION(, LOCK_RESULT, Unlock, LOCK_HANDLE, handle);
/**
* @brief The lock instance is destroyed.
@@ -67,7 +68,7 @@
* @return Returns @c LOCK_OK when the lock object has been
* destroyed and @c LOCK_ERROR when an error occurs.
*/
-extern LOCK_RESULT Lock_Deinit(LOCK_HANDLE handle);
+MOCKABLE_FUNCTION(, LOCK_RESULT, Lock_Deinit, LOCK_HANDLE, handle);
#ifdef __cplusplus
}
--- a/azure_c_shared_utility/map.h Sun Apr 24 16:41:14 2016 -0700
+++ b/azure_c_shared_utility/map.h Mon May 09 14:37:45 2016 -0700
@@ -21,6 +21,7 @@
#include "azure_c_shared_utility/macro_utils.h"
#include "azure_c_shared_utility/strings.h"
#include "azure_c_shared_utility/crt_abstractions.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
#define MAP_RESULT_VALUES \
MAP_OK, \
@@ -53,14 +54,14 @@
*
* @return A valid @c MAP_HANDLE or @c NULL in case an error occurs.
*/
-extern MAP_HANDLE Map_Create(MAP_FILTER_CALLBACK mapFilterFunc);
+MOCKABLE_FUNCTION(, MAP_HANDLE, Map_Create, MAP_FILTER_CALLBACK, mapFilterFunc);
/**
* @brief Release all resources associated with the map.
*
* @param handle The handle to an existing map.
*/
-extern void Map_Destroy(MAP_HANDLE handle);
+MOCKABLE_FUNCTION(, void, Map_Destroy, MAP_HANDLE, handle);
/**
* @brief Creates a copy of the map indicated by @p handle and returns a
@@ -71,7 +72,7 @@
* @return A valid @c MAP_HANDLE to the cloned copy of the map or @c NULL
* in case an error occurs.
*/
-extern MAP_HANDLE Map_Clone(MAP_HANDLE handle);
+MOCKABLE_FUNCTION(, MAP_HANDLE, Map_Clone, MAP_HANDLE, handle);
/**
* @brief Adds a key/value pair to the map.
@@ -95,7 +96,7 @@
* the new key is added to the map the function returns @c MAP_ERROR.
* If everything goes well then @c MAP_OK is returned.
*/
-extern MAP_RESULT Map_Add(MAP_HANDLE handle, const char* key, const char* value);
+MOCKABLE_FUNCTION(, MAP_RESULT, Map_Add, MAP_HANDLE, handle, const char*, key, const char*, value);
/**
* @brief Adds/updates a key/value pair to the map.
@@ -120,7 +121,7 @@
* added/updated in the map the function returns @c MAP_ERROR. If
* everything goes well then @c MAP_OK is returned.
*/
-extern MAP_RESULT Map_AddOrUpdate(MAP_HANDLE handle, const char* key, const char* value);
+MOCKABLE_FUNCTION(, MAP_RESULT, Map_AddOrUpdate, MAP_HANDLE, handle, const char*, key, const char*, value);
/**
* @brief Removes a key and its associated value from the map.
@@ -131,7 +132,7 @@
* @return Returns @c MAP_OK if the key was deleted successfully or an
* error code otherwise.
*/
-extern MAP_RESULT Map_Delete(MAP_HANDLE handle, const char* key);
+MOCKABLE_FUNCTION(, MAP_RESULT, Map_Delete, MAP_HANDLE, handle, const char*, key);
/**
* @brief This function returns a boolean value in @p keyExists if the map
@@ -146,7 +147,7 @@
* @return Returns @c MAP_OK if the check was performed successfully or an
* error code otherwise.
*/
-extern MAP_RESULT Map_ContainsKey(MAP_HANDLE handle, const char* key, bool* keyExists);
+MOCKABLE_FUNCTION(, MAP_RESULT, Map_ContainsKey, MAP_HANDLE, handle, const char*, key, bool*, keyExists);
/**
* @brief This function returns @c true in @p valueExists if at
@@ -162,7 +163,7 @@
* @return Returns @c MAP_OK if the check was performed successfully or an
* error code otherwise.
*/
-extern MAP_RESULT Map_ContainsValue(MAP_HANDLE handle, const char* value, bool* valueExists);
+MOCKABLE_FUNCTION(, MAP_RESULT, Map_ContainsValue, MAP_HANDLE, handle, const char*, value, bool*, valueExists);
/**
* @brief Retrieves the value of a stored key.
@@ -174,7 +175,7 @@
* requested key is not found in the map. Returns a pointer to the
* key's value otherwise.
*/
-extern const char* Map_GetValueFromKey(MAP_HANDLE handle, const char* key);
+MOCKABLE_FUNCTION(, const char*, Map_GetValueFromKey, MAP_HANDLE, handle, const char*, key);
/**
* @brief Retrieves the complete list of keys and values from the map
@@ -190,10 +191,10 @@
* @return Returns @c MAP_OK if the keys and values are retrieved and written
* successfully or an error code otherwise.
*/
-extern MAP_RESULT Map_GetInternals(MAP_HANDLE handle, const char*const** keys, const char*const** values, size_t* count);
+MOCKABLE_FUNCTION(, MAP_RESULT, Map_GetInternals, MAP_HANDLE, handle, const char*const**, keys, const char*const**, values, size_t*, count);
/*this API creates a JSON object from the content of the map*/
-extern STRING_HANDLE Map_ToJSON(MAP_HANDLE handle);
+MOCKABLE_FUNCTION(, STRING_HANDLE, Map_ToJSON, MAP_HANDLE, handle);
#ifdef __cplusplus
}
--- a/azure_c_shared_utility/platform.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/platform.h Mon May 09 14:37:45 2016 -0700 @@ -9,10 +9,11 @@ #endif /* __cplusplus */ #include "azure_c_shared_utility/xio.h" +#include "azure_c_shared_utility/umock_c_prod.h" - extern int platform_init(void); - extern void platform_deinit(void); - extern const IO_INTERFACE_DESCRIPTION* platform_get_default_tlsio(void); + MOCKABLE_FUNCTION(, int, platform_init); + MOCKABLE_FUNCTION(, void, platform_deinit); + MOCKABLE_FUNCTION(, const IO_INTERFACE_DESCRIPTION*, platform_get_default_tlsio); #ifdef __cplusplus }
--- a/azure_c_shared_utility/sastoken.h Sun Apr 24 16:41:14 2016 -0700
+++ b/azure_c_shared_utility/sastoken.h Mon May 09 14:37:45 2016 -0700
@@ -5,12 +5,13 @@
#define SASTOKEN_H
#include "azure_c_shared_utility/strings.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
#ifdef __cplusplus
extern "C" {
#endif
-extern STRING_HANDLE SASToken_Create(STRING_HANDLE key, STRING_HANDLE scope, STRING_HANDLE keyName, size_t expiry);
+ MOCKABLE_FUNCTION(, STRING_HANDLE, SASToken_Create, STRING_HANDLE, key, STRING_HANDLE, scope, STRING_HANDLE, keyName, size_t, expiry);
#ifdef __cplusplus
}
--- a/azure_c_shared_utility/socketio.h Sun Apr 24 16:41:14 2016 -0700
+++ b/azure_c_shared_utility/socketio.h Mon May 09 14:37:45 2016 -0700
@@ -13,6 +13,7 @@
#include "azure_c_shared_utility/xio.h"
#include "azure_c_shared_utility/xlogging.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
typedef struct SOCKETIO_CONFIG_TAG
{
@@ -23,15 +24,15 @@
#define RECEIVE_BYTES_VALUE 64
-extern CONCRETE_IO_HANDLE socketio_create(void* io_create_parameters, LOGGER_LOG logger_log);
-extern void socketio_destroy(CONCRETE_IO_HANDLE socket_io);
-extern int socketio_open(CONCRETE_IO_HANDLE socket_io, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_io_open_complete_context, ON_BYTES_RECEIVED on_bytes_received, void* on_bytes_received_context, ON_IO_ERROR on_io_error, void* on_io_error_context);
-extern int socketio_close(CONCRETE_IO_HANDLE socket_io, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* callback_context);
-extern int socketio_send(CONCRETE_IO_HANDLE socket_io, const void* buffer, size_t size, ON_SEND_COMPLETE on_send_complete, void* callback_context);
-extern void socketio_dowork(CONCRETE_IO_HANDLE socket_io);
-extern int socketio_setoption(CONCRETE_IO_HANDLE socket_io, const char* optionName, const void* value);
+MOCKABLE_FUNCTION(, CONCRETE_IO_HANDLE, socketio_create, void*, io_create_parameters, LOGGER_LOG, logger_log);
+MOCKABLE_FUNCTION(, void, socketio_destroy, CONCRETE_IO_HANDLE, socket_io);
+MOCKABLE_FUNCTION(, int, socketio_open, CONCRETE_IO_HANDLE, socket_io, ON_IO_OPEN_COMPLETE, on_io_open_complete, void*, on_io_open_complete_context, ON_BYTES_RECEIVED, on_bytes_received, void*, on_bytes_received_context, ON_IO_ERROR, on_io_error, void*, on_io_error_context);
+MOCKABLE_FUNCTION(, int, socketio_close, CONCRETE_IO_HANDLE, socket_io, ON_IO_CLOSE_COMPLETE, on_io_close_complete, void*, callback_context);
+MOCKABLE_FUNCTION(, int, socketio_send, CONCRETE_IO_HANDLE, socket_io, const void*, buffer, size_t, size, ON_SEND_COMPLETE, on_send_complete, void*, callback_context);
+MOCKABLE_FUNCTION(, void, socketio_dowork, CONCRETE_IO_HANDLE, socket_io);
+MOCKABLE_FUNCTION(, int, socketio_setoption, CONCRETE_IO_HANDLE, socket_io, const char*, optionName, const void*, value);
-extern const IO_INTERFACE_DESCRIPTION* socketio_get_interface_description(void);
+MOCKABLE_FUNCTION(, const IO_INTERFACE_DESCRIPTION*, socketio_get_interface_description);
#ifdef __cplusplus
}
--- a/azure_c_shared_utility/string_tokenizer.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/string_tokenizer.h Mon May 09 14:37:45 2016 -0700 @@ -5,6 +5,7 @@ #define STRING_TOKENIZER_H #include "azure_c_shared_utility/strings.h" +#include "azure_c_shared_utility/umock_c_prod.h" #ifdef __cplusplus extern "C" @@ -14,10 +15,10 @@ typedef struct STRING_TOKEN_TAG* STRING_TOKENIZER_HANDLE; -extern STRING_TOKENIZER_HANDLE STRING_TOKENIZER_create(STRING_HANDLE handle); -extern STRING_TOKENIZER_HANDLE STRING_TOKENIZER_create_from_char(const char* input); -extern int STRING_TOKENIZER_get_next_token(STRING_TOKENIZER_HANDLE t, STRING_HANDLE output, const char* delimiters); -extern void STRING_TOKENIZER_destroy(STRING_TOKENIZER_HANDLE t); +MOCKABLE_FUNCTION(, STRING_TOKENIZER_HANDLE, STRING_TOKENIZER_create, STRING_HANDLE, handle); +MOCKABLE_FUNCTION(, STRING_TOKENIZER_HANDLE, STRING_TOKENIZER_create_from_char, const char*, input); +MOCKABLE_FUNCTION(, int, STRING_TOKENIZER_get_next_token, STRING_TOKENIZER_HANDLE, t, STRING_HANDLE, output, const char*, delimiters); +MOCKABLE_FUNCTION(, void, STRING_TOKENIZER_destroy, STRING_TOKENIZER_HANDLE, t); #ifdef __cplusplus }
--- a/azure_c_shared_utility/strings.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/strings.h Mon May 09 14:37:45 2016 -0700 @@ -12,25 +12,27 @@ #include <stddef.h> #endif +#include "azure_c_shared_utility/umock_c_prod.h" + typedef struct STRING_TAG* STRING_HANDLE; -extern STRING_HANDLE STRING_new(void); -extern STRING_HANDLE STRING_clone(STRING_HANDLE handle); -extern STRING_HANDLE STRING_construct(const char* psz); -extern STRING_HANDLE STRING_construct_n(const char* psz, size_t n); -extern STRING_HANDLE STRING_new_with_memory(const char* memory); -extern STRING_HANDLE STRING_new_quoted(const char* source); -extern STRING_HANDLE STRING_new_JSON(const char* source); -extern void STRING_delete(STRING_HANDLE handle); -extern int STRING_concat(STRING_HANDLE handle, const char* s2); -extern int STRING_concat_with_STRING(STRING_HANDLE s1, STRING_HANDLE s2); -extern int STRING_quote(STRING_HANDLE handle); -extern int STRING_copy(STRING_HANDLE s1, const char* s2); -extern int STRING_copy_n(STRING_HANDLE s1, const char* s2, size_t n); -extern const char* STRING_c_str(STRING_HANDLE handle); -extern int STRING_empty(STRING_HANDLE handle); -extern size_t STRING_length(STRING_HANDLE handle); -extern int STRING_compare(STRING_HANDLE s1, STRING_HANDLE s2); +MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_new); +MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_clone, STRING_HANDLE, handle); +MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_construct, const char*, psz); +MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_construct_n, const char*, psz, size_t, n); +MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_new_with_memory, const char*, memory); +MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_new_quoted, const char*, source); +MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_new_JSON, const char*, source); +MOCKABLE_FUNCTION(, void, STRING_delete, STRING_HANDLE, handle); +MOCKABLE_FUNCTION(, int, STRING_concat, STRING_HANDLE, handle, const char*, s2); +MOCKABLE_FUNCTION(, int, STRING_concat_with_STRING, STRING_HANDLE, s1, STRING_HANDLE, s2); +MOCKABLE_FUNCTION(, int, STRING_quote, STRING_HANDLE, handle); +MOCKABLE_FUNCTION(, int, STRING_copy, STRING_HANDLE, s1, const char*, s2); +MOCKABLE_FUNCTION(, int, STRING_copy_n, STRING_HANDLE, s1, const char*, s2, size_t, n); +MOCKABLE_FUNCTION(, const char*, STRING_c_str, STRING_HANDLE, handle); +MOCKABLE_FUNCTION(, int, STRING_empty, STRING_HANDLE, handle); +MOCKABLE_FUNCTION(, size_t, STRING_length, STRING_HANDLE, handle); +MOCKABLE_FUNCTION(, int, STRING_compare, STRING_HANDLE, s1, STRING_HANDLE, s2); #ifdef __cplusplus
--- a/azure_c_shared_utility/threadapi.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/threadapi.h Mon May 09 14:37:45 2016 -0700 @@ -14,7 +14,8 @@ #endif #include "azure_c_shared_utility/macro_utils.h" - +#include "azure_c_shared_utility/umock_c_prod.h" + typedef int(*THREAD_START_FUNC)(void *); #define THREADAPI_RESULT_VALUES \ @@ -44,7 +45,7 @@ * @return @c THREADAPI_OK if the API call is successful or an error * code in case it fails. */ -extern THREADAPI_RESULT ThreadAPI_Create(THREAD_HANDLE* threadHandle, THREAD_START_FUNC func, void* arg); +MOCKABLE_FUNCTION(, THREADAPI_RESULT, ThreadAPI_Create, THREAD_HANDLE*, threadHandle, THREAD_START_FUNC, func, void*, arg); /** * @brief Blocks the calling thread by waiting on the thread identified by @@ -61,7 +62,7 @@ * @return @c THREADAPI_OK if the API call is successful or an error * code in case it fails. */ -extern THREADAPI_RESULT ThreadAPI_Join(THREAD_HANDLE threadHandle, int* res); +MOCKABLE_FUNCTION(, THREADAPI_RESULT, ThreadAPI_Join, THREAD_HANDLE, threadHandle, int*, res); /** * @brief This function is called by a thread when the thread exits. @@ -73,14 +74,14 @@ * function. The @p res value must be copied into the @p res out * argument passed to the ::ThreadAPI_Join function. */ -extern void ThreadAPI_Exit(int res); +MOCKABLE_FUNCTION(, void, ThreadAPI_Exit, int, res); /** * @brief Sleeps the current thread for the given number of milliseconds. * * @param milliseconds The number of milliseconds to sleep. */ -extern void ThreadAPI_Sleep(unsigned int milliseconds); +MOCKABLE_FUNCTION(, void, ThreadAPI_Sleep, unsigned int, milliseconds); #ifdef __cplusplus }
--- a/azure_c_shared_utility/tickcounter.h Sun Apr 24 16:41:14 2016 -0700 +++ b/azure_c_shared_utility/tickcounter.h Mon May 09 14:37:45 2016 -0700 @@ -11,11 +11,13 @@ #include <stdint.h> #endif /* __cplusplus */ +#include "azure_c_shared_utility/umock_c_prod.h" + typedef struct TICK_COUNTER_INSTANCE_TAG* TICK_COUNTER_HANDLE; - extern TICK_COUNTER_HANDLE tickcounter_create(void); - extern void tickcounter_destroy(TICK_COUNTER_HANDLE tick_counter); - extern int tickcounter_get_current_ms(TICK_COUNTER_HANDLE tick_counter, uint64_t* current_ms); + MOCKABLE_FUNCTION(, TICK_COUNTER_HANDLE, tickcounter_create); + MOCKABLE_FUNCTION(, void, tickcounter_destroy, TICK_COUNTER_HANDLE, tick_counter); + MOCKABLE_FUNCTION(, int, tickcounter_get_current_ms, TICK_COUNTER_HANDLE, tick_counter, uint64_t*, current_ms); #ifdef __cplusplus }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/azure_c_shared_utility/umock_c_prod.h Mon May 09 14:37:45 2016 -0700 @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#undef MOCKABLE_FUNCTION + +/* This header is meant to be included by production code headers, so that the MOCKABLE_FUNCTION gets enabled. */ +/* + If you are porting to a new platform and do not want to build the tests, but only the production code, + simply make sure that this file is in the include path (either by copying it to your inc folder or + by adjusting the include paths). +*/ + +#ifdef ENABLE_MOCKS + +/* Codes_SRS_UMOCK_C_LIB_01_001: [MOCKABLE_FUNCTION shall be used to wrap function definition allowing the user to declare a function that can be mocked.]*/ +#define MOCKABLE_FUNCTION(modifiers, result, function, ...) \ + MOCKABLE_FUNCTION_UMOCK_INTERNAL_WITH_MOCK(modifiers, result, function, __VA_ARGS__) + +#include "umock_c.h" + +#else + +#include "azure_c_shared_utility/macro_utils.h" + +#define UMOCK_C_PROD_ARG_IN_SIGNATURE(count, arg_type, arg_name) arg_type arg_name IFCOMMA(count) + +/* Codes_SRS_UMOCK_C_LIB_01_002: [The macro shall generate a function signature in case ENABLE_MOCKS is not defined.] */ +/* Codes_SRS_UMOCK_C_LIB_01_005: [**If ENABLE_MOCKS is not defined, MOCKABLE_FUNCTION shall only generate a declaration for the function.] */ +/* Codes_SRS_UMOCK_C_LIB_01_001: [MOCKABLE_FUNCTION shall be used to wrap function definition allowing the user to declare a function that can be mocked.]*/ +#define MOCKABLE_FUNCTION(modifiers, result, function, ...) \ + result modifiers function(IF(COUNT_ARG(__VA_ARGS__),,void) FOR_EACH_2_COUNTED(UMOCK_C_PROD_ARG_IN_SIGNATURE, __VA_ARGS__)); + +#endif
--- a/azure_c_shared_utility/uniqueid.h Sun Apr 24 16:41:14 2016 -0700
+++ b/azure_c_shared_utility/uniqueid.h Mon May 09 14:37:45 2016 -0700
@@ -13,6 +13,8 @@
#include <stddef.h>
#endif
+#include "azure_c_shared_utility/umock_c_prod.h"
+
#define UNIQUEID_RESULT_VALUES \
UNIQUEID_OK, \
UNIQUEID_INVALID_ARG, \
@@ -20,7 +22,7 @@
DEFINE_ENUM(UNIQUEID_RESULT, UNIQUEID_RESULT_VALUES)
- extern UNIQUEID_RESULT UniqueId_Generate(char* uid, size_t bufferSize);
+ MOCKABLE_FUNCTION(, UNIQUEID_RESULT, UniqueId_Generate, char*, uid, size_t, bufferSize);
#ifdef __cplusplus
}
--- a/azure_c_shared_utility/urlencode.h Sun Apr 24 16:41:14 2016 -0700
+++ b/azure_c_shared_utility/urlencode.h Mon May 09 14:37:45 2016 -0700
@@ -6,12 +6,14 @@
#include "azure_c_shared_utility/strings.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
+
#ifdef __cplusplus
extern "C" {
#endif
-extern STRING_HANDLE URL_EncodeString(const char* textEncode);
-extern STRING_HANDLE URL_Encode(STRING_HANDLE input);
+ MOCKABLE_FUNCTION(, STRING_HANDLE, URL_EncodeString, const char*, textEncode);
+ MOCKABLE_FUNCTION(, STRING_HANDLE, URL_Encode, STRING_HANDLE, input);
#ifdef __cplusplus
}
--- a/azure_c_shared_utility/vector.h Sun Apr 24 16:41:14 2016 -0700
+++ b/azure_c_shared_utility/vector.h Mon May 09 14:37:45 2016 -0700
@@ -5,13 +5,16 @@
#define VECTOR_H
#include "azure_c_shared_utility/crt_abstractions.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
#ifdef __cplusplus
#include <cstddef>
+#include <cstdbool>
extern "C"
{
#else
#include <stddef.h>
+#include <stdbool.h>
#endif
typedef struct VECTOR_TAG* VECTOR_HANDLE;
@@ -19,24 +22,24 @@
typedef bool(*PREDICATE_FUNCTION)(const void* element, const void* value);
/* creation */
-extern VECTOR_HANDLE VECTOR_create(size_t elementSize);
-extern void VECTOR_destroy(VECTOR_HANDLE handle);
+MOCKABLE_FUNCTION(, VECTOR_HANDLE, VECTOR_create, size_t, elementSize);
+MOCKABLE_FUNCTION(, void, VECTOR_destroy, VECTOR_HANDLE, handle);
/* insertion */
-extern int VECTOR_push_back(VECTOR_HANDLE handle, const void* elements, size_t numElements);
+MOCKABLE_FUNCTION(, int, VECTOR_push_back, VECTOR_HANDLE, handle, const void*, elements, size_t, numElements);
/* removal */
-extern void VECTOR_erase(VECTOR_HANDLE handle, void* elements, size_t numElements);
-extern void VECTOR_clear(VECTOR_HANDLE handle);
+MOCKABLE_FUNCTION(, void, VECTOR_erase, VECTOR_HANDLE, handle, void*, elements, size_t, numElements);
+MOCKABLE_FUNCTION(, void, VECTOR_clear, VECTOR_HANDLE, handle);
/* access */
-extern void* VECTOR_element(const VECTOR_HANDLE handle, size_t index);
-extern void* VECTOR_front(const VECTOR_HANDLE handle);
-extern void* VECTOR_back(const VECTOR_HANDLE handle);
-extern void* VECTOR_find_if(const VECTOR_HANDLE handle, PREDICATE_FUNCTION pred, const void* value);
+MOCKABLE_FUNCTION(, void*, VECTOR_element, const VECTOR_HANDLE, handle, size_t, index);
+MOCKABLE_FUNCTION(, void*, VECTOR_front, const VECTOR_HANDLE, handle);
+MOCKABLE_FUNCTION(, void*, VECTOR_back, const VECTOR_HANDLE, handle);
+MOCKABLE_FUNCTION(, void*, VECTOR_find_if, const VECTOR_HANDLE, handle, PREDICATE_FUNCTION, pred, const void*, value);
/* capacity */
-extern size_t VECTOR_size(const VECTOR_HANDLE handle);
+MOCKABLE_FUNCTION(, size_t, VECTOR_size, const VECTOR_HANDLE, handle);
#ifdef __cplusplus
}
--- a/azure_c_shared_utility/xio.h Sun Apr 24 16:41:14 2016 -0700
+++ b/azure_c_shared_utility/xio.h Mon May 09 14:37:45 2016 -0700
@@ -5,6 +5,7 @@
#define XIO_H
#include "azure_c_shared_utility/xlogging.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
#ifdef __cplusplus
#include <cstddef>
@@ -55,13 +56,13 @@
IO_SETOPTION concrete_io_setoption;
} IO_INTERFACE_DESCRIPTION;
-extern XIO_HANDLE xio_create(const IO_INTERFACE_DESCRIPTION* io_interface_description, const void* io_create_parameters, LOGGER_LOG logger_log);
-extern void xio_destroy(XIO_HANDLE xio);
-extern int xio_open(XIO_HANDLE xio, ON_IO_OPEN_COMPLETE on_io_open_complete, void* on_io_open_complete_context, ON_BYTES_RECEIVED on_bytes_received, void* on_bytes_received_context, ON_IO_ERROR on_io_error, void* on_io_error_context);
-extern int xio_close(XIO_HANDLE xio, ON_IO_CLOSE_COMPLETE on_io_close_complete, void* callback_context);
-extern int xio_send(XIO_HANDLE xio, const void* buffer, size_t size, ON_SEND_COMPLETE on_send_complete, void* callback_context);
-extern void xio_dowork(XIO_HANDLE xio);
-extern int xio_setoption(XIO_HANDLE xio, const char* optionName, const void* value);
+MOCKABLE_FUNCTION(, XIO_HANDLE, xio_create, const IO_INTERFACE_DESCRIPTION*, io_interface_description, const void*, io_create_parameters, LOGGER_LOG, logger_log);
+MOCKABLE_FUNCTION(, void, xio_destroy, XIO_HANDLE, xio);
+MOCKABLE_FUNCTION(, int, xio_open, XIO_HANDLE, xio, ON_IO_OPEN_COMPLETE, on_io_open_complete, void*, on_io_open_complete_context, ON_BYTES_RECEIVED, on_bytes_received, void*, on_bytes_received_context, ON_IO_ERROR, on_io_error, void*, on_io_error_context);
+MOCKABLE_FUNCTION(, int, xio_close, XIO_HANDLE, xio, ON_IO_CLOSE_COMPLETE, on_io_close_complete, void*, callback_context);
+MOCKABLE_FUNCTION(, int, xio_send, XIO_HANDLE, xio, const void*, buffer, size_t, size, ON_SEND_COMPLETE, on_send_complete, void*, callback_context);
+MOCKABLE_FUNCTION(, void, xio_dowork, XIO_HANDLE, xio);
+MOCKABLE_FUNCTION(, int, xio_setoption, XIO_HANDLE, xio, const char*, optionName, const void*, value);
#ifdef __cplusplus
}
--- a/httpapiex.c Sun Apr 24 16:41:14 2016 -0700
+++ b/httpapiex.c Mon May 09 14:37:45 2016 -0700
@@ -112,7 +112,7 @@
}
else
{
- char temp[22];
+ char temp[22] = { 0 };
(void)size_tToString(temp, 22, BUFFER_length(requestContent)); /*cannot fail, MAX_uint64 has 19 digits*/
/*Codes_SRS_HTTPAPIEX_02_011: [If parameter requestHttpHeadersHandle is not NULL then HTTPAPIEX_ExecuteRequest shall create or update the following headers of the request:
Host:{hostname}
