PKUOS - Pintos
Pintos source browser for PKU Operating System course
src
tests
filesys
extended
grow-file-size.c
Go to the documentation of this file.
1
/** Grows a file from 0 bytes to 2,134 bytes, 37 bytes at a time,
2
and checks that the file's size is reported correctly at each
3
step. */
4
5
#include <syscall.h>
6
#include "
tests/filesys/seq-test.h
"
7
#include "
tests/lib.h
"
8
#include "
tests/main.h
"
9
10
static
char
buf
[2134];
11
12
static
size_t
13
return_block_size
(
void
)
14
{
15
return
37;
16
}
17
18
static
void
19
check_file_size
(
int
fd,
long
ofs)
20
{
21
long
size =
filesize
(fd);
22
if
(size != ofs)
23
fail
(
"filesize not updated properly: should be %ld, actually %ld"
,
24
ofs, size);
25
}
26
27
void
28
test_main
(
void
)
29
{
30
seq_test
(
"testfile"
,
31
buf
,
sizeof
buf
, 0,
32
return_block_size
,
check_file_size
);
33
}
buf
static char buf[2134]
Grows a file from 0 bytes to 2,134 bytes, 37 bytes at a time, and checks that the file's size is repo...
Definition:
grow-file-size.c:10
test_main
void test_main(void)
tests/main.h
Definition:
grow-file-size.c:28
check_file_size
static void check_file_size(int fd, long ofs)
Definition:
grow-file-size.c:19
return_block_size
static size_t return_block_size(void)
Definition:
grow-file-size.c:13
filesize
int filesize(int fd)
Definition:
syscall.c:109
fail
void fail(const char *format,...)
Definition:
lib.c:40
lib.h
main.h
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
seq-test.h
Generated on Thu Nov 4 2021 19:31:01 for PKUOS - Pintos by
1.9.2