Skip to contentSkip to conversation

openposix: make use of tst_process_state_wait3

PATCH New Li Wang 2 participants 3 messages Sep 7, 2021 – Sep 8, 2021

lore
Share & tools
lore

Li Wang

author
#0 lore raw

PATCH 1/1 openposix: make use of tst_process_state_wait3

Replaces that sleep 1 sec with a wait until child process state changes to 'S' (sleeping).

---
 .../conformance/interfaces/clock_nanosleep/1-3.c               | 3 ++-
 .../conformance/interfaces/clock_nanosleep/1-4.c               | 3 ++-
 .../conformance/interfaces/clock_nanosleep/1-5.c               | 3 ++-
 .../conformance/interfaces/clock_nanosleep/10-1.c              | 3 ++-
 .../conformance/interfaces/clock_nanosleep/2-2.c               | 3 ++-
 .../conformance/interfaces/clock_nanosleep/2-3.c               | 3 ++-
 .../conformance/interfaces/clock_nanosleep/9-1.c               | 3 ++-
 7 files changed, 14 insertions(+), 7 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/1-3.c +2 -1
index 98de93a9e..e2fdc4c37 100644
@@ -22,6 +22,7 @@
 #include <unistd.h>
 #include <sys/wait.h>
 #include "posixtest.h"
+#include "proc.h"
 
 #define SLEEPSEC 30
 
@@ -63,7 +64,7 @@ int main(void)
 		/* parent here */
 		int i;
 
-		sleep(1);
+		tst_process_state_wait3(pid, 'S', 1);
 
 		if (kill(pid, SIGABRT) != 0) {
 			printf("Could not raise signal being tested\n");
testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/1-4.c +2 -1
index 9808c5c4f..ca3d0798f 100644
@@ -14,6 +14,7 @@
 #include <unistd.h>
 #include <sys/wait.h>
 #include "posixtest.h"
+#include "proc.h"
 
 #define SLEEPSEC 30
 
@@ -36,7 +37,7 @@ int main(void)
 		/* parent here */
 		int i;
 
-		sleep(1);
+		tst_process_state_wait3(pid, 'S', 1);
 
 		if (kill(pid, SIGABRT) != 0) {
 			printf("Could not raise signal being tested\n");
testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/1-5.c +2 -1
index 46f26163d..263d98a08 100644
@@ -18,6 +18,7 @@
 #include <sys/wait.h>
 #include <stdlib.h>
 #include "posixtest.h"
+#include "proc.h"
 
 #define SLEEPSEC 5
 
@@ -52,7 +53,7 @@ int main(void)
 		/* parent here */
 		int i;
 
-		sleep(1);
+		tst_process_state_wait3(pid, 'S', 1);
 
 		if (kill(pid, SIGSTOP) != 0) {
 			printf("Could not raise SIGSTOP\n");
testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/10-1.c +2 -1
index f6adcc938..9fae578b4 100644
@@ -15,6 +15,7 @@
 #include <sys/wait.h>
 #include <errno.h>
 #include "posixtest.h"
+#include "proc.h"
 
 #define SLEEPSEC 30
 
@@ -59,7 +60,7 @@ int main(void)
 		/* parent here */
 		int i;
 
-		sleep(1);
+		tst_process_state_wait3(pid, 'S', 1);
 
 		if (kill(pid, SIGABRT) != 0) {
 			printf("Could not raise signal being tested\n");
testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/2-2.c +2 -1
index 330618877..8cafb3bf0 100644
@@ -23,6 +23,7 @@
 #include <unistd.h>
 #include <sys/wait.h>
 #include "posixtest.h"
+#include "proc.h"
 
 #define SLEEPSEC 30
 
@@ -71,7 +72,7 @@ int main(void)
 		/* parent here */
 		int i;
 
-		sleep(1);
+		tst_process_state_wait3(pid, 'S', 1);
 
 		if (kill(pid, SIGABRT) != 0) {
 			printf("Could not raise signal being tested\n");
testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/2-3.c +2 -1
index 06a79a96d..3938f44b7 100644
@@ -16,6 +16,7 @@
 #include <unistd.h>
 #include <sys/wait.h>
 #include "posixtest.h"
+#include "proc.h"
 
 #define SLEEPSEC 30
 
@@ -45,7 +46,7 @@ int main(void)
 		/* parent here */
 		int i;
 
-		sleep(1);
+		tst_process_state_wait3(pid, 'S', 1);
 
 		if (kill(pid, SIGABRT) != 0) {
 			printf("Could not raise signal being tested\n");
testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/9-1.c +2 -1
index 04ef0a2cc..554714695 100644
@@ -17,6 +17,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include "posixtest.h"
+#include "proc.h"
 
 #define SLEEPSEC 30
 
@@ -88,7 +89,7 @@ int main(void)
 		/* parent here */
 		int i;
 
-		sleep(1);
+		tst_process_state_wait3(pid, 'S', 1);
 
 		if (kill(pid, SIGABRT) != 0) {
 			printf("Could not raise signal being tested\n");
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/1 openposix: make use of tst_process_state_wait3

Hi!

Quoted 13 lines
testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/9-1.c +1 -0
index 04ef0a2cc..554714695 100644
@@ -17,6 +17,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include "posixtest.h"
+#include "proc.h"
 
 #define SLEEPSEC 30
 

testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/9-1.c int main(void) · line 92

Quoted 5 lines
testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/9-1.c +1 -1
@@ -88,7 +89,7 @@ int main(void)
 		/* parent here */
 		int i;
 
-		sleep(1);
+		tst_process_state_wait3(pid, 'S', 1);

This test is actually the only one that looks at the remining time as returned by clock_nanosleep() so it may make a sense to keep the sleep(1) in this test so that the remaining time is smaller than the sleep time by some reasonable margin. But I guess that the test will work fine without it as well.

The rest is obviously fine.

Signature · 2 lines
Cyril Hrubis
[email protected]
author
#2 lore raw

PATCH 1/1 openposix: make use of tst_process_state_wait3

Quoted 21 lines · Cyril Hrubis

Hi!

Quoted 1 line

diff --git

a/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/9-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/9-1.c

Quoted 2 lines

index 04ef0a2cc..554714695 100644
---

a/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/9-1.c

Quoted 1 line

+++

b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/9-1.c

Quoted 12 lines
testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/9-1.c +1 -0
@@ -17,6 +17,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include "posixtest.h"
+#include "proc.h"
 
 #define SLEEPSEC 30
 
@@ -88,7 +89,7 @@ int main(void)
              /* parent here */
              int i;
 
Quoted 9 lines

Review int main(void) · line 92

Quoted 2 lines
(quoted diff) +1 -1
-             sleep(1);
+             tst_process_state_wait3(pid, 'S', 1);

This test is actually the only one that looks at the remining time as returned by clock_nanosleep() so it may make a sense to keep the sleep(1) in this test so that the remaining time is smaller than the sleep time by some reasonable margin. But I guess that the test will work fine without it as well.

Good point, I have retrieved that 1 sec sleep and applied. Thanks!

Signature · 5 lines
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20210908/2aceeefd/attachment-0001.htm>