Fix test_reclaimFilePageCache to avoid tmpfs (#1379)
Avoid tmpfs as fadvise(FADV_DONTNEED) has no effect on memory-backed filesystems. Fixes https://github.com/valkey-io/valkey/issues/897 --------- Signed-off-by: Ran Shidlansik <ranshid@amazon.com> Signed-off-by: ranshid <88133677+ranshid@users.noreply.github.com> Co-authored-by: ranshid <88133677+ranshid@users.noreply.github.com> Co-authored-by: Ran Shidlansik <ranshid@amazon.com>
This commit is contained in:
parent
980a801159
commit
7892bf808b
@ -6,6 +6,11 @@
|
|||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
#include "test_help.h"
|
#include "test_help.h"
|
||||||
|
|
||||||
|
#if defined(__linux__)
|
||||||
|
#include <sys/statfs.h>
|
||||||
|
#include <linux/magic.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
int test_string2ll(int argc, char **argv, int flags) {
|
int test_string2ll(int argc, char **argv, int flags) {
|
||||||
UNUSED(argc);
|
UNUSED(argc);
|
||||||
UNUSED(argv);
|
UNUSED(argv);
|
||||||
@ -291,6 +296,15 @@ int test_reclaimFilePageCache(int argc, char **argv, int flags) {
|
|||||||
if (flags & UNIT_TEST_VALGRIND) return 0;
|
if (flags & UNIT_TEST_VALGRIND) return 0;
|
||||||
|
|
||||||
#if defined(__linux__)
|
#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";
|
char *tmpfile = "/tmp/redis-reclaim-cache-test";
|
||||||
int fd = open(tmpfile, O_RDWR | O_CREAT, 0644);
|
int fd = open(tmpfile, O_RDWR | O_CREAT, 0644);
|
||||||
TEST_ASSERT(fd >= 0);
|
TEST_ASSERT(fd >= 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user