Skip to content

Commit 526a2f8

Browse files
Treehugger Robotandroid-build-merge-worker-robot
authored andcommitted
Merge "binderLibTest: epoch->uptime" into main am: 3987d12 am: a2466e0
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/3391722 Change-Id: Ic2f43d4a63877bb2635c2f966e373d8d7d26e28d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2 parents 87db06e + a2466e0 commit 526a2f8

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

libs/binder/tests/binderLibTest.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <input/BlockingQueue.h>
4444
#include <processgroup/processgroup.h>
4545
#include <utils/Flattenable.h>
46+
#include <utils/SystemClock.h>
4647

4748
#include <linux/sched.h>
4849
#include <sys/epoll.h>
@@ -1837,14 +1838,6 @@ TEST_F(BinderLibTest, ThreadPoolStarted) {
18371838
EXPECT_TRUE(reply.readBool());
18381839
}
18391840

1840-
size_t epochMillis() {
1841-
using std::chrono::duration_cast;
1842-
using std::chrono::milliseconds;
1843-
using std::chrono::seconds;
1844-
using std::chrono::system_clock;
1845-
return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
1846-
}
1847-
18481841
TEST_F(BinderLibTest, HangingServices) {
18491842
Parcel data, reply;
18501843
sp<IBinder> server = addServer();
@@ -1853,7 +1846,7 @@ TEST_F(BinderLibTest, HangingServices) {
18531846
data.writeInt32(delay);
18541847
// b/266537959 - must take before taking lock, since countdown is started in the remote
18551848
// process there.
1856-
size_t epochMsBefore = epochMillis();
1849+
int64_t timeBefore = uptimeMillis();
18571850
EXPECT_THAT(server->transact(BINDER_LIB_TEST_PROCESS_TEMPORARY_LOCK, data, &reply), NO_ERROR);
18581851
std::vector<std::thread> ts;
18591852
for (size_t i = 0; i < kKernelThreads + 1; i++) {
@@ -1867,10 +1860,10 @@ TEST_F(BinderLibTest, HangingServices) {
18671860
for (auto &t : ts) {
18681861
t.join();
18691862
}
1870-
size_t epochMsAfter = epochMillis();
1863+
int64_t timeAfter = uptimeMillis();
18711864

18721865
// deadlock occurred and threads only finished after 1s passed.
1873-
EXPECT_GE(epochMsAfter, epochMsBefore + delay);
1866+
EXPECT_GE(timeAfter, timeBefore + delay);
18741867
}
18751868

18761869
TEST_F(BinderLibTest, BinderProxyCount) {

0 commit comments

Comments
 (0)