SF: call the timer's callback in case of an error
Bug: 210065990
Test: new SF unit test
Change-Id: I4ae70e82e9402fc7d7eecc1a17c1b992eb3efab6
diff --git a/services/surfaceflinger/tests/unittests/TimerTest.cpp b/services/surfaceflinger/tests/unittests/TimerTest.cpp
index cda6bbf..0a3639d 100644
--- a/services/surfaceflinger/tests/unittests/TimerTest.cpp
+++ b/services/surfaceflinger/tests/unittests/TimerTest.cpp
@@ -26,11 +26,19 @@
namespace android::scheduler {
+struct TestableTimer : public Timer {
+public:
+ void makeEpollError() {
+ // close the epoll file descriptor to cause an epoll error
+ close(mEpollFd);
+ }
+};
+
struct TimerTest : testing::Test {
static constexpr int mIterations = 20;
AsyncCallRecorder<void (*)()> mCallbackRecorder;
- Timer mTimer;
+ TestableTimer mTimer;
void timerCallback() { mCallbackRecorder.recordCall(); }
};
@@ -42,4 +50,14 @@
EXPECT_FALSE(mCallbackRecorder.waitForUnexpectedCall().has_value());
}
}
+
+TEST_F(TimerTest, recoversAfterEpollError) {
+ for (int i = 0; i < mIterations; i++) {
+ mTimer.makeEpollError();
+ mTimer.alarmAt(std::bind(&TimerTest::timerCallback, this), systemTime() - 10'000'00);
+ EXPECT_TRUE(mCallbackRecorder.waitForCall().has_value());
+ EXPECT_FALSE(mCallbackRecorder.waitForUnexpectedCall().has_value());
+ }
+}
+
} // namespace android::scheduler