diff --git a/src/unit/test_util.c b/src/unit/test_util.c index 4558c38c3..9858318e0 100644 --- a/src/unit/test_util.c +++ b/src/unit/test_util.c @@ -6,6 +6,11 @@ #include "../util.h" #include "test_help.h" +#if defined(__linux__) +#include +#include +#endif + int test_string2ll(int argc, char **argv, int flags) { UNUSED(argc); UNUSED(argv); @@ -291,6 +296,15 @@ int test_reclaimFilePageCache(int argc, char **argv, int flags) { if (flags & UNIT_TEST_VALGRIND) return 0; #if defined(__linux__) + struct statfs stats; + + /* Check if /tmp is memory-backed (e.g., tmpfs) */ + if (statfs("/tmp", &stats) == 0) { + if (stats.f_type != TMPFS_MAGIC) { // Not tmpfs, use /tmp + return 0; + } + } + char *tmpfile = "/tmp/redis-reclaim-cache-test"; int fd = open(tmpfile, O_RDWR | O_CREAT, 0644); TEST_ASSERT(fd >= 0);