diff options
author | mbegumx <mogalx.begum@intel.com> | 2021-02-03 13:13:15 +0530 |
---|---|---|
committer | Alistair Delva <adelva@google.com> | 2021-02-15 05:36:11 +0000 |
commit | 4d21048a87836455e2c82491f430e88cdd404f2e (patch) | |
tree | fc648ba1078911d18b0fccf1bbc50ac36e4ec1cc | |
parent | 000fab878b5197457ae7c406cc1c4b06ec844d15 (diff) | |
download | ltp-4d21048a87836455e2c82491f430e88cdd404f2e.tar.gz |
UPSTREAM: Skip oversleep checks in timer tests under VM
Timer tests often fail on sleep overrun when LTP is running inside a VM.
The main cause is usually that the VM doesn't get enough CPU time to wake up
the test process in time. Disable oversleep tests if tst_is_virt() detects
any hypervisor.
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
Tested-by: Li Wang <liwang@redhat.com>
Acked-by: Jan Stancek <jstancek@redhat.com>
(cherry picked from commit 8bc8440151910260dcca0e3d923b801fff15b691)
Bug: 180251008
Signed-off-by: Alistair Delva <adelva@google.com>
Change-Id: I91b98b49ec049eaa229b5487f85a6ff9c47d4cf7
-rw-r--r-- | lib/tst_timer_test.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c index 13e9deff2..196c51272 100644 --- a/lib/tst_timer_test.c +++ b/lib/tst_timer_test.c @@ -26,6 +26,7 @@ static long long *samples; static unsigned int cur_sample; static unsigned int monotonic_resolution; static unsigned int timerslack; +static int virt_env; static char *print_frequency_plot; static char *file_name; @@ -306,7 +307,10 @@ void do_timer_test(long long usec, unsigned int nsamples) samples[nsamples-1], samples[0], median, 1.00 * trunc_mean / keep_samples, discard); - if (trunc_mean > (nsamples - discard) * usec + threshold) { + if (virt_env) { + tst_res(TINFO, + "Virtualisation detected, skipping oversleep checks"); + } else if (trunc_mean > (nsamples - discard) * usec + threshold) { tst_res(TFAIL, "%s slept for too long", scall); if (!print_frequency_plot) @@ -343,6 +347,11 @@ static void timer_setup(void) if (setup) setup(); + /* + * Running tests in VM may cause timing issues, disable upper bound + * checks if any hypervisor is detected. + */ + virt_env = tst_is_virt(VIRT_ANY); tst_clock_getres(CLOCK_MONOTONIC, &t); tst_res(TINFO, "CLOCK_MONOTONIC resolution %lins", (long)t.tv_nsec); |