1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

python expect swtimer test included

This commit is contained in:
Stephan Zeisberg 2010-10-26 16:51:28 +02:00
parent 57c9d3423f
commit 38994445dd
4 changed files with 78 additions and 0 deletions

View File

@ -0,0 +1,5 @@
SubDir TOP projects expect_swtimer ;
Module expect_swtimer : main.c : swtimer ;
UseModule expect_swtimer ;

View File

@ -0,0 +1,45 @@
#include <stdio.h>
#include <hwtimer.h>
#include <swtimer.h>
#include <thread.h>
#include <kernel.h>
#include <msg.h>
void callback(void* ptr){
puts((char*)ptr);
}
void wakeup_thread(void){
puts("wakeup");
}
void msg_thread(void){
msg m;
msg_receive(&m);
printf("%s\n",(char*)m.content.ptr);
}
int main(void)
{
hwtimer_init();
swtimer_init();
int pid1 = thread_create(8192, PRIORITY_MAIN-1,
CREATE_WOUT_YIELD | CREATE_SLEEPING | CREATE_STACKTEST, wakeup_thread, "nr1");
int pid2 = thread_create(8192, PRIORITY_MAIN-1,
/*CREATE_WOUT_YIELD | CREATE_SLEEPING |*/ CREATE_STACKTEST, msg_thread, "nr2");
swtimer_t cbt;
swtimer_t wut;
swtimer_t mst;
/* test callback */
swtimer_set_cb(&cbt,1000L,callback,"callback");
/* test wake-up */
swtimer_set_wakeup(&wut, 1000L, pid1);
/* test message */
swtimer_set_msg(&mst,1000L, pid2, "message");
while(1);
}

View File

@ -0,0 +1,13 @@
#!/usr/bin/expect
set timeout 5
spawn board/msba2/tools/bin/pseudoterm $env(PORT)
expect {
"Hello World!" {}
timeout { exit 1 }
}
puts "\nTest successful!\n"

View File

@ -0,0 +1,15 @@
#!/usr/bin/python
import pexpect
import os
import subprocess
child = pexpect.spawn ("board/msba2/tools/bin/pseudoterm %s" % os.environ["PORT"])
null = open('/dev/null', 'wb')
subprocess.call(['jam', 'reset'], stdout=null)
child.expect ('callback\r\n');
child.expect ('wakeup\r\n');
child.expect ('message\r\n');
print("Test successful!")