Skip to contentSkip to conversation

kernel/pty06: Skip test when TTY not available

PATCH In review Bogdan Lezhepekov 3 participants 4 messages Mar 11, 2022 – Apr 11, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel/pty06: Skip test when TTY not available

Since TTYs under test are hardcoded, they
might not be available in some systems.

---
 testcases/kernel/pty/pty06.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
testcases/kernel/pty/pty06.c +6 -3
index b621f584f..250c38f6b 100644
@@ -45,8 +45,6 @@ static struct tst_fzsync_pair fzp;
 
 static void *open_close(void *unused)
 {
-	sprintf(tty_path_b, "/dev/tty%d", test_tty_port);
-
 	while (tst_fzsync_run_b(&fzp)) {
 		tst_fzsync_start_race_b(&fzp);
 		int fd = SAFE_OPEN(tty_path_b, O_RDWR);
@@ -60,7 +58,6 @@ static void *open_close(void *unused)
 
 static void do_test(void)
 {
-	sprintf(tty_path_a, "/dev/tty%d", test_tty_port + 1);
 	int fd = SAFE_OPEN(tty_path_a, O_RDWR);
 
 	tst_fzsync_pair_reset(&fzp, open_close);
@@ -80,6 +77,12 @@ static void do_test(void)
 
 static void setup(void)
 {
+	sprintf(tty_path_a, "/dev/tty%d", test_tty_port + 1);
+	sprintf(tty_path_b, "/dev/tty%d", test_tty_port);
+
+	if (access(tty_path_a, F_OK) != 0 || access(tty_path_b, F_OK) != 0)
+		tst_brk(TCONF, "TTY(s) under test not available in system");
+
 	tst_fzsync_pair_init(&fzp);
 }
 
Signature · 5 lines
2.35.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi!

Quoted 2 lines

Since TTYs under test are hardcoded, they
might not be available in some systems.

Is the system you are running the tests on completely without ttys?

Quoted 27 lines
---
 testcases/kernel/pty/pty06.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
testcases/kernel/pty/pty06.c +0 -3
index b621f584f..250c38f6b 100644
@@ -45,8 +45,6 @@ static struct tst_fzsync_pair fzp;
 
 static void *open_close(void *unused)
 {
-	sprintf(tty_path_b, "/dev/tty%d", test_tty_port);
-
 	while (tst_fzsync_run_b(&fzp)) {
 		tst_fzsync_start_race_b(&fzp);
 		int fd = SAFE_OPEN(tty_path_b, O_RDWR);
@@ -60,7 +58,6 @@ static void *open_close(void *unused)
 
 static void do_test(void)
 {
-	sprintf(tty_path_a, "/dev/tty%d", test_tty_port + 1);
 	int fd = SAFE_OPEN(tty_path_a, O_RDWR);
 
 	tst_fzsync_pair_reset(&fzp, open_close);

testcases/kernel/pty/pty06.c static void do_test(void) · line 84

Quoted 8 lines
testcases/kernel/pty/pty06.c +5 -0
@@ -80,6 +77,12 @@ static void do_test(void)
 
 static void setup(void)
 {
+	sprintf(tty_path_a, "/dev/tty%d", test_tty_port + 1);
+	sprintf(tty_path_b, "/dev/tty%d", test_tty_port);
+
+	if (access(tty_path_a, F_OK) != 0 || access(tty_path_b, F_OK) != 0)
+		tst_brk(TCONF, "TTY(s) under test not available in system");

There is no need for the != 0 could be simplified just to:

	if (access(...) || access(...))
		tst_brk(TCONF, ...);
Quoted 9 lines
testcases/kernel/pty/pty06.c +0 -0
 	tst_fzsync_pair_init(&fzp);
 }
 
Signature · 5 lines
2.35.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
Quoted 44 lines · Cyril Hrubis

Hi!

Quoted 2 lines

Since TTYs under test are hardcoded, they
might not be available in some systems.

Is the system you are running the tests on completely without ttys?

Quoted 27 lines
---
 testcases/kernel/pty/pty06.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
testcases/kernel/pty/pty06.c +0 -3
index b621f584f..250c38f6b 100644
@@ -45,8 +45,6 @@ static struct tst_fzsync_pair fzp;
 
 static void *open_close(void *unused)
 {
-	sprintf(tty_path_b, "/dev/tty%d", test_tty_port);
-
 	while (tst_fzsync_run_b(&fzp)) {
 		tst_fzsync_start_race_b(&fzp);
 		int fd = SAFE_OPEN(tty_path_b, O_RDWR);
@@ -60,7 +58,6 @@ static void *open_close(void *unused)
 
 static void do_test(void)
 {
-	sprintf(tty_path_a, "/dev/tty%d", test_tty_port + 1);
 	int fd = SAFE_OPEN(tty_path_a, O_RDWR);
 
 	tst_fzsync_pair_reset(&fzp, open_close);

testcases/kernel/pty/pty06.c static void do_test(void) · line 84

Quoted 8 lines
testcases/kernel/pty/pty06.c +5 -0
@@ -80,6 +77,12 @@ static void do_test(void)
 
 static void setup(void)
 {
+	sprintf(tty_path_a, "/dev/tty%d", test_tty_port + 1);
+	sprintf(tty_path_b, "/dev/tty%d", test_tty_port);
+
+	if (access(tty_path_a, F_OK) != 0 || access(tty_path_b, F_OK) != 0)
+		tst_brk(TCONF, "TTY(s) under test not available in system");

There is no need for the != 0 could be simplified just to:

Quoted 12 lines
	if (access(...) || access(...))
		tst_brk(TCONF, ...);
Quoted 9 lines
testcases/kernel/pty/pty06.c +0 -1
 	tst_fzsync_pair_init(&fzp);
 }
 
--

2.35.1

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Hi Cyril,

Sorry for the delayed reply. I see the test requires an emulated terminal (ttyX), whilst our system supports serial console only (ttySX).

What would be your recommendation, does it make sense to switch to ttySX? I wasn't sure about it, so disabling seemed more logical.

Thanks,
Bogdan

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw

Hello Bogdan,

Quoted 49 lines · blezhepekov
Quoted 37 lines · Cyril Hrubis

Hi!

Quoted 2 lines

Since TTYs under test are hardcoded, they
might not be available in some systems.

Is the system you are running the tests on completely without ttys?

Quoted 24 lines
---
 testcases/kernel/pty/pty06.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
testcases/kernel/pty/pty06.c +0 -3
index b621f584f..250c38f6b 100644
@@ -45,8 +45,6 @@ static struct tst_fzsync_pair fzp;
 static void *open_close(void *unused)
 {
-	sprintf(tty_path_b, "/dev/tty%d", test_tty_port);
-
 	while (tst_fzsync_run_b(&fzp)) {
 		tst_fzsync_start_race_b(&fzp);
 		int fd = SAFE_OPEN(tty_path_b, O_RDWR);
@@ -60,7 +58,6 @@ static void *open_close(void *unused)
 static void do_test(void)
 {
-	sprintf(tty_path_a, "/dev/tty%d", test_tty_port + 1);
 	int fd = SAFE_OPEN(tty_path_a, O_RDWR);
 	tst_fzsync_pair_reset(&fzp, open_close);

testcases/kernel/pty/pty06.c static void do_test(void) · line 83

Quoted 7 lines
testcases/kernel/pty/pty06.c +5 -0
@@ -80,6 +77,12 @@ static void do_test(void)
 static void setup(void)
 {
+	sprintf(tty_path_a, "/dev/tty%d", test_tty_port + 1);
+	sprintf(tty_path_b, "/dev/tty%d", test_tty_port);
+
+	if (access(tty_path_a, F_OK) != 0 || access(tty_path_b, F_OK) != 0)
+		tst_brk(TCONF, "TTY(s) under test not available in system");

There is no need for the != 0 could be simplified just to:

Quoted 10 lines
	if (access(...) || access(...))
		tst_brk(TCONF, ...);
Quoted 7 lines
testcases/kernel/pty/pty06.c +0 -1
 	tst_fzsync_pair_init(&fzp);
 }
--

2.35.1

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Quoted 8 lines

Hi Cyril,

Sorry for the delayed reply. I see the test requires an emulated terminal (ttyX), whilst our system supports serial console only (ttySX).

What would be your recommendation, does it make sense to switch to ttySX? I wasn't sure about it, so disabling seemed more logical.

No, I think this only applies to graphical VTs. I'm not sure if it is possible to create one on a system without real graphics.

Unless someone has an answer to the above, I think it is enough for now to address Cyril's access comments and post a V2.

Quoted 3 lines

Thanks,
Bogdan

Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp