9#include "tests/vm/sample.inc"
17 int slen =
strlen (sample);
21 CHECK (
create (
"sample.txt", slen),
"create \"sample.txt\"");
22 CHECK ((handle =
open (
"sample.txt")) > 1,
"open \"sample.txt\"");
23 CHECK (
write (handle, sample, slen) == slen,
"write \"sample.txt\"");
27 CHECK ((handle =
open (
"sample.txt")) > 1,
"2nd open \"sample.txt\"");
28 CHECK (
read (handle,
buf2 + 32768, slen) == slen,
"read \"sample.txt\"");
30 CHECK (!
memcmp (sample,
buf2 + 32768, slen),
"compare written data against read data");
bool create(const char *file, unsigned initial_size)
int open(const char *file)
int write(int fd, const void *buffer, unsigned size)
int read(int fd, void *buffer, unsigned size)
#define CHECK(SUCCESS,...)
Takes an expression to test for SUCCESS and a message, which may include printf-style arguments.
void test_main(void)
This test checks that the stack is properly extended even if the first access to a stack location occ...
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.