Feature #659
direct io unit test
% Done:
0%
Source:
Tags:
Backport:
Reviewed:
Affected Versions:
Pull request ID:
Description
For qa/workunits:
Test directio reads and writes where
- the file offset is 512-byte and not page aligned
- the buffer offset is 512-byte and not page aligned
and verify that the correct offset was read/written.
The test program should return a success or error code, and some useful output to identify which case(s) work or don't work.
The tcloud guys sent this, fwiw:
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <fcntl.h> #include <string.h> int main(int argc, char *argv[]) { int i; int n = 0; void *buf = 0; int fd = open(argv[1], O_RDONLY | O_DIRECT); if (fd < 0) { printf("file open error %d\n", errno); return -1; } n = lseek(fd, 0, SEEK_END); printf("seek %d\n", n); n = lseek(fd, 0, SEEK_CUR); printf("seek %d\n", n); n = lseek(fd, 6656, SEEK_SET); printf("seek %d\n", n); n = posix_memalign(&buf, 512, 8192); printf("posix_memalign ret %d buf %p\n", n, buf); memset(buf, 0, n); n = read(fd, buf, 8192); printf("read %d bytes (err %d)\n", n, errno); char* buf1 = (char*)buf; for (i = 0; i < n; ++i) printf("%c", buf1[i]); printf("\n"); free(buf); close(fd); return 0; }
History
#1 Updated by Colin McCabe about 13 years ago
- Status changed from New to Resolved
I added direct_io_test for testing this feature. f1d7af97f3a30d2ecdd0e48f804d8347d319f3eb, 42709d1bff91bf7f692ca124520e6782c5278811, 6a20b83a6393b122279b638ee5345fe58e87de3a.