Merge pull request #13210 from dustin-crossman/pr/sleep_test_fix

Fix hal-sleep/sleep_manager Tests on Cypress Targets
pull/13227/head
Martin Kojtal 2020-07-03 10:36:22 +02:00 committed by GitHub
commit fe2fb48907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 22 deletions

View File

@ -61,17 +61,17 @@ void sleep_usticker_test()
const ticker_irq_handler_type us_ticker_irq_handler_org = set_us_ticker_irq_handler(us_ticker_isr);
/* Give some time Green Tea to finish UART transmission before entering
* sleep mode.
*/
busy_wait_ms(SERIAL_FLUSH_TIME_MS);
/* Test only sleep functionality. */
sleep_manager_lock_deep_sleep();
TEST_ASSERT_FALSE_MESSAGE(sleep_manager_can_deep_sleep(), "deep sleep should be locked");
/* Testing wake-up time 10 us. */
for (timestamp_t i = 100; i < 1000; i += 100) {
/* Give some time Green Tea to finish UART transmission before entering
* sleep mode.
*/
busy_wait_ms(SERIAL_FLUSH_TIME_MS);
/* note: us_ticker_read() operates on ticks. */
const timestamp_t start_timestamp = us_ticker_read();
const timestamp_t next_match_timestamp = overflow_protect(start_timestamp + us_to_ticks(i, ticker_freq),
@ -108,15 +108,15 @@ void deepsleep_lpticker_test()
const ticker_irq_handler_type lp_ticker_irq_handler_org = set_lp_ticker_irq_handler(lp_ticker_isr);
/* Give some time Green Tea to finish UART transmission before entering
* deep-sleep mode.
*/
busy_wait_ms(SERIAL_FLUSH_TIME_MS);
TEST_ASSERT_TRUE_MESSAGE(sleep_manager_can_deep_sleep(), "deep sleep should not be locked");
/* Testing wake-up time 10 ms. */
for (timestamp_t i = 20000; i < 200000; i += 20000) {
/* Give some time Green Tea to finish UART transmission before entering
* deep-sleep mode.
*/
busy_wait_ms(SERIAL_FLUSH_TIME_MS);
/* note: lp_ticker_read() operates on ticks. */
const timestamp_t start_timestamp = lp_ticker_read();
const timestamp_t next_match_timestamp = overflow_protect(start_timestamp + us_to_ticks(i, ticker_freq), ticker_width);

View File

@ -523,7 +523,7 @@ static int CurTok = 0;
*
* tok_eof ::= EOF (end of file)
* tok_open ::= "{{"
* tok_close ::= "}}"
* tok_close ::= "}}\n"
* tok_semicolon ::= ";"
* tok_string ::= [a-zA-Z0-9_-!@#$%^&*()]+ // See isstring() function
*
@ -597,7 +597,7 @@ extern "C" int greentea_parse_kv(char *out_key,
case tok_open:
if (HandleKV(out_key, out_value, out_key_size, out_value_size)) {
// We've found {{ KEY ; VALUE }} expression
// We've found {{ KEY ; VALUE }}\n expression
return 1;
}
break;
@ -684,7 +684,7 @@ static int isstring(int c) {
*
* <TOK_EOF> ::= EOF (end of file)
* <TOK_OPEN> ::= "{{"
* <TOK_CLOSE> ::= "}}"
* <TOK_CLOSE> ::= "}}\n"
* <TOK_SEMICOLON> ::= ";"
* <TOK_STRING> ::= [a-zA-Z0-9_-!@#$%^&*()]+ // See isstring() function *
*
@ -737,13 +737,16 @@ static int gettok(char *out_str, const int str_size) {
}
// close ::= '}'
if (LastChar == '}') {
LastChar = greentea_getc();
if (LastChar == '}') {
LastChar = '!';
return tok_close;
}
}
if (LastChar == '}') {
LastChar = greentea_getc();
if (LastChar == '}') {
LastChar = greentea_getc();
if (LastChar == '\n') {
LastChar = '!';
return tok_close;
}
}
}
if (LastChar == EOF)
return tok_eof;
@ -762,8 +765,8 @@ static int gettok(char *out_str, const int str_size) {
* <MESSAGE>: <TOK_OPEN> <TOK_STRING> <TOK_SEMICOLON> <TOK_STRING> <TOK_CLOSE>
*
* Examples:
* message: "{{__timeout; 1000}}"
* "{{__sync; 12345678-1234-5678-1234-567812345678}}"
* message: "{{__timeout; 1000}}\n"
* "{{__sync; 12345678-1234-5678-1234-567812345678}}\n"
*
* \param out_key Output buffer to store key string value
* \param out_value Output buffer to store value string value