tests: Add two devices test

This commit is contained in:
sheinz 2016-08-19 01:23:26 +03:00
parent 5ace1c5bff
commit 33d695ec83
11 changed files with 277 additions and 10 deletions

View file

@ -34,6 +34,7 @@ class Test(threading.Thread):
def wait_start(self):
skip_lines = 100
while skip_lines > 0:
self._port.write('START\n'.encode())
l = self._port.readline()
if 'TEST_INIT: TIMEOUT=' in l:
res = re.findall(r'\d+', l)

View file

@ -23,5 +23,35 @@
*/
#include "test.h"
#include <string.h>
#include "task.h"
#include "esp/uart.h"
bool test_result = true;
void test_init(uint32_t timeout)
{
char buf[256];
int data_len = 0;
buf[data_len] = 0;
uart_set_baud(0, 115200);
while (true) {
int c = getchar();
if (c == EOF || c == '\n' || c == '\r') {
if (strcmp(buf, "START") == 0) {
break;
} else {
data_len = 0;
buf[data_len] = 0;
}
} else{
buf[data_len++] = c;
buf[data_len] = 0;
}
taskYIELD();
}
printf("TEST_INIT: TIMEOUT=%ds\n", timeout); \
}

View file

@ -27,7 +27,6 @@
#include <stdio.h>
#include <stdbool.h>
#include "esp/uart.h"
#include "FreeRTOS.h"
extern bool test_result;
@ -56,12 +55,8 @@ extern bool test_result;
printf("TEST_FINISH: FAIL\n"); \
}
#define TEST_INIT(timeout) \
if (true) { \
test_result = true; \
uart_set_baud(0, 115200); \
printf("TEST_INIT: TIMEOUT=%ds\n", timeout); \
}
#define TEST_INIT(timeout) test_init(timeout)
void test_init(uint32_t timeout);
#endif // __TEST_H__