]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-fuse: Test for fuse cache issue (#2215)
authorSam Lang <sam.lang@inktank.com>
Fri, 28 Sep 2012 17:13:51 +0000 (10:13 -0700)
committerSam Lang <sam.lang@inktank.com>
Wed, 3 Oct 2012 16:38:11 +0000 (11:38 -0500)
Signed-off-by: Sam Lang <sam.lang@inktank.com>
src/Makefile.am
src/test/test_cfuse_cache_invalidate.cc [new file with mode: 0644]

index 9ad7ca0665f67ffd5dafddc09519668a3a91bed6..1c2018d8a3b07cc2496c5ab5eecad2b4452aa0f5 100644 (file)
@@ -925,6 +925,11 @@ test_keyvaluedb_iterators_LDADD =  ${UNITTEST_STATIC_LDADD} $(LIBOS_LDA) $(LIBGL
 test_keyvaluedb_iterators_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} $(LEVELDB_INCLUDE)
 bin_DEBUGPROGRAMS += test_keyvaluedb_iterators
 
+test_cfuse_cache_invalidate_SOURCES = test/test_cfuse_cache_invalidate.cc
+test_cfuse_cache_invalidate_LDFLAGS = ${AM_LDFLAGS}
+test_cfuse_cache_invalidate_LDADD =
+test_cfuse_cache_invalidate_CXXFLAGS = ${AM_CXXFLAGS}
+bin_DEBUGPROGRAMS += test_cfuse_cache_invalidate
 
 # shell scripts
 editpaths = sed \
diff --git a/src/test/test_cfuse_cache_invalidate.cc b/src/test/test_cfuse_cache_invalidate.cc
new file mode 100644 (file)
index 0000000..418f835
--- /dev/null
@@ -0,0 +1,44 @@
+
+#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 <assert.h>
+
+#define REGION 1048576
+int main(int argc, char *argv[]) {
+
+  pid_t p = fork();
+  char buf[REGION];
+
+  if (p != 0) {
+    int done = 0;
+    int fd = open(argv[1], O_RDWR|O_CREAT, 0644);
+    if (fd < 0) perror(argv[1]);
+
+    int i = 0;
+    while(!done) {
+      printf("writing %d\n", i++);
+      assert(pwrite(fd, buf, REGION, 0) == REGION);
+      int status;
+      int ret = waitpid(p, &status, WNOHANG);
+      assert(ret >= 0);
+      if (ret > 0) {
+       done = 1;
+      }
+    }
+    close(fd);
+  } else {
+    sleep(1);
+    int fd = open(argv[2], O_RDONLY, 0644);
+    printf("reading\n");
+    assert(pread(fd, buf, REGION, 0) == REGION);
+    close(fd);
+  }
+
+  return 0;
+}