pty/pty07: Restore active console after the testrun
PATCH 1/1 pty/pty07: Restore active console after the testrun
The test, as a side effect, switches to a different console during the run, which may confuse both users and automated test systems.
Fix that by saving the console active at the start of the test and restore it in the test cleanup.
--- testcases/kernel/pty/pty07.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
testcases/kernel/pty/pty07.c +15 -2
@@ -40,6 +40,8 @@ static int test_tty_port = 8;static int fd =-1 ;static struct tst_fzsync_pair fzp; +static unsigned short vt_active; +static void *open_close (void *unused) {int i;
@@ -76,16 +78,27 @@ static void do_test(void)static void setup (void ) { +struct vt_stat stat; +sprintf (tty_path,"/dev/tty%d" , test_tty_port); fd =SAFE_OPEN (tty_path,O_RDWR ); +SAFE_IOCTL (fd,VT_GETSTATE , &stat); + vt_active = stat.v_active; + +tst_res (TINFO ,"Saving active console %i" , vt_active); +tst_fzsync_pair_init (&fzp); }static void cleanup (void ) { -tst_fzsync_pair_cleanup (&fzp); -if (fd >=0 ) +if (fd >=0 ) { +tst_res (TINFO ,"Restoring active console" ); +SAFE_IOCTL (fd,VT_ACTIVATE , vt_active);SAFE_CLOSE (fd); + } + +tst_fzsync_pair_cleanup (&fzp); }static struct tst_test test = {
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi,
Quoted 41 lines · Cyril Hrubis
The test, as a side effect, switches to a different console during the run, which may confuse both users and automated test systems.
Fix that by saving the console active at the start of the test and restore it in the test cleanup.
Signed-off-by Cyril Hrubis <[email protected]>--- testcases/kernel/pty/pty07.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)testcases/kernel/pty/pty07.c +9
-0@@ -40,6 +40,8 @@ static int test_tty_port = 8;static int fd =-1 ;static struct tst_fzsync_pair fzp; +static unsigned short vt_active; +static void *open_close (void *unused) {int i;@@ -76,16 +78,27 @@ static void do_test(void)static void setup (void ) { +struct vt_stat stat; +sprintf (tty_path,"/dev/tty%d" , test_tty_port); fd =SAFE_OPEN (tty_path,O_RDWR ); +SAFE_IOCTL (fd,VT_GETSTATE , &stat); + vt_active = stat.v_active; + +tst_res (TINFO ,"Saving active console %i" , vt_active); +tst_fzsync_pair_init (&fzp); }static void cleanup (void )
testcases/kernel/pty/pty07.c static void do_test(void) · line 101
Quoted 10 lines
testcases/kernel/pty/pty07.c +6
-2{ -tst_fzsync_pair_cleanup (&fzp); -if (fd >=0 ) +if (fd >=0 ) { +tst_res (TINFO ,"Restoring active console" ); +SAFE_IOCTL (fd,VT_ACTIVATE , vt_active);SAFE_CLOSE (fd); + } + +tst_fzsync_pair_cleanup (&fzp);
If you move the fzsync cleanup to the end of cleanup(), you can end up with the open_close() thread racing against fd cleanup.
Quoted 3 lines
testcases/kernel/pty/pty07.c +0
-0}static struct tst_test test = {
Signature · 10 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 6 lines
Quoted 6 lines
static void cleanup(void)
{testcases/kernel/pty/pty07.c +2
-2-tst_fzsync_pair_cleanup (&fzp); -if (fd >=0 ) +if (fd >=0 ) { +tst_res (TINFO ,"Restoring active console" );
Quoted 8 lines
testcases/kernel/pty/pty07.c static void do_test(void) · line 101
Quoted 5 lines
testcases/kernel/pty/pty07.c +4
-0+SAFE_IOCTL (fd,VT_ACTIVATE , vt_active);SAFE_CLOSE (fd); + } + +tst_fzsync_pair_cleanup (&fzp);If you move the fzsync cleanup to the end of
cleanup(), you can end up with theopen_close()thread racing against fd cleanup.
Ah, right, looking closely at the fzsync, the thread B may be racing against the restoration in the case that something caused premature exit in the thread A.
Will move the call back to the start of the cleanup().
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hello,
Quoted 16 lines · Cyril Hrubis
Hi!
Quoted 6 lines
Quoted 6 lines
static void cleanup(void)
{testcases/kernel/pty/pty07.c +2
-2-tst_fzsync_pair_cleanup (&fzp); -if (fd >=0 ) +if (fd >=0 ) { +tst_res (TINFO ,"Restoring active console" );Quoted 8 lines
testcases/kernel/pty/pty07.c static void do_test(void) · line 101
Quoted 5 lines
testcases/kernel/pty/pty07.c +4
-0+SAFE_IOCTL (fd,VT_ACTIVATE , vt_active);SAFE_CLOSE (fd); + } + +tst_fzsync_pair_cleanup (&fzp);If you move the fzsync cleanup to the end of
cleanup(), you can end up with theopen_close()thread racing against fd cleanup.
Quoted 9 lines
Ah, right, looking closely at the fzsync, the thread B may be racing against the restoration in the case that something caused premature exit in the thread A.
Will move the call back to the start of the
cleanup().Signature · 2 lines
Cyril Hrubis [email protected]
Why are we using /dev/tty8 instead of allocating a pty with /dev/ptmx?
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 11 lines
Quoted 9 lines
Ah, right, looking closely at the fzsync, the thread B may be racing against the restoration in the case that something caused premature exit in the thread A.
Will move the call back to the start of the
cleanup().Signature · 2 lines
Cyril Hrubis [email protected]Why are we using
/dev/tty8instead of allocating a pty with/dev/ptmx?
I do not think that we can VT_ACTIVATE on pseudoterminals, as far as I can tell we have to have real console for that.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Richard Palethorpe
Reviewed-byQuoted 7 lines · Cyril Hrubis
Hi!
Quoted 6 lines
Quoted 6 lines
Ah, right, looking closely at the fzsync, the thread B may be racing against the restoration in the case that something caused premature exit in the thread A.
Will move the call back to the start of the
cleanup().
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Signature · 2 lines
Cyril Hrubis [email protected]Why are we using
/dev/tty8instead of allocating a pty with/dev/ptmx?I do not think that we can
VT_ACTIVATEon pseudoterminals, as far as I can tell we have to have real console for that.
OK, this looks good then.
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Applied with the change requested by Martin.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp