You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
693: fix some tests for Android r=asomers
I tested the crate on an Android emulator and quite all the tests passed. Only 6 were failing.
> failures:
>
> ---- sys::test_pthread::test_pthread_self stdout ----
> thread 'sys::test_pthread::test_pthread_self' panicked at 'assertion failed: tid > 0', test/sys/test_pthread.rs:6
> note: Run with `RUST_BACKTRACE=1` for a backtrace.
>
> ---- sys::test_socket::test_getsockname stdout ----
> thread 'sys::test_socket::test_getsockname' panicked at 'bind failed: Sys(EACCES)', /checkout/src/libcore/result.rs:859
>
> ---- sys::test_socket::test_unixdomain stdout ----
> thread 'sys::test_socket::test_unixdomain' panicked at 'bind failed: Sys(EACCES)', /checkout/src/libcore/result.rs:859
>
> ---- sys::test_termios::test_local_flags stdout ----
> thread 'sys::test_termios::test_local_flags' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:329
>
> ---- test_net::test_if_nametoindex stdout ----
> thread 'test_net::test_if_nametoindex' panicked at 'assertion failed: if_nametoindex(&LOOPBACK[..]).is_ok()', test/test_net.rs:11
>
> ---- test_unistd::test_mkstemp stdout ----
> thread 'test_unistd::test_mkstemp' panicked at 'mkstemp failed: ENOENT: No such file or directory', test/test_unistd.rs:73
This PR fixes 3 of those:
- `test_pthread_self`: pthread_t is unsigned, so it can be negative (and it is often the case)
- `test_if_nametoindex`: constant `LOOPBACK` is the same than on Linux
- `test_mkstemp`: directory `/tmp` does not exist in Android
Two are still failing (`test_unixdomain` and `test_getsockname`) because we need some special permissions on Android for playing with sockets. On a rooted physical device, they passed. So, if tests for Android are integrated in CI, we should try to embed the tests to run in an APK with requested permissions or find a way to give the permission to a native program.
`test_local_flags` is still failing also because `O_LARGEFILE` is hardcoded and is not the right value in Android. Then `fcntl::OFlag::from_bits(flags).unwrap()` fails because this flag is then not recognised.
I made a PR in `libc` so that we can rely on libc definitions for all `O_*` flags. (rust-lang/libc#683)
Do you prefer to wait for this one to be fixed for this PR to merged as well ?
0 commit comments