lib: Add a helper to wait for a keypress

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
This commit is contained in:
Damien Lespiau 2014-02-06 21:06:07 +00:00
parent c7e3413a08
commit 377f48afe6
2 changed files with 15 additions and 0 deletions

View File

@ -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 );
}

View File

@ -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 */