diff options
author | Damien Lespiau <damien.lespiau@intel.com> | 2014-02-06 21:06:07 +0000 |
---|---|---|
committer | Damien Lespiau <damien.lespiau@intel.com> | 2014-02-11 13:50:16 +0000 |
commit | 377f48afe668fc118d6dd902641a1c41c4430b44 (patch) | |
tree | aa33c142bd6834d86cf845333a4a862bf0423fb6 | |
parent | c7e3413a081aa7fb2b9f4de5b99c64802b649392 (diff) |
lib: Add a helper to wait for a keypress
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
-rw-r--r-- | lib/drmtest.c | 13 | ||||
-rw-r--r-- | lib/drmtest.h | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c index 2718de4d..24362bd4 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" @@ -1704,3 +1705,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 f945a7eb..8dd9f790 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -362,4 +362,6 @@ void igt_system_suspend_autoresume(void); /* dropping priviledges */ void igt_drop_root(void); +void igt_wait_for_keypress(void); + #endif /* DRMTEST_H */ |