Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8d5f1a4 authored by Steven Moreland's avatar Steven Moreland
Browse files

binderLibTest: epoch->uptime

NTP time reset during test causes flakes.

Fixes: 368314472
Test: TH
Change-Id: I759113d19721936336b355e0c363c18e7c3adfa1
parent 1e1a07f0
Loading
Loading
Loading
Loading
+4 −11
Original line number Diff line number Diff line
@@ -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>
@@ -1710,14 +1711,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();
@@ -1726,7 +1719,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++) {
@@ -1740,10 +1733,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) {