From: Joerg Vehlow <lkml@jv-coder.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] open_posix/timer_getoverrun/2-3: Fix test for systems with low timer precision
Date: Fri, 11 Oct 2019 07:31:34 +0200 [thread overview]
Message-ID: <20191011053134.18416-1-lkml@jv-coder.de> (raw)
From: Joerg Vehlow <joerg.vehlow@aox-tech.de>
On systems with low timer precision the test always fails, because the allowed
maximum number of overruns is calculated from the expected overruns + 10%.
If the expected overruns is less than 200, there is no tollerance.
This happens, if the precision of the timer is less than or equal to 4ms.
E.g. qemu-arm64 without high resolution timer the accuracy is only 4ms.
Signed-off-by: Joerg Vehlow <joerg.vehlow@aox-tech.de>
---
.../conformance/interfaces/timer_getoverrun/2-3.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/2-3.c b/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/2-3.c
index 96b7d01e6..3df3a9f01 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/2-3.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/2-3.c
@@ -55,6 +55,7 @@ int main(void)
int overruns;
int valuensec, intervalnsec, expectedoverruns;
int fudge;
+ int duration;
if (sigemptyset(&set) != 0) {
perror("sigemptyset() did not return success\n");
@@ -94,11 +95,15 @@ int main(void)
valuensec = tsres.tv_nsec;
intervalnsec = 2 * valuensec;
- //expectedoverruns = (1000000000 - valuensec) / intervalnsec;
- expectedoverruns = 1000000000 / intervalnsec - 1;
+ expectedoverruns = 0;
+ duration = 0;
+ while (expectedoverruns < 1000) {
+ duration++;
+ expectedoverruns = duration * (1000000000 / intervalnsec - 1);
+ }
- printf("value = %d sec, interval = %d nsec, "
- "expected overruns = %d\n", 1, intervalnsec, expectedoverruns);
+ printf("duration = %d sec, interval = %d nsec, "
+ "expected overruns = %d\n", duration, intervalnsec, expectedoverruns);
its.it_interval.tv_sec = 0;
its.it_interval.tv_nsec = intervalnsec;
@@ -113,7 +118,7 @@ int main(void)
}
//tssleep.tv_nsec = valuensec + (expectedoverruns*intervalnsec);
tssleep.tv_nsec = 0;
- tssleep.tv_sec = 2;
+ tssleep.tv_sec = duration + 1;
if (nanosleep(&tssleep, NULL) != 0) {
perror("nanosleep() did not return success\n");
return PTS_UNRESOLVED;
--
2.20.1
next reply other threads:[~2019-10-11 5:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-11 5:31 Joerg Vehlow [this message]
2019-10-15 15:08 ` [LTP] [PATCH] open_posix/timer_getoverrun/2-3: Fix test for systems with low timer precision Jan Stancek
2019-10-16 5:39 ` Joerg Vehlow
2019-10-16 8:38 ` Jan Stancek
2019-10-16 8:42 ` Joerg Vehlow
2019-10-16 9:51 ` [LTP] [PATCH] timer_getoverrun/2-3: increase tolerance for overshoot Jan Stancek
2019-10-17 12:54 ` Cyril Hrubis
2019-10-18 7:58 ` Jan Stancek
2019-10-18 8:02 ` Joerg Vehlow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191011053134.18416-1-lkml@jv-coder.de \
--to=lkml@jv-coder.de \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.