mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
* test_suite: added thread_sleep test & expect script'
This commit is contained in:
parent
09a8bdd269
commit
8b91cd790b
70
projects/test_suite/tests/04-thread_sleep
Executable file
70
projects/test_suite/tests/04-thread_sleep
Executable file
@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/expect
|
||||||
|
|
||||||
|
set timeout 5
|
||||||
|
|
||||||
|
spawn pseudoterm $env(PORT)
|
||||||
|
|
||||||
|
expect {
|
||||||
|
">$" {}
|
||||||
|
timeout { exit 1 }
|
||||||
|
}
|
||||||
|
|
||||||
|
send "start_test\n"
|
||||||
|
expect {
|
||||||
|
"\[TEST_START\]" {}
|
||||||
|
timeout { exit 1 }
|
||||||
|
}
|
||||||
|
|
||||||
|
expect {
|
||||||
|
">$" {}
|
||||||
|
timeout { exit 1 }
|
||||||
|
}
|
||||||
|
|
||||||
|
send "thread_sleep\n"
|
||||||
|
expect {
|
||||||
|
" main: running. integer=0, i=1." {}
|
||||||
|
" main: running. integer=0, i=2." {}
|
||||||
|
"Waking up sleeper." {}
|
||||||
|
"sleeper: running. integer=1, i=2." {}
|
||||||
|
"sleeper: running. integer=2, i=2." {}
|
||||||
|
"Going to sleep." {}
|
||||||
|
" main: running. integer=2, i=3." {}
|
||||||
|
" main: running. integer=2, i=4." {}
|
||||||
|
"Waking up sleeper." {}
|
||||||
|
"Woke up!" {}
|
||||||
|
"sleeper: running. integer=3, i=4." {}
|
||||||
|
"sleeper: running. integer=4, i=4." {}
|
||||||
|
"Going to sleep." {}
|
||||||
|
" main: running. integer=4, i=5." {}
|
||||||
|
" main: running. integer=4, i=6." {}
|
||||||
|
"Waking up sleeper." {}
|
||||||
|
"Woke up!" {}
|
||||||
|
"sleeper: running. integer=5, i=6." {}
|
||||||
|
"sleeper: running. integer=6, i=6." {}
|
||||||
|
"Going to sleep." {}
|
||||||
|
" main: running. integer=6, i=7." {}
|
||||||
|
" main: running. integer=6, i=8." {}
|
||||||
|
"Waking up sleeper." {}
|
||||||
|
"Woke up!" {}
|
||||||
|
"sleeper: running. integer=7, i=8." {}
|
||||||
|
"sleeper: running. integer=8, i=8." {}
|
||||||
|
"Going to sleep." {}
|
||||||
|
" main: running. integer=8, i=9." {}
|
||||||
|
" main: running. integer=8, i=10." {}
|
||||||
|
"Waking up sleeper." {}
|
||||||
|
"Woke up!" {}
|
||||||
|
"sleeper: running. integer=9, i=10." {}
|
||||||
|
"sleeper: running. integer=10, i=10." {}
|
||||||
|
"Going to sleep." {}
|
||||||
|
">$" {}
|
||||||
|
timeout { exit 1 }
|
||||||
|
}
|
||||||
|
|
||||||
|
send "end_test\n"
|
||||||
|
|
||||||
|
expect {
|
||||||
|
"\[TEST_END\]" {}
|
||||||
|
timeout { exit 1 }
|
||||||
|
}
|
||||||
|
|
||||||
|
puts "\nTest successful!\n"
|
@ -9,7 +9,7 @@ static void second_thread(void) {
|
|||||||
while(1) {
|
while(1) {
|
||||||
integer++;
|
integer++;
|
||||||
printf("sleeper: running. integer=%i, i=%i.\n", integer, i);
|
printf("sleeper: running. integer=%i, i=%i.\n", integer, i);
|
||||||
if (integer % 10 == 0) {
|
if (integer % 2 == 0) {
|
||||||
printf("Going to sleep.\n");
|
printf("Going to sleep.\n");
|
||||||
thread_sleep();
|
thread_sleep();
|
||||||
printf("Woke up!\n");
|
printf("Woke up!\n");
|
||||||
@ -29,10 +29,10 @@ void test_thread_sleep(char* line)
|
|||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
while(1) {
|
while(i < 10) {
|
||||||
i++;
|
i++;
|
||||||
printf(" main: running. integer=%i, i=%i.\n", integer, i);
|
printf(" main: running. integer=%i, i=%i.\n", integer, i);
|
||||||
if (i % 10 == 0) {
|
if (i % 2 == 0) {
|
||||||
printf("Waking up sleeper.\n");
|
printf("Waking up sleeper.\n");
|
||||||
thread_wakeup(pid);
|
thread_wakeup(pid);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user