tests/tcg/multiarch/linux-test: Skip test if nanosleep missing (Travis)
RFC 1/1 tests/tcg/multiarch/linux-test: Skip test if nanosleep missing (Travis)
The time test sometimes fails on Travis-CI [*]:
TEST linux-test on aarch64
tests/tcg/multiarch/linux-test.c:237: nanosleep make[2]: *** [run-linux-test] Error 1
make: *** [run-tcg-tests-aarch64-linux-user] Error 2
As this seems due to a container limitation on Travis-CI, simply skip the test there.
[*] https://travis-ci.org/github/qemu/qemu/jobs/710005078#L3706
---
RFC because per Laurent Vivier we are not using the correct libc
while cross-linking the test (maybe change in the container packages?)
--- tests/tcg/multiarch/linux-test.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tests/tcg/multiarch/linux-test.c +6 -1
@@ -233,8 +233,13 @@ static void test_time(void) ts.tv_sec =0 ; ts.tv_nsec =20 *1000000 ;chk_error (nanosleep (&ts, &rem)); -if (rem.tv_sec !=1 ) +if (rem.tv_sec !=1 ) { +if (getenv ("TRAVIS_ARCH" )) { +printf ("nanosleep missing? skipping 'time' test\n" ); +return ; + }error ("nanosleep" ); + }chk_error (gettimeofday (&tv2,NULL )); ti = tv2.tv_sec - tv.tv_sec;if (ti >=2 )
Signature · 1 line
2.21.3
Le 21/07/2020 à 10:57, Philippe Mathieu-Daudé a écrit :
Quoted 31 lines
The time test sometimes fails on Travis-CI [*]:
TEST linux-test on aarch64
tests/tcg/multiarch/linux-test.c:237: nanosleep make[2]: *** [run-linux-test] Error 1
make: *** [run-tcg-tests-aarch64-linux-user] Error 2As this seems due to a container limitation on Travis-CI, simply skip the test there.
[*] https://travis-ci.org/github/qemu/qemu/jobs/710005078#L3706
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
RFC because per Laurent Vivier we are not using the correct libc
while cross-linking the test (maybe change in the container packages?)--- tests/tcg/multiarch/linux-test.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tests/tcg/multiarch/linux-test.c +0
-1@@ -233,8 +233,13 @@ static void test_time(void) ts.tv_sec =0 ; ts.tv_nsec =20 *1000000 ;chk_error (nanosleep (&ts, &rem)); -if (rem.tv_sec !=1 )
tests/tcg/multiarch/linux-test.c static void test_time(void) · line 245
Quoted 10 lines
tests/tcg/multiarch/linux-test.c +6
-0+if (rem.tv_sec !=1 ) { +if (getenv ("TRAVIS_ARCH" )) { +printf ("nanosleep missing? skipping 'time' test\n" ); +return ; + }error ("nanosleep" ); + }chk_error (gettimeofday (&tv2,NULL )); ti = tv2.tv_sec - tv.tv_sec;if (ti >=2 )
Well, in the end I think the problem is in linux-user:
We copy the "rem" structure even if there is no error, so "1" is overwritten.
We don't have the problem on all architectures because some use nanosleep() syscall (that is correct) others use clock_nanosleep() syscall that is not correct.
This should fix the problem:
linux-user/syscall.c +0 -0
@@ -11831,7 +11831,7 @@ static abi_long do_syscall1(void *cpu_env, int
num, abi_long arg1,
target_to_host_timespec(&ts, arg3);
ret = get_errno(safe_clock_nanosleep(arg1, arg2,
&ts, arg4 ? &ts : NULL));
- if (arg4)
+ if (is_error(ret) && arg4)
host_to_target_timespec(arg4, &ts); #if defined(TARGET_PPC)
Thanks,
Laurent
Le 21/07/2020 à 13:38, Laurent Vivier a écrit :
Quoted 67 lines
Le 21/07/2020 à 10:57, Philippe Mathieu-Daudé a écrit :
Quoted 31 lines
The time test sometimes fails on Travis-CI [*]:
TEST linux-test on aarch64
tests/tcg/multiarch/linux-test.c:237: nanosleep make[2]: *** [run-linux-test] Error 1
make: *** [run-tcg-tests-aarch64-linux-user] Error 2As this seems due to a container limitation on Travis-CI, simply skip the test there.
[*] https://travis-ci.org/github/qemu/qemu/jobs/710005078#L3706
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
RFC because per Laurent Vivier we are not using the correct libc
while cross-linking the test (maybe change in the container packages?)--- tests/tcg/multiarch/linux-test.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tests/tcg/multiarch/linux-test.c +0
-1@@ -233,8 +233,13 @@ static void test_time(void) ts.tv_sec =0 ; ts.tv_nsec =20 *1000000 ;chk_error (nanosleep (&ts, &rem)); -if (rem.tv_sec !=1 )tests/tcg/multiarch/linux-test.c static void test_time(void) · line 245
Quoted 10 lines
tests/tcg/multiarch/linux-test.c +6
-0+if (rem.tv_sec !=1 ) { +if (getenv ("TRAVIS_ARCH" )) { +printf ("nanosleep missing? skipping 'time' test\n" ); +return ; + }error ("nanosleep" ); + }chk_error (gettimeofday (&tv2,NULL )); ti = tv2.tv_sec - tv.tv_sec;if (ti >=2 )Well, in the end I think the problem is in linux-user:
We copy the "rem" structure even if there is no error, so "1" is overwritten.
We don't have the problem on all architectures because some use
nanosleep()syscall (that is correct) others useclock_nanosleep()syscall that is not correct.This should fix the problem:
linux-user/syscall.c +1
-1@@ -11831,7 +11831,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,target_to_host_timespec (&ts, arg3); ret =get_errno (safe_clock_nanosleep (arg1, arg2, &ts, arg4 ? &ts :NULL )); -if (arg4) +if (is_error (ret) && arg4)host_to_target_timespec (arg4, &ts);
Quoted 1 line
#if
defined(TARGET_PPC)
According to clock_nanosleep(2) it should be in fact:
linux-user/syscall.c +0 -0
@@ -11831,8 +11831,9 @@ static abi_long do_syscall1(void *cpu_env, int
num, abi_long arg1,
target_to_host_timespec(&ts, arg3);
ret = get_errno(safe_clock_nanosleep(arg1, arg2,
&ts, arg4 ? &ts : NULL));
- if (arg4)
+ if (ret == -TARGET_EINTR && arg4 && arg2 != TIMER_ABSTIME) {
host_to_target_timespec(arg4, &ts);+ }
#if defined(TARGET_PPC)
/* clock_nanosleep is odd in that it returns positive errno values.Quoted 77 lines · Laurent Vivier
Le 21/07/2020 à 13:38, Laurent Vivier a écrit :
Quoted 67 lines
Le 21/07/2020 à 10:57, Philippe Mathieu-Daudé a écrit :
Quoted 31 lines
The time test sometimes fails on Travis-CI [*]:
TEST linux-test on aarch64
tests/tcg/multiarch/linux-test.c:237: nanosleep make[2]: *** [run-linux-test] Error 1
make: *** [run-tcg-tests-aarch64-linux-user] Error 2As this seems due to a container limitation on Travis-CI, simply skip the test there.
[*] https://travis-ci.org/github/qemu/qemu/jobs/710005078#L3706
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
RFC because per Laurent Vivier we are not using the correct libc
while cross-linking the test (maybe change in the container packages?)--- tests/tcg/multiarch/linux-test.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tests/tcg/multiarch/linux-test.c +0
-1@@ -233,8 +233,13 @@ static void test_time(void) ts.tv_sec =0 ; ts.tv_nsec =20 *1000000 ;chk_error (nanosleep (&ts, &rem)); -if (rem.tv_sec !=1 )tests/tcg/multiarch/linux-test.c static void test_time(void) · line 245
Quoted 10 lines
tests/tcg/multiarch/linux-test.c +6
-0+if (rem.tv_sec !=1 ) { +if (getenv ("TRAVIS_ARCH" )) { +printf ("nanosleep missing? skipping 'time' test\n" ); +return ; + }error ("nanosleep" ); + }chk_error (gettimeofday (&tv2,NULL )); ti = tv2.tv_sec - tv.tv_sec;if (ti >=2 )Well, in the end I think the problem is in linux-user:
We copy the "rem" structure even if there is no error, so "1" is overwritten.
We don't have the problem on all architectures because some use
nanosleep()syscall (that is correct) others useclock_nanosleep()syscall that is not correct.This should fix the problem:
linux-user/syscall.c +1
-1@@ -11831,7 +11831,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,target_to_host_timespec (&ts, arg3); ret =get_errno (safe_clock_nanosleep (arg1, arg2, &ts, arg4 ? &ts :NULL )); -if (arg4) +if (is_error (ret) && arg4)host_to_target_timespec (arg4, &ts);Quoted 1 line
#if
defined(TARGET_PPC)According to
clock_nanosleep(2)it should be in fact:linux-user/syscall.c +0
-0
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int · line 11837
Quoted 8 lines
linux-user/syscall.c +2
-1@@ -11831,8 +11831,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,target_to_host_timespec (&ts, arg3); ret =get_errno (safe_clock_nanosleep (arg1, arg2, &ts, arg4 ? &ts :NULL )); -if (arg4) +if (ret == -TARGET_EINTR && arg4 && arg2 !=TIMER_ABSTIME ) {host_to_target_timespec (arg4, &ts); + }
I tested this hunk and couldn't reproduce it on Travis-CI. Since it is intermittent, that doesn't mean much, but still if you send a proper path you can add "Tested-by: Philippe Mathieu-Daudé <[email protected]>".
Quoted 5 lines
linux-user/syscall.c +0
-0#if defined(TARGET_PPC )/* clock_nanosleep is odd in that it returns positive errno values.
Quoted 59 lines · Laurent Vivier
Quoted 31 lines · Philippe Mathieu-Daudé
The time test sometimes fails on Travis-CI [*]:
TEST linux-test on aarch64
tests/tcg/multiarch/linux-test.c:237: nanosleep make[2]: *** [run-linux-test] Error 1
make: *** [run-tcg-tests-aarch64-linux-user] Error 2As this seems due to a container limitation on Travis-CI, simply skip the test there.
[*] https://travis-ci.org/github/qemu/qemu/jobs/710005078#L3706
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
RFC because per Laurent Vivier we are not using the correct libc
while cross-linking the test (maybe change in the container packages?)--- tests/tcg/multiarch/linux-test.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)tests/tcg/multiarch/linux-test.c +0
-1@@ -233,8 +233,13 @@ static void test_time(void) ts.tv_sec =0 ; ts.tv_nsec =20 *1000000 ;chk_error (nanosleep (&ts, &rem)); -if (rem.tv_sec !=1 )tests/tcg/multiarch/linux-test.c static void test_time(void) · line 245
Quoted 10 lines
tests/tcg/multiarch/linux-test.c +6
-0+if (rem.tv_sec !=1 ) { +if (getenv ("TRAVIS_ARCH" )) { +printf ("nanosleep missing? skipping 'time' test\n" ); +return ; + }error ("nanosleep" ); + }chk_error (gettimeofday (&tv2,NULL )); ti = tv2.tv_sec - tv.tv_sec;if (ti >=2 )Well, in the end I think the problem is in linux-user:
We copy the "rem" structure even if there is no error, so "1" is overwritten.
We don't have the problem on all architectures because some use
nanosleep()syscall (that is correct) others useclock_nanosleep()syscall that is not correct.This should fix the problem:
linux-user/syscall.c +0
-0
linux-user/syscall.c static abi_long do_syscall1(void *cpu_env, int · line 11836
Quoted 7 lines
linux-user/syscall.c +1
-1@@ -11831,7 +11831,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,target_to_host_timespec (&ts, arg3); ret =get_errno (safe_clock_nanosleep (arg1, arg2, &ts, arg4 ? &ts :NULL )); -if (arg4) +if (is_error (ret) && arg4)host_to_target_timespec (arg4, &ts);
So the testcase worked and caught something :-)
I don't know why I couldn't trigger it reliably on my own dev setting though...
Quoted 5 lines
linux-user/syscall.c +0
-0#if defined(TARGET_PPC )Thanks,
Laurent
Signature · 1 line
Alex Bennée