All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] open_posix/conformance/clock/1.1: check PASS condition periodically
@ 2021-10-18  9:17 Jan Stancek
  2021-10-19  9:11 ` Li Wang
  2021-10-25  9:09 ` Cyril Hrubis
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Stancek @ 2021-10-18  9:17 UTC (permalink / raw)
  To: ltp

LTP commit 61312c62a392 ("open_posix/conformance/clock/1.1:
Deterministic timing") changed test to busy loop for 5 seconds.
This made the test sometimes fail in environments with high steal
time.

Move PASS condition inside loop, so in ideal case test can finish
as soon as it has spent >1 sec of CPU time. Also drop the wrap-around
check, since that takes order of minutes to happen.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 .../conformance/interfaces/clock/1-1.c        | 49 +++++++------------
 1 file changed, 18 insertions(+), 31 deletions(-)

diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock/1-1.c
index 384be0648f0b..e255720df6b1 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/clock/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock/1-1.c
@@ -20,45 +20,32 @@
 #include <time.h>
 #include "posixtest.h"
 
-#define BUSY_LOOP_SECONDS 5
+#define MAX_RUNTIME_SECONDS 15
 
 int main(void)
 {
 	clock_t c1, c2;
 	double sec1, sec2;
-	time_t end;
+	time_t end = time(NULL) + MAX_RUNTIME_SECONDS;
 
 	c1 = clock();
-	sec1 = c1 / CLOCKS_PER_SEC;
-
-	end = time(NULL) + BUSY_LOOP_SECONDS;
-
-	while (end >= time(NULL)) {
-		clock();
+	if (c1 == (clock_t)-1) {
+		printf("processor time not available\n");
+		return PTS_UNRESOLVED;
 	}
-
-	c2 = clock();
-	sec2 = c2 / CLOCKS_PER_SEC;
-
-	if (sec2 > sec1) {
-		printf("Times T1=%.2f, T2=%.2f\n", sec1, sec2);
-		printf("Test PASSED\n");
-		return PTS_PASS;
-	} else {
-		if (sec2 < sec1) {
-			/*
-			 * probably wrapping happened; however, since
-			 * we do not know the wrap value, results are
-			 * undefined
-			 */
-			printf("TEST AGAIN:  Times probably wrapped\n");
-			return PTS_UNRESOLVED;
-		} else {
-			printf("Error with processor times T1=%.2f, T2=%.2f\n",
-			       sec1, sec2);
-			return PTS_FAIL;
+	sec1 = (double) c1 / CLOCKS_PER_SEC;
+
+	do {
+		c2 = clock();
+		sec2 = (double) c2 / CLOCKS_PER_SEC;
+		if (sec2 - sec1 > 1) {
+			printf("Times T1=%.2lf, T2=%.2lf\n", sec1, sec2);
+			printf("Test PASSED\n");
+			return PTS_PASS;
 		}
-	}
+	} while (end >= time(NULL));
 
-	return PTS_UNRESOLVED;
+	printf("Error with processor times T1=%.2lf, T2=%.2lf\n",
+	       sec1, sec2);
+	return PTS_FAIL;
 }
-- 
2.27.0


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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] open_posix/conformance/clock/1.1: check PASS condition periodically
  2021-10-18  9:17 [LTP] [PATCH] open_posix/conformance/clock/1.1: check PASS condition periodically Jan Stancek
@ 2021-10-19  9:11 ` Li Wang
  2021-10-25  9:09 ` Cyril Hrubis
  1 sibling, 0 replies; 4+ messages in thread
From: Li Wang @ 2021-10-19  9:11 UTC (permalink / raw)
  To: Jan Stancek; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 682 bytes --]

On Mon, Oct 18, 2021 at 5:18 PM Jan Stancek <jstancek@redhat.com> wrote:

> LTP commit 61312c62a392 ("open_posix/conformance/clock/1.1:
> Deterministic timing") changed test to busy loop for 5 seconds.
> This made the test sometimes fail in environments with high steal
> time.
>
> Move PASS condition inside loop, so in ideal case test can finish
> as soon as it has spent >1 sec of CPU time. Also drop the wrap-around
> check, since that takes order of minutes to happen.
>

Looks like more reliable than that 5sec busy loop, let's see how it
performs then.


>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
>

Reviewed-by: Li Wang <liwang@redhat.com>


-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 1663 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] open_posix/conformance/clock/1.1: check PASS condition periodically
  2021-10-18  9:17 [LTP] [PATCH] open_posix/conformance/clock/1.1: check PASS condition periodically Jan Stancek
  2021-10-19  9:11 ` Li Wang
@ 2021-10-25  9:09 ` Cyril Hrubis
  2021-10-25  9:29   ` Jan Stancek
  1 sibling, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2021-10-25  9:09 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp

Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH] open_posix/conformance/clock/1.1: check PASS condition periodically
  2021-10-25  9:09 ` Cyril Hrubis
@ 2021-10-25  9:29   ` Jan Stancek
  0 siblings, 0 replies; 4+ messages in thread
From: Jan Stancek @ 2021-10-25  9:29 UTC (permalink / raw)
  To: Cyril Hrubis, Li Wang; +Cc: LTP List

On Mon, Oct 25, 2021 at 11:09 AM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

Thanks, pushed.


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-25  9:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-18  9:17 [LTP] [PATCH] open_posix/conformance/clock/1.1: check PASS condition periodically Jan Stancek
2021-10-19  9:11 ` Li Wang
2021-10-25  9:09 ` Cyril Hrubis
2021-10-25  9:29   ` Jan Stancek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.