test_console.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "sdkconfig.h"
  4. #include "unity.h"
  5. #include "test_utils.h"
  6. #include "esp_console.h"
  7. #include "argtable3/argtable3.h"
  8. #include "freertos/FreeRTOS.h"
  9. #include "freertos/task.h"
  10. static int do_hello_cmd(int argc, char **argv)
  11. {
  12. printf("Hello World\n");
  13. return 0;
  14. }
  15. TEST_CASE("esp console init/deinit test", "[console]")
  16. {
  17. esp_console_config_t console_config = ESP_CONSOLE_CONFIG_DEFAULT();
  18. TEST_ESP_OK(esp_console_init(&console_config));
  19. const esp_console_cmd_t cmd = {
  20. .command = "hello",
  21. .help = "Print Hello World",
  22. .hint = NULL,
  23. .func = do_hello_cmd,
  24. };
  25. TEST_ESP_OK(esp_console_cmd_register(&cmd));
  26. // re-register the same command, just for test
  27. TEST_ESP_OK(esp_console_cmd_register(&cmd));
  28. TEST_ESP_OK(esp_console_deinit());
  29. }
  30. // Enter "quit" to exit REPL environment
  31. TEST_CASE("esp console repl test", "[console][ignore]")
  32. {
  33. esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT();
  34. TEST_ESP_OK(esp_console_repl_init(&repl_config));
  35. TEST_ESP_OK(esp_console_repl_start());
  36. vTaskDelay(pdMS_TO_TICKS(2000));
  37. }