diff options
author | Sam Lang <sam.lang@inktank.com> | 2012-09-28 19:13:51 +0200 |
---|---|---|
committer | Sam Lang <sam.lang@inktank.com> | 2012-10-03 18:38:11 +0200 |
commit | 68fbbea234b75728fd3437f7ee7bbbaa79977d78 (patch) | |
tree | e6656458672c557f30114d9675fe2d8385732738 /src/test/test_cfuse_cache_invalidate.cc | |
parent | doc: update release-process.rst (diff) | |
download | ceph-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/test/test_cfuse_cache_invalidate.cc')
-rw-r--r-- | src/test/test_cfuse_cache_invalidate.cc | 44 |
1 files changed, 44 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 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; +} |