Skip to content
Snippets Groups Projects
Commit fa12fbf1 authored by Kaspar Schleiser's avatar Kaspar Schleiser
Browse files

* added mutex trylock regression test

parent 62035f36
No related branches found
No related tags found
No related merge requests found
SubDir TOP projects test_mutex_trylock_fail ;
Module test_mutex_trylock_fail : main.c ;
UseModule test_mutex_trylock_fail ;
#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.");
}
#!/usr/bin/expect
set timeout 5
spawn pseudoterm $env(PORT)
expect {
"main: mutex unlocked." {}
timeout { exit 1 }
}
puts "\nTest successful!\n"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment