-
Notifications
You must be signed in to change notification settings - Fork 37
/
fdso.c
102 lines (62 loc) · 1.84 KB
/
fdso.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <sys/wait.h> /* for waitpid() */
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include "tests.h"
#include "litmus.h"
TESTCASE(fmlp_not_active, C_EDF | PFAIR | LINUX,
"don't open FMLP semaphores if FMLP is not supported")
{
int fd;
SYSCALL( fd = open(".fmlp_locks", O_RDONLY | O_CREAT, S_IRUSR) );
ASSERT(fd != -1);
SYSCALL_FAILS(ENXIO, open_fmlp_sem(fd, 0) );
SYSCALL( close(fd) );
SYSCALL( remove(".fmlp_locks") );
}
TESTCASE(invalid_od, ALL,
"reject invalid object descriptors")
{
SYSCALL_FAILS( EINVAL, litmus_lock(3) );
SYSCALL_FAILS( EINVAL, litmus_unlock(3) );
SYSCALL_FAILS( EINVAL, od_close(3) );
SYSCALL_FAILS( EINVAL, litmus_lock(-1) );
SYSCALL_FAILS( EINVAL, litmus_unlock(-1) );
SYSCALL_FAILS( EINVAL, od_close(-1) );
}
TESTCASE(invalid_obj_type, ALL,
"reject invalid object types")
{
SYSCALL_FAILS( EINVAL, od_open(0, -1, 0) );
SYSCALL_FAILS( EINVAL, od_open(0, 10, 0) );
}
TESTCASE(not_inherit_od, GSN_EDF | PSN_EDF,
"don't inherit FDSO handles across fork")
{
int fd, od, pid, status;
SYSCALL( fd = open(".fmlp_locks", O_RDONLY | O_CREAT, S_IRUSR) );
SYSCALL( od = open_fmlp_sem(fd, 0) );
pid = fork();
ASSERT( pid != -1 );
/* must be an RT task to lock at all */
SYSCALL( sporadic_partitioned(ms2ns(10), ms2ns(100), 0) );
SYSCALL( task_mode(LITMUS_RT_TASK) );
if (pid == 0) {
/* child */
SYSCALL_FAILS(EINVAL, litmus_lock(od) );
SYSCALL_FAILS(EINVAL, litmus_unlock(od) );
SYSCALL( task_mode(BACKGROUND_TASK) );
exit(0);
} else {
SYSCALL( litmus_lock(od) );
SYSCALL( litmus_unlock(od) );
SYSCALL( litmus_lock(od) );
SYSCALL( litmus_unlock(od) );
SYSCALL( task_mode(BACKGROUND_TASK) );
SYSCALL( waitpid(pid, &status, 0) );
ASSERT(WEXITSTATUS(status) == 0);
}
SYSCALL( od_close(od) );
SYSCALL( close(fd) );
SYSCALL( remove(".fmlp_locks") );
}