test: add macros to run fs tests with io_uring (#4963 1/2)

Added `TEST_FS_DECLARE`, `TEST_FS_ENTRY` and `TEST_FS_IMPL` so we can
run test-fs.c tests both using the threadpool and io_uring
implementations.
This commit is contained in:
Santiago Gimeno 2025-12-07 22:40:05 +01:00
parent 9640bc6510
commit e522b27da3
2 changed files with 30 additions and 0 deletions

View File

@ -68,6 +68,23 @@ typedef struct {
#define TEST_ENTRY_CUSTOM(name, is_helper, show_output, timeout) \
{ #name, #name, &run_test_##name, is_helper, show_output, timeout },
/*
* Macros for fs tests that, on linux, generate both normal and io_uring
* versions.
*/
#ifdef __linux__
#define TEST_FS_DECLARE(name) \
TEST_DECLARE(name) \
TEST_DECLARE(name##_iouring)
#define TEST_FS_ENTRY(name) \
TEST_ENTRY(name) \
TEST_ENTRY(name##_iouring)
#else
#define TEST_FS_DECLARE(name) TEST_DECLARE(name)
#define TEST_FS_ENTRY(name) TEST_ENTRY(name)
#endif
#define BENCHMARK_DECLARE(name) \
int run_benchmark_##name(void);

View File

@ -284,6 +284,19 @@ typedef enum {
int run_benchmark_##name(void); \
int run_benchmark_##name(void)
#ifdef __linux__
#define TEST_FS_IMPL(name) \
int run_test_##name(void); \
int run_test_##name##_iouring(void) { \
uv_os_setenv("UV_USE_IO_URING", "1"); \
uv_loop_configure(uv_default_loop(), UV_LOOP_USE_IO_URING_SQPOLL); \
return run_test_##name(); \
} \
int run_test_##name(void)
#else
#define TEST_FS_IMPL(name) TEST_IMPL(name)
#endif
#define HELPER_IMPL(name) \
int run_helper_##name(void); \
int run_helper_##name(void)