CS318 - Pintos
Pintos source browser for JHU CS318 course
grow-tell.c
Go to the documentation of this file.
1 /** Checks that growing a file updates the file position
2  correctly. */
3 
4 #include <syscall.h>
6 #include "tests/lib.h"
7 #include "tests/main.h"
8 
9 static char buf[2134];
10 
11 static size_t
13 {
14  return 37;
15 }
16 
17 static void
18 check_tell (int fd, long ofs)
19 {
20  long pos = tell (fd);
21  if (pos != ofs)
22  fail ("file position not updated properly: should be %ld, actually %ld",
23  ofs, pos);
24 }
25 
26 void
27 test_main (void)
28 {
29  seq_test ("foobar",
30  buf, sizeof buf, 0,
32 }
lib.h
return_block_size
static size_t return_block_size(void)
Definition: grow-tell.c:12
seq_test
void seq_test(const char *file_name, void *buf, size_t size, size_t initial_size, size_t(*block_size_func)(void), void(*check_func)(int fd, long ofs))
tests/filesys/seq-test.h
Definition: seq-test.c:7
buf
static char buf[2134]
Checks that growing a file updates the file position correctly.
Definition: grow-tell.c:9
test_main
void test_main(void)
tests/main.h
Definition: grow-tell.c:27
tell
unsigned tell(int fd)
Definition: syscall.c:133
fail
void fail(const char *format,...)
Definition: lib.c:40
check_tell
static void check_tell(int fd, long ofs)
Definition: grow-tell.c:18
main.h
seq-test.h