[Intel-gfx] [PATCH igt 23/28] lib: Add a helper to wait for a keypress

Damien Lespiau damien.lespiau at intel.com
Fri Feb 7 15:49:07 CET 2014


Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 lib/drmtest.c | 13 +++++++++++++
 lib/drmtest.h |  2 ++
 2 files changed, 15 insertions(+)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index f7262d7..f0635d3 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -46,6 +46,7 @@
 #include <sys/types.h>
 #include <sys/syscall.h>
 #include <sys/utsname.h>
+#include <termios.h>
 
 #include "drmtest.h"
 #include "i915_drm.h"
@@ -1687,3 +1688,15 @@ void igt_drop_root(void)
 	igt_assert(getgid() == 2);
 	igt_assert(getuid() == 2);
 }
+
+void igt_wait_for_keypress(void)
+{
+	struct termios oldt, newt;
+
+	tcgetattr ( STDIN_FILENO, &oldt );
+	newt = oldt;
+	newt.c_lflag &= ~( ICANON | ECHO );
+	tcsetattr ( STDIN_FILENO, TCSANOW, &newt );
+	getchar();
+	tcsetattr ( STDIN_FILENO, TCSANOW, &oldt );
+}
diff --git a/lib/drmtest.h b/lib/drmtest.h
index d42a6f7..af68ee8 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -361,4 +361,6 @@ void igt_system_suspend_autoresume(void);
 /* dropping priviledges */
 void igt_drop_root(void);
 
+void igt_wait_for_keypress(void);
+
 #endif /* DRMTEST_H */
-- 
1.8.3.1




More information about the Intel-gfx mailing list