From a9f051faac471e306b467692e9baecb3232b21ee Mon Sep 17 00:00:00 2001 From: Rahul Frias Date: Sun, 7 Mar 2021 22:21:50 -0800 Subject: [PATCH] Fix test sleep on iOS. [ Merge of http://go/wvgerrit/117203 ] clock_settime isn't available on iOS (even though settimeofday is). But we can't change the system time on iOS anyway, so this just disallows iOS. Bug: 182058081 Test: WV unit/integration tests Change-Id: I96e5b6634803bd4e6aaf5cc6d64f4441296247d4 --- libwvdrmengine/cdm/util/test/test_sleep.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libwvdrmengine/cdm/util/test/test_sleep.cpp b/libwvdrmengine/cdm/util/test/test_sleep.cpp index f3f219c8..3557fe95 100644 --- a/libwvdrmengine/cdm/util/test/test_sleep.cpp +++ b/libwvdrmengine/cdm/util/test/test_sleep.cpp @@ -9,6 +9,9 @@ #else # include #endif +#ifdef __APPLE__ +# include +#endif #include #include @@ -73,10 +76,13 @@ bool TestSleep::RollbackSystemTime(int seconds) { file_time.dwHighDateTime = long_time >> 32; if (!FileTimeToSystemTime(&file_time, &time)) return false; if (!SetSystemTime(&time)) return false; +#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE + LOGE("iOS time rollback: cannot set system time."); + return false; #else auto time = std::chrono::system_clock::now(); auto modified_time = time - std::chrono::seconds(seconds); - ; + timespec time_spec; time_spec.tv_sec = std::chrono::duration_cast( modified_time.time_since_epoch()) @@ -140,6 +146,9 @@ bool TestSleep::CanChangeSystemTime() { } LOGE("Win32 time rollback: cannot set system time."); return false; +#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE + LOGE("iOS time rollback: cannot set system time."); + return false; #else // Otherwise, the test needs to be run as root. const uid_t uid = getuid();