kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'feature/unit_test_app_tweaks' into 'master'
unit-test-app: Don't auto-display menu after test run finishes Previous code would sometimes display menu multiple times, depending on UART activity. See merge request !253pull/149/head
commit
a35e4f5923
|
@ -1,16 +1,16 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include "unity.h"
|
||||
#include "rom/ets_sys.h"
|
||||
#include "rom/uart.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#define unity_printf ets_printf
|
||||
|
||||
// Functions which are defined in ROM, linker script provides addresses for these:
|
||||
int uart_tx_one_char(uint8_t c);
|
||||
void uart_tx_wait_idle(uint8_t uart_no);
|
||||
int UartRxString(uint8_t* dst, uint8_t max_length);
|
||||
|
||||
// Pointers to the head and tail of linked list of test description structs:
|
||||
static struct test_desc_t* s_unity_tests_first = NULL;
|
||||
static struct test_desc_t* s_unity_tests_last = NULL;
|
||||
|
@ -114,9 +114,7 @@ static void trim_trailing_space(char* str)
|
|||
}
|
||||
}
|
||||
|
||||
void unity_run_menu()
|
||||
{
|
||||
while (true)
|
||||
static int print_test_menu(void)
|
||||
{
|
||||
int test_counter = 0;
|
||||
unity_printf("\n\nHere's the test menu, pick your combo:\n");
|
||||
|
@ -126,14 +124,27 @@ void unity_run_menu()
|
|||
{
|
||||
unity_printf("(%d)\t\"%s\" %s\n", test_counter + 1, test->name, test->desc);
|
||||
}
|
||||
return test_counter;
|
||||
}
|
||||
|
||||
char cmdline[256];
|
||||
void unity_run_menu()
|
||||
{
|
||||
int test_count = print_test_menu();
|
||||
while (true)
|
||||
{
|
||||
char cmdline[256] = { 0 };
|
||||
while(strlen(cmdline) == 0)
|
||||
{
|
||||
/* Flush anything already in the RX buffer */
|
||||
while(uart_rx_one_char((uint8_t *) cmdline) == OK) {
|
||||
}
|
||||
/* Read input */
|
||||
UartRxString((uint8_t*) cmdline, sizeof(cmdline) - 1);
|
||||
trim_trailing_space(cmdline);
|
||||
|
||||
if (strlen(cmdline) == 0)
|
||||
{
|
||||
continue;
|
||||
if(strlen(cmdline) == 0) {
|
||||
/* if input was newline, print a new menu */
|
||||
print_test_menu();
|
||||
}
|
||||
}
|
||||
|
||||
UNITY_BEGIN();
|
||||
|
@ -153,13 +164,18 @@ void unity_run_menu()
|
|||
else
|
||||
{
|
||||
int test_index = strtol(cmdline, NULL, 10);
|
||||
if (test_index >= 1 && test_index <= test_counter)
|
||||
if (test_index >= 1 && test_index <= test_count)
|
||||
{
|
||||
uint32_t start = esp_log_timestamp(); /* hacky way to get ms */
|
||||
unity_run_single_test_by_index(test_index - 1);
|
||||
uint32_t end = esp_log_timestamp();
|
||||
printf("Test ran in %dms\n", end - start);
|
||||
}
|
||||
}
|
||||
|
||||
UNITY_END();
|
||||
|
||||
printf("Enter next test, or 'enter' to see menu\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#
|
||||
# Main Makefile. This is basically the same as a component makefile.
|
||||
# "main" pseudo-component makefile.
|
||||
#
|
||||
|
||||
include $(IDF_PATH)/make/component_common.mk
|
||||
# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.)
|
||||
|
|
Ładowanie…
Reference in New Issue