Files
Rafał Wojdyła baab561a75 [LibOS] Add tests for some typical FS use cases
These tests perform common FS operations in various ways:
- open/close
- read/write
- create/delete
- read/change size
- seek/tell
- memory-mapped read/write
- copy directory in different ways

Tests use both direct syscalls and stdio wrappers (FILE).

To run, call `make test` in `LibOS/shim/test/fs`.
2019-12-03 15:25:47 +01:00

22 lines
568 B
C

#include "common.h"
void copy_data(int fi, int fo, const char* input_path, const char* output_path, size_t size) {
size_t max_step = 16;
if (size > 65536)
max_step = 256;
void* data = alloc_buffer(max_step);
ssize_t offset = 0;
ssize_t step;
while (offset < size) {
if (offset + max_step <= size)
step = rand() % max_step + 1;
else
step = size - offset;
read_fd(input_path, fi, data, step);
write_fd(output_path, fo, data, step);
offset += step;
}
free(data);
}