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

40
test/test_utils.h Executable file
View File

@@ -0,0 +1,40 @@
#ifndef TEST_UTILS_H
#define TEST_UTILS_H
#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
static inline double time_diff_sec(struct timespec a, struct timespec b)
{
return (b.tv_sec - a.tv_sec) + (b.tv_nsec - a.tv_nsec) / 1000000000.0;
}
static inline void make_path(char *out, size_t out_sz, const char *dir, const char *name)
{
if (dir && dir[0] != 0) {
snprintf(out, out_sz, "%s/%s", dir, name);
} else {
snprintf(out, out_sz, "/tmp/%s", name);
}
}
static inline int report_result(const char *name, int rc)
{
printf("\n=== %s %s ===\n", name, rc == 0 ? "PASSED" : "FAILED");
return rc;
}
#endif