zvfs: testcase重写
This commit is contained in:
40
test/test_utils.h
Executable file
40
test/test_utils.h
Executable 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
|
||||
Reference in New Issue
Block a user