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:
parent
62035f36c8
commit
fa12fbf167
5
projects/test_mutex_trylock_fail/Jamfile
Normal file
5
projects/test_mutex_trylock_fail/Jamfile
Normal file
@ -0,0 +1,5 @@
|
||||
SubDir TOP projects test_mutex_trylock_fail ;
|
||||
|
||||
Module test_mutex_trylock_fail : main.c ;
|
||||
|
||||
UseModule test_mutex_trylock_fail ;
|
31
projects/test_mutex_trylock_fail/main.c
Normal file
31
projects/test_mutex_trylock_fail/main.c
Normal 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.");
|
||||
}
|
13
projects/test_mutex_trylock_fail/tests/test_mutex_trylock_fail
Executable file
13
projects/test_mutex_trylock_fail/tests/test_mutex_trylock_fail
Executable 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"
|
||||
|
Loading…
Reference in New Issue
Block a user