mirror of https://github.com/FreeRDP/FreeRDP
Add test to check that handle_signals resets the terminal
This commit is contained in:
parent
48f474316d
commit
5aea0e2e0c
|
@ -35,6 +35,7 @@
|
|||
#include <freerdp/utils/wait_obj.h>
|
||||
#include <freerdp/utils/args.h>
|
||||
#include <freerdp/utils/passphrase.h>
|
||||
#include <freerdp/utils/signal.h>
|
||||
|
||||
#include "test_utils.h"
|
||||
|
||||
|
@ -58,6 +59,7 @@ int add_utils_suite(void)
|
|||
add_test_function(wait_obj);
|
||||
add_test_function(args);
|
||||
add_test_function(passphrase_read);
|
||||
add_test_function(handle_signals);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -629,3 +631,41 @@ void test_passphrase_read(void)
|
|||
passphrase_read_prompts_to_stderr_when_no_tty();
|
||||
passphrase_read_reads_from_stdin_when_no_tty();
|
||||
}
|
||||
|
||||
void handle_signals_resets_terminal(void)
|
||||
{
|
||||
int status, masterfd;
|
||||
char* slavedevice;
|
||||
struct termios test_flags;
|
||||
|
||||
masterfd = posix_openpt(O_RDWR|O_NOCTTY);
|
||||
|
||||
if (masterfd == -1
|
||||
|| grantpt (masterfd) == -1
|
||||
|| unlockpt (masterfd) == -1
|
||||
|| (slavedevice = ptsname (masterfd)) == NULL)
|
||||
CU_FAIL_FATAL("Could not create pty");
|
||||
|
||||
terminal_fildes = open(slavedevice, O_RDWR|O_NOCTTY);
|
||||
tcgetattr(terminal_fildes, &orig_flags);
|
||||
new_flags = orig_flags;
|
||||
new_flags.c_lflag &= ~ECHO;
|
||||
tcsetattr(terminal_fildes, TCSANOW, &new_flags);
|
||||
terminal_needs_reset = 1;
|
||||
|
||||
if(fork() == 0)
|
||||
{
|
||||
freerdp_handle_signals();
|
||||
raise(SIGINT);
|
||||
}
|
||||
wait(&status);
|
||||
tcgetattr(terminal_fildes, &test_flags);
|
||||
CU_ASSERT_EQUAL(orig_flags.c_lflag, test_flags.c_lflag);
|
||||
close(masterfd);
|
||||
close(terminal_fildes);
|
||||
}
|
||||
|
||||
void test_handle_signals(void)
|
||||
{
|
||||
handle_signals_resets_terminal();
|
||||
}
|
||||
|
|
|
@ -29,3 +29,4 @@ void test_load_plugin(void);
|
|||
void test_wait_obj(void);
|
||||
void test_args(void);
|
||||
void test_passphrase_read(void);
|
||||
void test_handle_signals(void);
|
||||
|
|
Loading…
Reference in New Issue