From ef69f4de3d239bc45e5265f58cf8f802b1c4699c Mon Sep 17 00:00:00 2001 From: Bjoern Brandenburg Date: Mon, 13 Aug 2012 13:28:37 +0200 Subject: Add tests for the DPCP and the MPCP Do the basic open/lock/unlock/close test sequence for the MPCP and the DPCP as well. --- tests/pcp.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/pcp.c b/tests/pcp.c index a893da6..88d1be3 100644 --- a/tests/pcp.c +++ b/tests/pcp.c @@ -37,18 +37,86 @@ TESTCASE(lock_pcp, P_FP, SYSCALL( remove(".pcp_locks") ); } +TESTCASE(lock_dpcp, P_FP, + "DPCP acquisition and release") +{ + int fd, od, cpu = 1; + + SYSCALL( fd = open(".pcp_locks", O_RDONLY | O_CREAT) ); + + SYSCALL( sporadic_partitioned(10, 100, 0) ); + SYSCALL( task_mode(LITMUS_RT_TASK) ); + + SYSCALL( od = open_dpcp_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") + "don't let best-effort tasks lock (D|M-)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 */ + /* BE tasks are not even allowed to open a PCP semaphore */ SYSCALL_FAILS(EPERM, od = open_pcp_sem(fd, 0, 1) ); + /* BE tasks are not allowed to open a D-PCP semaphore */ + SYSCALL_FAILS(EPERM, od = open_dpcp_sem(fd, 0, 1) ); + + /* BE tasks are not allowed to open an M-PCP semaphore */ + SYSCALL_FAILS(EPERM, od = open_mpcp_sem(fd, 0) ); + SYSCALL( close(fd) ); SYSCALL( remove(".pcp_locks") ); } + +TESTCASE(lock_mpcp, P_FP, + "MPCP acquisition and release") +{ + int fd, od; + + SYSCALL( fd = open(".pcp_locks", O_RDONLY | O_CREAT) ); + + SYSCALL( sporadic_partitioned(10, 100, 0) ); + SYSCALL( task_mode(LITMUS_RT_TASK) ); + + SYSCALL( od = open_mpcp_sem(fd, 0) ); + + 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") ); +} -- cgit v1.2.2