Skip to content

Commit ae3ff3b

Browse files
committed
Android: Fixed tests for libc time API
1 parent 894c264 commit ae3ff3b

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

ci/ci.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ case $HOST_TARGET in
154154
TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname pthread time fs
155155
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX thread sync available-parallelism time tls
156156
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX thread sync available-parallelism time tls
157-
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX pthread --skip threadname --skip pthread_cond_timedwait
157+
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX pthread time --skip threadname --skip pthread_cond_timedwait
158158
TEST_TARGET=wasm32-wasip2 run_tests_minimal empty_main wasm heap_alloc libc-mem
159159
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal empty_main wasm
160160
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std

src/shims/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3636
let mut relative_clocks;
3737

3838
match this.tcx.sess.target.os.as_ref() {
39-
"linux" | "freebsd" => {
39+
"linux" | "freebsd" | "android" => {
4040
// Linux and FreeBSD have two main kinds of clocks. REALTIME clocks return the actual time since the
4141
// Unix epoch, including effects which may cause time to move backwards such as NTP.
4242
// Linux further distinguishes regular and "coarse" clocks, but the "coarse" version

tests/pass-dep/libc/libc-time.rs

+25-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn test_clocks() {
1515
assert_eq!(is_error, 0);
1616
let is_error = unsafe { libc::clock_gettime(libc::CLOCK_MONOTONIC, tp.as_mut_ptr()) };
1717
assert_eq!(is_error, 0);
18-
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
18+
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "android"))]
1919
{
2020
let is_error = unsafe { libc::clock_gettime(libc::CLOCK_REALTIME_COARSE, tp.as_mut_ptr()) };
2121
assert_eq!(is_error, 0);
@@ -63,9 +63,19 @@ fn test_localtime_r() {
6363
tm_wday: 0,
6464
tm_yday: 0,
6565
tm_isdst: 0,
66-
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
66+
#[cfg(any(
67+
target_os = "linux",
68+
target_os = "macos",
69+
target_os = "freebsd",
70+
target_os = "android"
71+
))]
6772
tm_gmtoff: 0,
68-
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
73+
#[cfg(any(
74+
target_os = "linux",
75+
target_os = "macos",
76+
target_os = "freebsd",
77+
target_os = "android"
78+
))]
6979
tm_zone: std::ptr::null_mut::<libc::c_char>(),
7080
};
7181
let res = unsafe { libc::localtime_r(custom_time_ptr, &mut tm) };
@@ -79,9 +89,19 @@ fn test_localtime_r() {
7989
assert_eq!(tm.tm_wday, 0);
8090
assert_eq!(tm.tm_yday, 97);
8191
assert_eq!(tm.tm_isdst, -1);
82-
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
92+
#[cfg(any(
93+
target_os = "linux",
94+
target_os = "macos",
95+
target_os = "freebsd",
96+
target_os = "android"
97+
))]
8398
assert_eq!(tm.tm_gmtoff, 0);
84-
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
99+
#[cfg(any(
100+
target_os = "linux",
101+
target_os = "macos",
102+
target_os = "freebsd",
103+
target_os = "android"
104+
))]
85105
unsafe {
86106
assert_eq!(std::ffi::CStr::from_ptr(tm.tm_zone).to_str().unwrap(), "+00")
87107
};

0 commit comments

Comments
 (0)