igt/kms_flip/nonblocking_read: Demonstrate that O_NONBLOCK is a myth

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 3cccfdf..901f013 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -1513,6 +1513,28 @@
 	}
 }
 
+static void test_nonblocking_read(int in)
+{
+	char buffer[1024];
+	int fd = dup(in);
+	int ret;
+
+	ret = -1;
+	if (fd != -1)
+		ret = fcntl(fd, F_GETFL);
+	if (ret != -1) {
+		ret |= O_NONBLOCK;
+		ret = fcntl(fd, F_SETFL, ret);
+	}
+	igt_require(ret != -1);
+
+	ret = read(fd, buffer, sizeof(buffer));
+	igt_assert_eq(ret, -1);
+	igt_assert_eq(errno, EAGAIN);
+
+	close(fd);
+}
+
 int main(int argc, char **argv)
 {
 	struct {
@@ -1603,6 +1625,9 @@
 		batch = intel_batchbuffer_alloc(bufmgr, devid);
 	}
 
+	igt_subtest("nonblocking-read")
+		test_nonblocking_read(drm_fd);
+
 	for (i = 0; i < sizeof(tests) / sizeof (tests[0]); i++) {
 		igt_subtest(tests[i].name)
 			run_test(tests[i].duration, tests[i].flags);