Skip to content

Commit

Permalink
Skip O_TMPFILE test on Linux versions < 3.11
Browse files Browse the repository at this point in the history
There it fails with EISDIR.
  • Loading branch information
martinpitt committed Sep 22, 2014
1 parent 4d502d2 commit 2c6efd0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.8.8 (UNRELEASED)
------------------
- Skip O_TMPFILE test on Linux versions < 3.11.

0.8.7 (2014-09-19)
------------------
- /umockdev-run/integration/input-evtest-evemu test: Be more liberal in parsing
Expand Down
20 changes: 14 additions & 6 deletions tests/test-umockdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/utsname.h>
#include <linux/usbdevice_fs.h>
#include <linux/input.h>

Expand Down Expand Up @@ -1000,6 +1001,7 @@ t_testbed_dev_access(UMockdevTestbedFixture * fixture, gconstpointer data)
gchar *devdir, *devpath;
int fd;
char buf[100];
struct utsname uts;

/* no mocked devices */
g_assert_cmpint(g_open("/dev/wishyouwerehere", O_RDONLY, 0), ==, -1);
Expand Down Expand Up @@ -1067,13 +1069,19 @@ t_testbed_dev_access(UMockdevTestbedFixture * fixture, gconstpointer data)
close(fd);
}

/* open() with O_TMPFILE */
/* open() with O_TMPFILE (Linux >= 3.11) */
errno = 0;
fd = g_open("/dev", O_TMPFILE|O_RDWR, 0644);
g_assert_cmpint(errno, ==, 0);
g_assert_cmpint(fd, >, 0);
g_assert_cmpint(write(fd, "hello", 5), ==, 5);
close(fd);
g_assert_cmpint(uname(&uts), ==, 0);

if (strncmp(uts.release, "3.11", 4) >= 0) {
fd = g_open("/dev", O_TMPFILE|O_RDWR, 0644);
g_assert_cmpint(errno, ==, 0);
g_assert_cmpint(fd, >, 0);
g_assert_cmpint(write(fd, "hello", 5), ==, 5);
close(fd);
} else {
g_printf("(Skipping O_TMPFILE test, Linux version %s too old) ", uts.release);
}

g_free(devdir);
}
Expand Down

0 comments on commit 2c6efd0

Please sign in to comment.