summaryrefslogtreecommitdiffstats
path: root/src/test/test_cfuse_cache_invalidate.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/test/test_cfuse_cache_invalidate.cc
parentInitial commit. (diff)
downloadceph-upstream/16.2.11+ds.tar.xz
ceph-upstream/16.2.11+ds.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/test_cfuse_cache_invalidate.cc')
-rw-r--r--src/test/test_cfuse_cache_invalidate.cc54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/test/test_cfuse_cache_invalidate.cc b/src/test/test_cfuse_cache_invalidate.cc
new file mode 100644
index 000000000..4b45cb39c
--- /dev/null
+++ b/src/test/test_cfuse_cache_invalidate.cc
@@ -0,0 +1,54 @@
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "include/ceph_assert.h"
+
+#define REGION 1048576
+int main(int argc, char *argv[]) {
+
+ pid_t p = fork();
+ char buf[REGION];
+ memset(buf, 0, sizeof(buf));
+
+ if (p != 0) {
+ int done = 0;
+ int fd = open(argv[1], O_RDWR|O_CREAT, 0644);
+ if (fd < 0) {
+ perror(argv[1]);
+ return 1;
+ }
+
+ int i = 0;
+ while(!done) {
+ printf("writing %d\n", i++);
+ ceph_assert(pwrite(fd, buf, REGION, 0) == REGION);
+ int status;
+ int ret = waitpid(p, &status, WNOHANG);
+ ceph_assert(ret >= 0);
+ if (ret > 0) {
+ done = 1;
+ }
+ }
+ close(fd);
+ } else {
+ sleep(1);
+ int fd = open(argv[2], O_RDONLY, 0644);
+ if (fd < 0) {
+ perror(argv[2]);
+ return 1;
+ }
+
+ printf("reading\n");
+ ceph_assert(pread(fd, buf, REGION, 0) == REGION);
+ close(fd);
+ }
+
+ return 0;
+}