zvfs: testcase重写

This commit is contained in:
2026-03-02 07:27:48 +00:00
parent 4f3e2a592f
commit f82e089325
23 changed files with 1597 additions and 932 deletions

27
test/test_write_file.c Executable file
View File

@@ -0,0 +1,27 @@
#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);
}