upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tests/unit/stubs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/stubs')
-rw-r--r--tests/unit/stubs/driver/gpio.h44
-rw-r--r--tests/unit/stubs/driver/i2c_master.h39
-rw-r--r--tests/unit/stubs/driver/i2c_types.h45
-rw-r--r--tests/unit/stubs/freertos/FreeRTOS.h6
-rw-r--r--tests/unit/stubs/freertos/queue.h37
-rw-r--r--tests/unit/stubs/http.h41
-rw-r--r--tests/unit/stubs/tollgate_api.h11
7 files changed, 223 insertions, 0 deletions
diff --git a/tests/unit/stubs/driver/gpio.h b/tests/unit/stubs/driver/gpio.h
new file mode 100644
index 0000000..d8dda0a
--- /dev/null
+++ b/tests/unit/stubs/driver/gpio.h
@@ -0,0 +1,44 @@
1#ifndef STUBS_DRIVER_GPIO_H
2#define STUBS_DRIVER_GPIO_H
3
4#include <stdint.h>
5
6typedef enum {
7 GPIO_MODE_DISABLE = 0,
8 GPIO_MODE_INPUT,
9 GPIO_MODE_OUTPUT,
10 GPIO_MODE_OUTPUT_OD,
11 GPIO_MODE_INPUT_OUTPUT_OD,
12 GPIO_MODE_INPUT_OUTPUT,
13} gpio_mode_t;
14
15typedef enum {
16 GPIO_INTR_DISABLE = 0,
17} gpio_int_type_t;
18
19typedef enum {
20 GPIO_PULLUP_DISABLE = 0,
21 GPIO_PULLUP_ENABLE,
22} gpio_pullup_t;
23
24typedef enum {
25 GPIO_PULLDOWN_DISABLE = 0,
26 GPIO_PULLDOWN_ENABLE,
27} gpio_pulldown_t;
28
29typedef struct {
30 uint64_t pin_bit_mask;
31 gpio_mode_t mode;
32 gpio_pullup_t pull_up_en;
33 gpio_pulldown_t pull_down_en;
34 gpio_int_type_t intr_type;
35} gpio_config_t;
36
37static inline int gpio_config(const gpio_config_t *cfg) { (void)cfg; return 0; }
38static inline int gpio_set_level(uint32_t gpio_num, uint32_t level) { (void)gpio_num; (void)level; return 0; }
39
40#define GPIO_INTR_DISABLE 0
41#define GPIO_PULLUP_DISABLE 0
42#define GPIO_PULLDOWN_DISABLE 0
43
44#endif
diff --git a/tests/unit/stubs/driver/i2c_master.h b/tests/unit/stubs/driver/i2c_master.h
new file mode 100644
index 0000000..f49eaad
--- /dev/null
+++ b/tests/unit/stubs/driver/i2c_master.h
@@ -0,0 +1,39 @@
1#ifndef STUBS_DRIVER_I2C_MASTER_H
2#define STUBS_DRIVER_I2C_MASTER_H
3
4#include "driver/i2c_types.h"
5#include "esp_err.h"
6#include <stdint.h>
7#include <stddef.h>
8
9static inline esp_err_t i2c_new_master_bus(const i2c_master_bus_config_t *cfg, i2c_master_bus_handle_t *ret) {
10 (void)cfg; (void)ret;
11 return ESP_OK;
12}
13
14static inline esp_err_t i2c_master_bus_add_device(i2c_master_bus_handle_t bus, const i2c_device_config_t *cfg, i2c_master_dev_handle_t *ret) {
15 (void)bus; (void)cfg; (void)ret;
16 return ESP_OK;
17}
18
19static inline esp_err_t i2c_master_transmit(i2c_master_dev_handle_t dev, const uint8_t *buf, size_t len, int timeout_ms) {
20 (void)dev; (void)buf; (void)len; (void)timeout_ms;
21 return ESP_OK;
22}
23
24static inline esp_err_t i2c_master_receive(i2c_master_dev_handle_t dev, uint8_t *buf, size_t len, int timeout_ms) {
25 (void)dev; (void)buf; (void)len; (void)timeout_ms;
26 return ESP_OK;
27}
28
29static inline esp_err_t i2c_master_bus_rm_device(i2c_master_dev_handle_t dev) {
30 (void)dev;
31 return ESP_OK;
32}
33
34static inline esp_err_t i2c_del_master_bus(i2c_master_bus_handle_t bus) {
35 (void)bus;
36 return ESP_OK;
37}
38
39#endif
diff --git a/tests/unit/stubs/driver/i2c_types.h b/tests/unit/stubs/driver/i2c_types.h
new file mode 100644
index 0000000..3590a8b
--- /dev/null
+++ b/tests/unit/stubs/driver/i2c_types.h
@@ -0,0 +1,45 @@
1#ifndef STUBS_DRIVER_I2C_TYPES_H
2#define STUBS_DRIVER_I2C_TYPES_H
3
4#include <stdint.h>
5#include <stddef.h>
6
7typedef int i2c_port_num_t;
8#define I2C_NUM_0 0
9
10typedef enum {
11 I2C_ADDR_BIT_LEN_7 = 0,
12} i2c_addr_bit_len_t;
13
14typedef enum {
15 I2C_CLK_SRC_DEFAULT = 0,
16} i2c_clock_source_t;
17
18typedef struct i2c_master_bus_t *i2c_master_bus_handle_t;
19typedef struct i2c_master_dev_t *i2c_master_dev_handle_t;
20
21typedef struct {
22 i2c_port_num_t i2c_port;
23 int sda_io_num;
24 int scl_io_num;
25 i2c_clock_source_t clk_source;
26 uint8_t glitch_ignore_cnt;
27 int intr_priority;
28 size_t trans_queue_depth;
29 struct {
30 uint32_t enable_internal_pullup : 1;
31 uint32_t allow_pd : 1;
32 } flags;
33} i2c_master_bus_config_t;
34
35typedef struct {
36 i2c_addr_bit_len_t dev_addr_length;
37 uint16_t device_address;
38 uint32_t scl_speed_hz;
39 uint32_t scl_wait_us;
40 struct {
41 uint32_t disable_ack_check : 1;
42 } flags;
43} i2c_device_config_t;
44
45#endif
diff --git a/tests/unit/stubs/freertos/FreeRTOS.h b/tests/unit/stubs/freertos/FreeRTOS.h
index 2d2b967..fc38846 100644
--- a/tests/unit/stubs/freertos/FreeRTOS.h
+++ b/tests/unit/stubs/freertos/FreeRTOS.h
@@ -3,11 +3,17 @@
3 3
4#include <stdint.h> 4#include <stdint.h>
5 5
6typedef int32_t BaseType_t;
7typedef uint32_t UBaseType_t;
8typedef uint32_t TickType_t;
9
6static inline uint32_t xTaskGetTickCount(void) { return 0; } 10static inline uint32_t xTaskGetTickCount(void) { return 0; }
7static inline void vTaskDelay(uint32_t ticks) { (void)ticks; } 11static inline void vTaskDelay(uint32_t ticks) { (void)ticks; }
8#define pdMS_TO_TICKS(ms) ((ms) / 10) 12#define pdMS_TO_TICKS(ms) ((ms) / 10)
9#define portTICK_PERIOD_MS 10 13#define portTICK_PERIOD_MS 10
14#define configTICK_RATE_HZ 100
10#define portMAX_DELAY 0xFFFFFFFF 15#define portMAX_DELAY 0xFFFFFFFF
11#define pdTRUE 1 16#define pdTRUE 1
17#define pdFALSE 0
12 18
13#endif 19#endif
diff --git a/tests/unit/stubs/freertos/queue.h b/tests/unit/stubs/freertos/queue.h
new file mode 100644
index 0000000..04aef49
--- /dev/null
+++ b/tests/unit/stubs/freertos/queue.h
@@ -0,0 +1,37 @@
1#ifndef STUB_FREERTOS_QUEUE_H
2#define STUB_FREERTOS_QUEUE_H
3
4#include <stddef.h>
5#include "freertos/FreeRTOS.h"
6
7typedef void *QueueHandle_t;
8
9static inline QueueHandle_t xQueueCreate(UBaseType_t uxQueueLength, UBaseType_t uxItemSize)
10{
11 (void)uxQueueLength;
12 (void)uxItemSize;
13 return (QueueHandle_t)1;
14}
15
16static inline BaseType_t xQueueSend(QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait)
17{
18 (void)xQueue;
19 (void)pvItemToQueue;
20 (void)xTicksToWait;
21 return pdTRUE;
22}
23
24static inline BaseType_t xQueueReceive(QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait)
25{
26 (void)xQueue;
27 (void)pvBuffer;
28 (void)xTicksToWait;
29 return pdFALSE;
30}
31
32static inline void vQueueDelete(QueueHandle_t xQueue)
33{
34 (void)xQueue;
35}
36
37#endif
diff --git a/tests/unit/stubs/http.h b/tests/unit/stubs/http.h
new file mode 100644
index 0000000..753ebd8
--- /dev/null
+++ b/tests/unit/stubs/http.h
@@ -0,0 +1,41 @@
1#ifndef STUBS_HTTP_H
2#define STUBS_HTTP_H
3
4#include "esp_err.h"
5#include <stddef.h>
6
7typedef struct {
8 int status;
9 char *body;
10 size_t body_len;
11} http_response_t;
12
13static inline esp_err_t http_get(const char *url, http_response_t *resp)
14{
15 (void)url; (void)resp;
16 return ESP_FAIL;
17}
18
19static inline esp_err_t http_post_json(const char *url, const char *json_body,
20 http_response_t *resp)
21{
22 (void)url; (void)json_body; (void)resp;
23 return ESP_FAIL;
24}
25
26static inline esp_err_t http_post_json_timeout(const char *url, const char *json_body,
27 http_response_t *resp, int timeout_ms)
28{
29 (void)url; (void)json_body; (void)resp; (void)timeout_ms;
30 return ESP_FAIL;
31}
32
33static inline void http_response_free(http_response_t *resp)
34{
35 if (resp && resp->body) {
36 free(resp->body);
37 resp->body = NULL;
38 }
39}
40
41#endif
diff --git a/tests/unit/stubs/tollgate_api.h b/tests/unit/stubs/tollgate_api.h
new file mode 100644
index 0000000..7e20fce
--- /dev/null
+++ b/tests/unit/stubs/tollgate_api.h
@@ -0,0 +1,11 @@
1#ifndef STUB_TOLLGATE_API_H
2#define STUB_TOLLGATE_API_H
3
4#include "freertos/queue.h"
5
6static inline void tls_worker_set_queue(QueueHandle_t q)
7{
8 (void)q;
9}
10
11#endif