CS318 - Pintos
Pintos source browser for JHU CS318 course
src
tests
vm
mmap-over-code.c
Go to the documentation of this file.
1
/** Verifies that mapping over the code 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
void
10
test_main
(
void
)
11
{
12
uintptr_t
test_main_page =
ROUND_DOWN
((
uintptr_t
)
test_main
, 4096);
13
int
handle;
14
15
CHECK
((handle =
open
(
"sample.txt"
)) > 1,
"open \"sample.txt\""
);
16
CHECK
(
mmap
(handle, (
void
*) test_main_page) ==
MAP_FAILED
,
17
"try to mmap over code segment"
);
18
}
19
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
round.h
stdint.h
test_main
void test_main(void)
Verifies that mapping over the code segment is disallowed.
Definition:
mmap-over-code.c:10
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