Skip to content

Commit 3848064

Browse files
committed
feat(esp_repl): add tests for esp_repl
1 parent b6992a5 commit 3848064

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

esp_repl/test_apps/main/test_esp_repl.c

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,69 @@
66

77
#include <string.h>
88
#include <stdio.h>
9-
#include <pthread.h>
9+
#include "freertos/FreeRTOS.h"
10+
#include "freertos/task.c"
11+
#include "freertos/semphr.h"
1012
#include "unity.h"
1113
#include "esp_repl.h"
14+
15+
typedef struct esp_linenoise_dummy {
16+
size_t value;
17+
} esp_linenoise_dummy_t;
18+
typedef struct esp_linenoise_dummy *esp_linenoise_handle_t;
19+
20+
typedef struct esp_commands_dummy {
21+
size_t value;
22+
} esp_commands_dummy_t;
23+
typedef struct esp_commands_dummy *esp_commands_handle_t;
24+
25+
esp_err_t esp_repl_reader_non_blocking(esp_linenoise_handle_t handle, char *buf, size_t buf_size)
26+
{
27+
return ESP_OK;
28+
}
29+
30+
esp_err_t esp_repl_pre_executor_fn(void *ctx, const char *buf, const esp_err_t reader_ret_val)
31+
{
32+
return ESP_OK;
33+
}
34+
35+
esp_err_t esp_repl_executor_fn(esp_commands_handle_t handle, const char *buf, int *ret_val)
36+
{
37+
return ESP_OK;
38+
}
39+
40+
esp_err_t esp_repl_post_executor_fn(void *ctx, const char *buf, const esp_err_t executor_ret_val, const int cmd_ret_val)
41+
{
42+
return ESP_OK;
43+
}
44+
45+
void esp_repl_on_stop_fn(void *ctx, esp_linenoise_handle_t handle)
46+
{
47+
return;
48+
}
49+
50+
void esp_repl_on_exit_fn(void *ctx, esp_linenoise_handle_t handle)
51+
{
52+
return;
53+
}
54+
55+
TEST_CASE("esp_repl() called after successful init, with non blocking reader", "[esp_repl]")
56+
{
57+
esp_commands_dummy_t dummy_esp_linenoise = {.value = 0x01 };
58+
esp_commands_dummy_t dummy_esp_commands = {.value = 0x02 };
59+
esp_repl_config_t config = {
60+
.max_cmd_line_size = 256,
61+
.reader = { .func = esp_repl_reader_non_blocking, .ctx = &dummy_esp_linenoise },
62+
.pre_executor = { .func = esp_repl_pre_executor_fn, .ctx = NULL },
63+
.executor = { .func = esp_repl_executor_fn, .ctx = &dummy_esp_commands },
64+
.post_executor = { .func = esp_repl_post_executor_fn, .ctx = NULL },
65+
.on_exit = { .func = esp_repl_on_exit_fn, .ctx = NULL }
66+
};
67+
68+
esp_repl_instance_handle_t handle = NULL;
69+
TEST_ASSERT_EQUAL(ESP_OK, esp_repl_create(&handle, &config));
70+
TEST_ASSERT_NOT_NULL(handle);
71+
72+
xTaskCreate()
73+
74+
}

0 commit comments

Comments
 (0)