summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSam Lang <sam.lang@inktank.com>2012-09-28 19:13:51 +0200
committerSam Lang <sam.lang@inktank.com>2012-10-03 18:38:11 +0200
commit68fbbea234b75728fd3437f7ee7bbbaa79977d78 (patch)
treee6656458672c557f30114d9675fe2d8385732738 /src
parentdoc: update release-process.rst (diff)
downloadceph-68fbbea234b75728fd3437f7ee7bbbaa79977d78.tar.xz
ceph-68fbbea234b75728fd3437f7ee7bbbaa79977d78.zip
ceph-fuse: Test for fuse cache issue (#2215)
Signed-off-by: Sam Lang <sam.lang@inktank.com>
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am5
-rw-r--r--src/test/test_cfuse_cache_invalidate.cc44
2 files changed, 49 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 9ad7ca0665f..1c2018d8a3b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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
index 00000000000..418f8351e13
--- /dev/null
+++ b/src/test/test_cfuse_cache_invalidate.cc
@@ -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;
+}