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

* added mutex trylock regression test

This commit is contained in:
Kaspar Schleiser 2010-11-01 16:12:22 +01:00
parent 62035f36c8
commit fa12fbf167
3 changed files with 49 additions and 0 deletions

View File

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

View File

@ -0,0 +1,31 @@
#include <stdio.h>
#include <mutex.h>
#include <thread.h>
#include <flags.h>
#include <kernel.h>
mutex_t mutex;
void second_thread(void) {
puts(" 2nd: trying to lock mutex...");
mutex_trylock(&mutex);
puts(" 2nd: done.");
}
tcb second_tcb;
char second_stack[8192];
int main(void)
{
puts("main: locking mutex...");
mutex_lock(&mutex);
puts("main: creating thread...");
int pid = thread_create(&second_tcb, second_stack, 8192, PRIORITY_MAIN-1, CREATE_STACKTEST, second_thread, "nr2");
puts("main: thread created. Unlocking mutex...");
mutex_unlock(&mutex, true);
puts("main: mutex unlocked.");
}

View File

@ -0,0 +1,13 @@
#!/usr/bin/expect
set timeout 5
spawn pseudoterm $env(PORT)
expect {
"main: mutex unlocked." {}
timeout { exit 1 }
}
puts "\nTest successful!\n"