* added mutex trylock regression test

dev/timer
Kaspar Schleiser 13 years ago
parent 62035f36c8
commit fa12fbf167

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

@ -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.");
}

@ -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"
Loading…
Cancel
Save