From 6e1ceb5ab56005fd343f52bbb8d2879e2c1493bd Mon Sep 17 00:00:00 2001 From: Sven Dziadek Date: Mon, 16 Apr 2012 21:37:40 +0200 Subject: P-FP: make PCP available to user space PCP was only used for DPCP before tests: add some basic tests for PCP under P-FP --- tests/pcp.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/pcp.c (limited to 'tests') diff --git a/tests/pcp.c b/tests/pcp.c new file mode 100644 index 0000000..a893da6 --- /dev/null +++ b/tests/pcp.c @@ -0,0 +1,54 @@ +#include +#include +#include + +#include "tests.h" +#include "litmus.h" + + +TESTCASE(lock_pcp, P_FP, + "PCP acquisition and release") +{ + int fd, od, cpu = 0; + + SYSCALL( fd = open(".pcp_locks", O_RDONLY | O_CREAT) ); + + SYSCALL( sporadic_partitioned(10, 100, cpu) ); + SYSCALL( task_mode(LITMUS_RT_TASK) ); + + SYSCALL( od = open_pcp_sem(fd, 0, cpu) ); + + SYSCALL( litmus_lock(od) ); + SYSCALL( litmus_unlock(od) ); + + SYSCALL( litmus_lock(od) ); + SYSCALL( litmus_unlock(od) ); + + SYSCALL( litmus_lock(od) ); + SYSCALL( litmus_unlock(od) ); + + /* tasks may not unlock resources they don't own */ + SYSCALL_FAILS(EINVAL, litmus_unlock(od) ); + + SYSCALL( od_close(od) ); + + SYSCALL( close(fd) ); + + SYSCALL( remove(".pcp_locks") ); +} + +TESTCASE(not_lock_pcp_be, P_FP, + "don't let best-effort tasks lock PCP semaphores") +{ + int fd, od; + + SYSCALL( fd = open(".pcp_locks", O_RDONLY | O_CREAT) ); + + /* BE task are not even allowed to open a PCP semaphore */ + SYSCALL_FAILS(EPERM, od = open_pcp_sem(fd, 0, 1) ); + + SYSCALL( close(fd) ); + + SYSCALL( remove(".pcp_locks") ); + +} -- cgit v1.2.2