diff options
author | Nicolas Dusart <dusartnicolas@gmail.com> | 2017-07-20 14:03:27 +0200 |
---|---|---|
committer | Nicolas Dusart <dusartnicolas@gmail.com> | 2017-07-20 16:44:47 +0200 |
commit | f72287e1f68bccf76498db1547e3dd9755dec623 (patch) | |
tree | 5e847aee66c323b0e6defe189c126f4703b61dfa | |
parent | 07e6c2f5c2d2a95fcfcd509556c4d1441a91adfb (diff) | |
download | nix-f72287e1f68bccf76498db1547e3dd9755dec623.zip |
fix some tests for Android
-rw-r--r-- | test/sys/test_pthread.rs | 2 | ||||
-rw-r--r-- | test/test_net.rs | 4 | ||||
-rw-r--r-- | test/test_unistd.rs | 9 |
3 files changed, 10 insertions, 5 deletions
diff --git a/test/sys/test_pthread.rs b/test/sys/test_pthread.rs index 092a95aa..a4f02772 100644 --- a/test/sys/test_pthread.rs +++ b/test/sys/test_pthread.rs @@ -3,5 +3,5 @@ use nix::sys::pthread::*; #[test] fn test_pthread_self() { let tid = pthread_self(); - assert!(tid > 0); + assert!(tid != 0); } diff --git a/test/test_net.rs b/test/test_net.rs index acdaf47a..24bd411a 100644 --- a/test/test_net.rs +++ b/test/test_net.rs @@ -1,9 +1,9 @@ use nix::net::if_::*; -#[cfg(target_os = "linux")] +#[cfg(any(target_os = "android", target_os = "linux"))] const LOOPBACK: &'static [u8] = b"lo"; -#[cfg(not(target_os = "linux"))] +#[cfg(not(any(target_os = "android", target_os = "linux")))] const LOOPBACK: &'static [u8] = b"lo0"; #[test] diff --git a/test/test_unistd.rs b/test/test_unistd.rs index fd4e327b..7ae01feb 100644 --- a/test/test_unistd.rs +++ b/test/test_unistd.rs @@ -64,7 +64,12 @@ fn test_wait() { #[test] fn test_mkstemp() { - let result = mkstemp("/tmp/nix_tempfile.XXXXXX"); + #[cfg(target_os = "android")] + let tmp = "/data/local/tmp/"; + #[cfg(not(target_os = "android"))] + let tmp = "/tmp/"; + + let result = mkstemp((tmp.to_owned() + "nix_tempfile.XXXXXX").as_str()); match result { Ok((fd, path)) => { close(fd).unwrap(); @@ -73,7 +78,7 @@ fn test_mkstemp() { Err(e) => panic!("mkstemp failed: {}", e) } - let result = mkstemp("/tmp/"); + let result = mkstemp(tmp); match result { Ok(_) => { panic!("mkstemp succeeded even though it should fail (provided a directory)"); |