28 lines
721 B
C
Executable File
28 lines
721 B
C
Executable File
#include "test_utils.h"
|
|
|
|
static int test_write_file(const char *path)
|
|
{
|
|
printf("\n=== test_write_file ===\n");
|
|
|
|
int fd = open(path, O_CREAT | O_RDWR, 0644);
|
|
if (fd < 0) { perror("open"); return 1; }
|
|
printf("open: %s fd=%d\n", path, fd);
|
|
|
|
const char *msg = "Hello, zvfs!";
|
|
ssize_t w = write(fd, msg, strlen(msg));
|
|
if (w < 0) { perror("write"); close(fd); return 2; }
|
|
printf("write: %zd bytes: %s\n", w, msg);
|
|
|
|
close(fd);
|
|
printf("close: ok\n");
|
|
return 0;
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
char path[PATH_MAX];
|
|
make_path(path, sizeof(path), argc >= 2 ? argv[1] : NULL, "file.dat");
|
|
int rc = test_write_file(path);
|
|
return report_result("test_write_file", rc);
|
|
}
|