diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/stubs/esp_err.h | 2 | ||||
| -rw-r--r-- | tests/unit/stubs/esp_http_client.h | 43 | ||||
| -rw-r--r-- | tests/unit/stubs/freertos/FreeRTOS.h | 1 |
3 files changed, 45 insertions, 1 deletions
diff --git a/tests/unit/stubs/esp_err.h b/tests/unit/stubs/esp_err.h index 84c3734..9bedb72 100644 --- a/tests/unit/stubs/esp_err.h +++ b/tests/unit/stubs/esp_err.h | |||
| @@ -13,6 +13,8 @@ typedef int esp_err_t; | |||
| 13 | #define ESP_ERR_NO_MEM 0x101 | 13 | #define ESP_ERR_NO_MEM 0x101 |
| 14 | #define ESP_ERR_NOT_FOUND 0x104 | 14 | #define ESP_ERR_NOT_FOUND 0x104 |
| 15 | 15 | ||
| 16 | static inline const char *esp_err_to_name(esp_err_t err) { (void)err; return "ESP_OK"; } | ||
| 17 | |||
| 16 | #define ESP_ERROR_CHECK(x) do { if ((x) != 0) { fprintf(stderr, "ESP_ERROR_CHECK failed: 0x%x\n", (int)(x)); abort(); } } while(0) | 18 | #define ESP_ERROR_CHECK(x) do { if ((x) != 0) { fprintf(stderr, "ESP_ERROR_CHECK failed: 0x%x\n", (int)(x)); abort(); } } while(0) |
| 17 | 19 | ||
| 18 | #endif | 20 | #endif |
diff --git a/tests/unit/stubs/esp_http_client.h b/tests/unit/stubs/esp_http_client.h index 4169714..288ce3b 100644 --- a/tests/unit/stubs/esp_http_client.h +++ b/tests/unit/stubs/esp_http_client.h | |||
| @@ -2,11 +2,52 @@ | |||
| 2 | #define STUBS_ESP_HTTP_CLIENT_H | 2 | #define STUBS_ESP_HTTP_CLIENT_H |
| 3 | 3 | ||
| 4 | #include "esp_err.h" | 4 | #include "esp_err.h" |
| 5 | #include <string.h> | ||
| 6 | #include <stdlib.h> | ||
| 5 | 7 | ||
| 6 | typedef void *esp_http_client_handle_t; | 8 | typedef enum { |
| 9 | HTTP_METHOD_GET = 0, | ||
| 10 | HTTP_METHOD_POST, | ||
| 11 | HTTP_METHOD_PUT, | ||
| 12 | HTTP_METHOD_DELETE, | ||
| 13 | } esp_http_client_method_t; | ||
| 14 | |||
| 15 | typedef void *esp_crt_bundle_attach_fn_t(void *conf); | ||
| 7 | 16 | ||
| 8 | typedef struct { | 17 | typedef struct { |
| 18 | const char *url; | ||
| 19 | esp_http_client_method_t method; | ||
| 20 | int timeout_ms; | ||
| 21 | esp_crt_bundle_attach_fn_t *crt_bundle_attach; | ||
| 9 | int cert_pem; | 22 | int cert_pem; |
| 10 | } esp_http_client_config_t; | 23 | } esp_http_client_config_t; |
| 11 | 24 | ||
| 25 | typedef void *esp_http_client_handle_t; | ||
| 26 | |||
| 27 | static inline esp_http_client_handle_t esp_http_client_init(const esp_http_client_config_t *cfg) { | ||
| 28 | (void)cfg; | ||
| 29 | return (void *)malloc(1); | ||
| 30 | } | ||
| 31 | static inline esp_err_t esp_http_client_set_header(esp_http_client_handle_t c, const char *k, const char *v) { | ||
| 32 | (void)c; (void)k; (void)v; return ESP_OK; | ||
| 33 | } | ||
| 34 | static inline esp_err_t esp_http_client_open(esp_http_client_handle_t c, int len) { | ||
| 35 | (void)c; (void)len; return ESP_OK; | ||
| 36 | } | ||
| 37 | static inline int esp_http_client_write(esp_http_client_handle_t c, const char *buf, int len) { | ||
| 38 | (void)c; (void)buf; return len; | ||
| 39 | } | ||
| 40 | static inline int esp_http_client_fetch_headers(esp_http_client_handle_t c) { | ||
| 41 | (void)c; return 0; | ||
| 42 | } | ||
| 43 | static inline int esp_http_client_get_status_code(esp_http_client_handle_t c) { | ||
| 44 | (void)c; return 200; | ||
| 45 | } | ||
| 46 | static inline int esp_http_client_read(esp_http_client_handle_t c, char *buf, int len) { | ||
| 47 | (void)c; (void)buf; (void)len; return 0; | ||
| 48 | } | ||
| 49 | static inline esp_err_t esp_http_client_cleanup(esp_http_client_handle_t c) { | ||
| 50 | free(c); return ESP_OK; | ||
| 51 | } | ||
| 52 | |||
| 12 | #endif | 53 | #endif |
diff --git a/tests/unit/stubs/freertos/FreeRTOS.h b/tests/unit/stubs/freertos/FreeRTOS.h index 0fee758..696da87 100644 --- a/tests/unit/stubs/freertos/FreeRTOS.h +++ b/tests/unit/stubs/freertos/FreeRTOS.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | static inline uint32_t xTaskGetTickCount(void) { return 0; } | 6 | static inline uint32_t xTaskGetTickCount(void) { return 0; } |
| 7 | static inline void vTaskDelay(uint32_t ticks) { (void)ticks; } | 7 | static inline void vTaskDelay(uint32_t ticks) { (void)ticks; } |
| 8 | #define pdMS_TO_TICKS(ms) ((ms) / 10) | 8 | #define pdMS_TO_TICKS(ms) ((ms) / 10) |
| 9 | #define portTICK_PERIOD_MS 10 | ||
| 9 | #define portMAX_DELAY 0xFFFFFFFF | 10 | #define portMAX_DELAY 0xFFFFFFFF |
| 10 | 11 | ||
| 11 | #endif | 12 | #endif |