CS318 - Pintos
Pintos source browser for JHU CS318 course
src
tests
vm
mmap-over-data.c
Go to the documentation of this file.
1
/** Verifies that mapping over the data segment is disallowed. */
2
3
#include <
stdint.h
>
4
#include <
round.h
>
5
#include <syscall.h>
6
#include "
tests/lib.h
"
7
#include "
tests/main.h
"
8
9
static
char
x
;
10
11
void
12
test_main
(
void
)
13
{
14
uintptr_t
x_page =
ROUND_DOWN
((
uintptr_t
) &
x
, 4096);
15
int
handle;
16
17
CHECK
((handle =
open
(
"sample.txt"
)) > 1,
"open \"sample.txt\""
);
18
CHECK
(
mmap
(handle, (
void
*) x_page) ==
MAP_FAILED
,
19
"try to mmap over data segment"
);
20
}
21
lib.h
CHECK
#define CHECK(SUCCESS,...)
Takes an expression to test for SUCCESS and a message, which may include printf-style arguments.
Definition:
lib.h:29
MAP_FAILED
#define MAP_FAILED
Definition:
syscall.h:13
open
int open(const char *file)
Definition:
syscall.c:103
test_main
void test_main(void)
tests/main.h
Definition:
mmap-over-data.c:12
round.h
stdint.h
x
static char x
Verifies that mapping over the data segment is disallowed.
Definition:
mmap-over-data.c:9
main.h
ROUND_DOWN
#define ROUND_DOWN(X, STEP)
Yields X rounded down to the nearest multiple of STEP.
Definition:
round.h:14
mmap
mapid_t mmap(int fd, void *addr)
Project 3 and optionally project 4.
Definition:
syscall.c:145
uintptr_t
uint32_t uintptr_t
Definition:
stdint.h:36
Generated on Thu Aug 22 2019 10:19:15 for CS318 - Pintos by
1.8.16