Skip to content

Commit fe2fb48

Browse files
authored
Merge pull request #13210 from dustin-crossman/pr/sleep_test_fix
Fix hal-sleep/sleep_manager Tests on Cypress Targets
2 parents fa7c32c + 0ae7516 commit fe2fb48

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

TESTS/mbed_hal/sleep/main.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ void sleep_usticker_test()
6161

6262
const ticker_irq_handler_type us_ticker_irq_handler_org = set_us_ticker_irq_handler(us_ticker_isr);
6363

64-
/* Give some time Green Tea to finish UART transmission before entering
65-
* sleep mode.
66-
*/
67-
busy_wait_ms(SERIAL_FLUSH_TIME_MS);
68-
6964
/* Test only sleep functionality. */
7065
sleep_manager_lock_deep_sleep();
7166
TEST_ASSERT_FALSE_MESSAGE(sleep_manager_can_deep_sleep(), "deep sleep should be locked");
7267

7368
/* Testing wake-up time 10 us. */
7469
for (timestamp_t i = 100; i < 1000; i += 100) {
70+
/* Give some time Green Tea to finish UART transmission before entering
71+
* sleep mode.
72+
*/
73+
busy_wait_ms(SERIAL_FLUSH_TIME_MS);
74+
7575
/* note: us_ticker_read() operates on ticks. */
7676
const timestamp_t start_timestamp = us_ticker_read();
7777
const timestamp_t next_match_timestamp = overflow_protect(start_timestamp + us_to_ticks(i, ticker_freq),
@@ -108,15 +108,15 @@ void deepsleep_lpticker_test()
108108

109109
const ticker_irq_handler_type lp_ticker_irq_handler_org = set_lp_ticker_irq_handler(lp_ticker_isr);
110110

111-
/* Give some time Green Tea to finish UART transmission before entering
112-
* deep-sleep mode.
113-
*/
114-
busy_wait_ms(SERIAL_FLUSH_TIME_MS);
115-
116111
TEST_ASSERT_TRUE_MESSAGE(sleep_manager_can_deep_sleep(), "deep sleep should not be locked");
117112

118113
/* Testing wake-up time 10 ms. */
119114
for (timestamp_t i = 20000; i < 200000; i += 20000) {
115+
/* Give some time Green Tea to finish UART transmission before entering
116+
* deep-sleep mode.
117+
*/
118+
busy_wait_ms(SERIAL_FLUSH_TIME_MS);
119+
120120
/* note: lp_ticker_read() operates on ticks. */
121121
const timestamp_t start_timestamp = lp_ticker_read();
122122
const timestamp_t next_match_timestamp = overflow_protect(start_timestamp + us_to_ticks(i, ticker_freq), ticker_width);

features/frameworks/greentea-client/source/greentea_test_env.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ static int CurTok = 0;
523523
*
524524
* tok_eof ::= EOF (end of file)
525525
* tok_open ::= "{{"
526-
* tok_close ::= "}}"
526+
* tok_close ::= "}}\n"
527527
* tok_semicolon ::= ";"
528528
* tok_string ::= [a-zA-Z0-9_-!@#$%^&*()]+ // See isstring() function
529529
*
@@ -597,7 +597,7 @@ extern "C" int greentea_parse_kv(char *out_key,
597597

598598
case tok_open:
599599
if (HandleKV(out_key, out_value, out_key_size, out_value_size)) {
600-
// We've found {{ KEY ; VALUE }} expression
600+
// We've found {{ KEY ; VALUE }}\n expression
601601
return 1;
602602
}
603603
break;
@@ -684,7 +684,7 @@ static int isstring(int c) {
684684
*
685685
* <TOK_EOF> ::= EOF (end of file)
686686
* <TOK_OPEN> ::= "{{"
687-
* <TOK_CLOSE> ::= "}}"
687+
* <TOK_CLOSE> ::= "}}\n"
688688
* <TOK_SEMICOLON> ::= ";"
689689
* <TOK_STRING> ::= [a-zA-Z0-9_-!@#$%^&*()]+ // See isstring() function *
690690
*
@@ -737,13 +737,16 @@ static int gettok(char *out_str, const int str_size) {
737737
}
738738

739739
// close ::= '}'
740-
if (LastChar == '}') {
741-
LastChar = greentea_getc();
742-
if (LastChar == '}') {
743-
LastChar = '!';
744-
return tok_close;
745-
}
746-
}
740+
if (LastChar == '}') {
741+
LastChar = greentea_getc();
742+
if (LastChar == '}') {
743+
LastChar = greentea_getc();
744+
if (LastChar == '\n') {
745+
LastChar = '!';
746+
return tok_close;
747+
}
748+
}
749+
}
747750

748751
if (LastChar == EOF)
749752
return tok_eof;
@@ -762,8 +765,8 @@ static int gettok(char *out_str, const int str_size) {
762765
* <MESSAGE>: <TOK_OPEN> <TOK_STRING> <TOK_SEMICOLON> <TOK_STRING> <TOK_CLOSE>
763766
*
764767
* Examples:
765-
* message: "{{__timeout; 1000}}"
766-
* "{{__sync; 12345678-1234-5678-1234-567812345678}}"
768+
* message: "{{__timeout; 1000}}\n"
769+
* "{{__sync; 12345678-1234-5678-1234-567812345678}}\n"
767770
*
768771
* \param out_key Output buffer to store key string value
769772
* \param out_value Output buffer to store value string value

0 commit comments

Comments
 (0)