Skip to content

Commit f72287e

Browse files
committed
fix some tests for Android
1 parent 07e6c2f commit f72287e

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

test/sys/test_pthread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ use nix::sys::pthread::*;
33
#[test]
44
fn test_pthread_self() {
55
let tid = pthread_self();
6-
assert!(tid > 0);
6+
assert!(tid != 0);
77
}

test/test_net.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use nix::net::if_::*;
22

3-
#[cfg(target_os = "linux")]
3+
#[cfg(any(target_os = "android", target_os = "linux"))]
44
const LOOPBACK: &'static [u8] = b"lo";
55

6-
#[cfg(not(target_os = "linux"))]
6+
#[cfg(not(any(target_os = "android", target_os = "linux")))]
77
const LOOPBACK: &'static [u8] = b"lo0";
88

99
#[test]

test/test_unistd.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ fn test_wait() {
6464

6565
#[test]
6666
fn test_mkstemp() {
67-
let result = mkstemp("/tmp/nix_tempfile.XXXXXX");
67+
#[cfg(target_os = "android")]
68+
let tmp = "/data/local/tmp/";
69+
#[cfg(not(target_os = "android"))]
70+
let tmp = "/tmp/";
71+
72+
let result = mkstemp((tmp.to_owned() + "nix_tempfile.XXXXXX").as_str());
6873
match result {
6974
Ok((fd, path)) => {
7075
close(fd).unwrap();
@@ -73,7 +78,7 @@ fn test_mkstemp() {
7378
Err(e) => panic!("mkstemp failed: {}", e)
7479
}
7580

76-
let result = mkstemp("/tmp/");
81+
let result = mkstemp(tmp);
7782
match result {
7883
Ok(_) => {
7984
panic!("mkstemp succeeded even though it should fail (provided a directory)");

0 commit comments

Comments
 (0)