]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: add short directio read test
authorSage Weil <sage.weil@dreamhost.com>
Fri, 10 Jun 2011 04:53:28 +0000 (21:53 -0700)
committerSage Weil <sage@newdream.net>
Mon, 13 Jun 2011 20:22:06 +0000 (13:22 -0700)
This tests for the bug fixed by linux commit:c3cd628.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
qa/src/Makefile.am
qa/src/test_short_dio_read.c [new file with mode: 0644]
qa/workunits/direct_io.sh

index 6f74c0c2979277470fa379147af984051ac380bd..56e7a3d7d20bf4a6e16e33f788604abdab7122a9 100644 (file)
@@ -5,7 +5,8 @@ bin_PROGRAMS =
 
 direct_io_test_SOURCES = direct_io_test.c
 test_sync_io_SOURCES = test_sync_io.c
+test_short_dio_read_SOURCES = test_short_dio_read.c
 
 if WITH_DEBUG
-bin_PROGRAMS += direct_io_test test_sync_io
+bin_PROGRAMS += direct_io_test test_sync_io test_short_dio_read
 endif
diff --git a/qa/src/test_short_dio_read.c b/qa/src/test_short_dio_read.c
new file mode 100644 (file)
index 0000000..d63f9f5
--- /dev/null
@@ -0,0 +1,29 @@
+#define _GNU_SOURCE
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+        char buf[409600];
+        int fd = open(argv[1], O_WRONLY|O_CREAT);
+        ssize_t r;
+
+       printf("writing first 3 bytes of 10k file\n");
+        write(fd, "foo", 3);
+        ftruncate(fd, 10000);
+        fsync(fd);
+        close(fd);
+
+       printf("reading O_DIRECT\n");
+        fd = open(argv[1], O_RDONLY|O_DIRECT);
+        r = read(fd, buf, sizeof(buf));
+        close(fd);
+
+        printf("got %d\n", r);
+       if (r != 10000)
+               return 1;
+        return 0;
+}
index e333344274c77d73fb2517618ac47618bed17b20..7d2acc7f3d7bbc6058be7b36bdbbfcd84f37b511 100755 (executable)
@@ -2,6 +2,8 @@
 
 direct_io_test
 
+test_short_dio_read
+
 # a few test cases from henry
 echo "test read from hole"
 dd if=/dev/zero of=dd3 bs=1 seek=1048576 count=0