1 #include "tests/filesys/seq-test.h"
7 seq_test (const char *filename, void *buf, size_t size, size_t initial_size,
8 size_t (*block_size_func) (void),
9 void (*check_func) (int fd, long ofs))
14 random_bytes (buf, size);
15 CHECK (create (filename, initial_size), "create \"%s\"", filename);
16 CHECK ((fd = open (filename)) > 1, "open \"%s\"", filename);
19 msg ("writing \"%s\"", filename);
22 size_t block_size = block_size_func ();
23 if (block_size > size - ofs)
24 block_size = size - ofs;
26 if (write (fd, buf + ofs, block_size) != (int) block_size)
27 fail ("write %zu bytes at offset %zu in \"%s\" failed",
28 block_size, ofs, filename);
31 if (check_func != NULL)
34 msg ("close \"%s\"", filename);
36 check_file (filename, buf, size);