@@ -1067,13 +1067,21 @@ t_testbed_dev_access(UMockdevTestbedFixture * fixture, gconstpointer data)
10671067 close (fd );
10681068 }
10691069
1070- /* open() with O_TMPFILE */
1071- 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 );
1070+ /* open() with O_TMPFILE; this hasn't been supported in Linux for very long
1071+ * (>= 3.11), so check that it works in the testbed only if it also works
1072+ * in the "normal" file system. */
1073+ fd = g_open ("/tmp" , O_TMPFILE |O_RDWR , 0644 );
1074+ if (fd >= 0 ) {
1075+ close (fd );
1076+ errno = 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, not supported on this kernel: %m) " );
1084+ }
10771085
10781086 g_free (devdir );
10791087}
0 commit comments