|
30 | 30 | #include <sys/ioctl.h> |
31 | 31 | #include <sys/socket.h> |
32 | 32 | #include <sys/un.h> |
| 33 | +#include <sys/utsname.h> |
33 | 34 | #include <linux/usbdevice_fs.h> |
34 | 35 | #include <linux/input.h> |
35 | 36 |
|
@@ -1000,6 +1001,7 @@ t_testbed_dev_access(UMockdevTestbedFixture * fixture, gconstpointer data) |
1000 | 1001 | gchar *devdir, *devpath; |
1001 | 1002 | int fd; |
1002 | 1003 | char buf[100]; |
| 1004 | + struct utsname uts; |
1003 | 1005 |
|
1004 | 1006 | /* no mocked devices */ |
1005 | 1007 | g_assert_cmpint(g_open("/dev/wishyouwerehere", O_RDONLY, 0), ==, -1); |
@@ -1067,13 +1069,19 @@ t_testbed_dev_access(UMockdevTestbedFixture * fixture, gconstpointer data) |
1067 | 1069 | close(fd); |
1068 | 1070 | } |
1069 | 1071 |
|
1070 | | - /* open() with O_TMPFILE */ |
| 1072 | + /* open() with O_TMPFILE (Linux >= 3.11) */ |
1071 | 1073 | errno = 0; |
1072 | | - fd = g_open("/dev", O_TMPFILE|O_RDWR, 0644); |
1073 | | - g_assert_cmpint(errno, ==, 0); |
1074 | | - g_assert_cmpint(fd, >, 0); |
1075 | | - g_assert_cmpint(write(fd, "hello", 5), ==, 5); |
1076 | | - close(fd); |
| 1074 | + g_assert_cmpint(uname(&uts), ==, 0); |
| 1075 | + |
| 1076 | + if (strncmp(uts.release, "3.11", 4) >= 0) { |
| 1077 | + fd = g_open("/dev", O_TMPFILE|O_RDWR, 0644); |
| 1078 | + g_assert_cmpint(errno, ==, 0); |
| 1079 | + g_assert_cmpint(fd, >, 0); |
| 1080 | + g_assert_cmpint(write(fd, "hello", 5), ==, 5); |
| 1081 | + close(fd); |
| 1082 | + } else { |
| 1083 | + g_printf("(Skipping O_TMPFILE test, Linux version %s too old) ", uts.release); |
| 1084 | + } |
1077 | 1085 |
|
1078 | 1086 | g_free(devdir); |
1079 | 1087 | } |
|
0 commit comments