Skip to content

Commit 9d8caf6

Browse files
committed
feat(esp_repl): Add integration tests
1 parent cc96470 commit 9d8caf6

File tree

6 files changed

+199
-119
lines changed

6 files changed

+199
-119
lines changed

esp_repl/.build-test-rules.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ esp_repl/test_apps:
22
enable:
33
- if: IDF_TARGET == "linux"
44
reason: "Sufficient to test on Linux target"
5+
disable:
6+
- if: IDF_VERSION_MAJOR <= 5 and IDF_VERSION_MINOR <= 4
7+
reason: "those versions of esp-idf do not support eventfd for linux target"

esp_repl/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.0.0"
1+
version: "0.1.0"
22
description: "esp_repl - Read Eval Print Loop component"
33
url: https://github.com/espressif/idf-extra-components/tree/master/esp_repl
44
dependencies:

esp_repl/include/esp_repl.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ extern "C" {
1919
*/
2020
typedef struct esp_repl_instance *esp_repl_handle_t;
2121

22+
/**
23+
* @brief Function prototype called at the beginning of esp_repl().
24+
*
25+
* @param ctx User-defined context pointer.
26+
* @param handle Handle to the REPL instance.
27+
*/
28+
typedef void (*esp_repl_on_enter_fn)(void *ctx, esp_repl_handle_t handle);
29+
30+
/**
31+
* @brief Enter callback configuration structure for the REPL.
32+
*/
33+
typedef struct esp_repl_on_enter {
34+
esp_repl_on_enter_fn func; /**!< Function called at the beginning of esp_repl() */
35+
void *ctx; /**!< Context passed to the enter function */
36+
} esp_repl_on_enter_t;
37+
2238
/**
2339
* @brief Function prototype called before executing a command.
2440
*
@@ -101,6 +117,7 @@ typedef struct esp_repl_config {
101117
esp_command_set_handle_t command_set_handle; /**!< Handle to a set of commands */
102118
size_t max_cmd_line_size; /**!< Maximum allowed command line size */
103119
const char *history_save_path; /**!< Path to file to save the history */
120+
esp_repl_on_enter_t on_enter; /**!< Enter callback and context */
104121
esp_repl_pre_executor_t pre_executor; /**!< Pre-executor callback and context */
105122
esp_repl_post_executor_t post_executor; /**!< Post-executor callback and context */
106123
esp_repl_on_stop_t on_stop; /**!< Stop callback and context */

esp_repl/src/esp_repl.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ void esp_repl(esp_repl_handle_t handle)
184184
esp_repl_config_t *config = &handle->config;
185185
esp_repl_state_t *state = &handle->state;
186186

187+
/* trigger a user defined callback before the function gets into the while loop
188+
* if the user wants to perform some logic that needs to be done within the task
189+
* running the REPL */
190+
if (config->on_enter.func != NULL) {
191+
config->on_enter.func(config->on_enter.ctx, handle);
192+
}
193+
187194
/* get the task handle of the task running this function.
188195
* It is necessary to gather this information in case esp_repl_stop()
189196
* is called from the same task as the one running esp_repl() (e.g.,
@@ -257,7 +264,7 @@ void esp_repl(esp_repl_handle_t handle)
257264
cmd_args.write_func = write;
258265
}
259266

260-
const esp_err_t exec_ret = esp_commands_execute(c_set, &cmd_args, cmd_line, &cmd_func_ret);
267+
const esp_err_t exec_ret = esp_commands_execute(cmd_line, &cmd_func_ret, c_set, &cmd_args);
261268

262269
/* forward the raw command line to the post executor callback (e.g., save in history).
263270
* this callback is not necessary for the user to register, continue if it isn't */

0 commit comments

Comments
 (0)