void run_test(int max_ios, int getevents_type)
{
- int fd, ret;
+ int fd, ret, flags;
long i, to_submit;
struct iocb **iocb_sub;
io_context_t io_ctx;
events = calloc(max_ios, sizeof(*events));
unlink(filename);
- fd = open(filename, O_CREAT | O_RDWR | O_DIRECT, 0644);
+ fd = open(filename, O_CREAT | O_RDWR, 0644);
assert(fd >= 0);
+ /*
+ * Use O_DIRECT if it's available. If it's not, the test code
+ * will still operate correctly, just potentially slower.
+ */
+ flags = fcntl(fd, F_GETFL, 0);
+ fcntl(fd, F_SETFL, flags | O_DIRECT);
+
ret = ftruncate(fd, max_ios * io_size);
assert(!ret);
assert(buffer != NULL);
fd = open(FILENAME, O_DIRECT|O_RDONLY);
+ if (fd < 0 && errno == EINVAL)
+ exit(3); /* skip this test, O_DIRECT is unavailable */
assert(fd >= 0);
for (i = 0; i < 1000; i++) {
int
open_temp_file(void)
{
- int fd;
+ int fd, flags;
char template[sizeof(TEMPLATE)];
strncpy(template, TEMPLATE, sizeof(template));
- fd = mkostemp(template, O_DIRECT);
+ fd = mkstemp(template);
if (fd < 0) {
perror("mkstemp");
exit(1);
}
+ /*
+ * O_DIRECT is desirable, but not required for this test.
+ */
+ flags = fcntl(F_GETFL, 0);
+ fcntl(F_SETFL, flags | O_DIRECT);
+
unlink(template);
return fd;
}
*/
flags = fcntl(fd, F_GETFL);
ret = fcntl(fd, F_SETFL, flags | O_DIRECT);
- if (ret != 0) {
+ if (ret < 0) {
+ /* SKIP this test if O_DIRECT is not available on this fs */
+ if (errno == EINVAL)
+ return 3;
perror("fcntl");
return 1;
}