summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-12-07 00:12:38 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-12-07 00:12:38 +0000
commit3987d122972987dc6a3b7bcc32c55d9ec2a9dc38 (patch)
tree511a8b9013c6f1e4127b3b9cfe7d77ca113ac7da
parent012ba5b054af01a6aa98f7ad1a97e78cf1af2a85 (diff)
parentc8d5f1a4720bc2923aa398e713ad5da4f9ae2f86 (diff)
Merge "binderLibTest: epoch->uptime" into main
-rw-r--r--libs/binder/tests/binderLibTest.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp
index e56b7cf004..c234172916 100644
--- a/libs/binder/tests/binderLibTest.cpp
+++ b/libs/binder/tests/binderLibTest.cpp
@@ -43,6 +43,7 @@
#include <input/BlockingQueue.h>
#include <processgroup/processgroup.h>
#include <utils/Flattenable.h>
+#include <utils/SystemClock.h>
#include <linux/sched.h>
#include <sys/epoll.h>
@@ -1716,14 +1717,6 @@ TEST_F(BinderLibTest, ThreadPoolStarted) {
EXPECT_TRUE(reply.readBool());
}
-size_t epochMillis() {
- using std::chrono::duration_cast;
- using std::chrono::milliseconds;
- using std::chrono::seconds;
- using std::chrono::system_clock;
- return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
-}
-
TEST_F(BinderLibTest, HangingServices) {
Parcel data, reply;
sp<IBinder> server = addServer();
@@ -1732,7 +1725,7 @@ TEST_F(BinderLibTest, HangingServices) {
data.writeInt32(delay);
// b/266537959 - must take before taking lock, since countdown is started in the remote
// process there.
- size_t epochMsBefore = epochMillis();
+ int64_t timeBefore = uptimeMillis();
EXPECT_THAT(server->transact(BINDER_LIB_TEST_PROCESS_TEMPORARY_LOCK, data, &reply), NO_ERROR);
std::vector<std::thread> ts;
for (size_t i = 0; i < kKernelThreads + 1; i++) {
@@ -1746,10 +1739,10 @@ TEST_F(BinderLibTest, HangingServices) {
for (auto &t : ts) {
t.join();
}
- size_t epochMsAfter = epochMillis();
+ int64_t timeAfter = uptimeMillis();
// deadlock occurred and threads only finished after 1s passed.
- EXPECT_GE(epochMsAfter, epochMsBefore + delay);
+ EXPECT_GE(timeAfter, timeBefore + delay);
}
TEST_F(BinderLibTest, BinderProxyCount) {