6#include "tests/vm/sample.inc"
13 static const char overwrite[] =
"Now is the time for all good...";
14 static char buffer[
sizeof sample - 1];
15 char *actual = (
char *) 0x54321000;
20 CHECK ((handle =
open (
"sample.txt")) > 1,
"open \"sample.txt\"");
23 fail (
"read of mmap'd file reported bad data");
27 == (
int)
strlen (overwrite),
28 "write \"sample.txt\"");
32 msg (
"munmap \"sample.txt\"");
36 msg (
"seek \"sample.txt\"");
39 "read \"sample.txt\"");
47 fail (
"munmap wrote back clean page");
49 fail (
"read surprising data from file");
52 msg (
"file change was retained after munmap");
mapid_t mmap(int fd, void *addr)
Project 3 and optionally project 4.
int open(const char *file)
int write(int fd, const void *buffer, unsigned size)
void seek(int fd, unsigned position)
int read(int fd, void *buffer, unsigned size)
void munmap(mapid_t mapid)
int mapid_t
Map region identifier.
void fail(const char *format,...)
void msg(const char *format,...)
#define CHECK(SUCCESS,...)
Takes an expression to test for SUCCESS and a message, which may include printf-style arguments.
void test_main(void)
Verifies that mmap'd regions are only written back on munmap if the data was actually modified in mem...
int memcmp(const void *a_, const void *b_, size_t size)
Find the first differing byte in the two blocks of SIZE bytes at A and B.
size_t strlen(const char *string)
Returns the length of STRING.