Merge "Fix flakiness of sensor VTS test cases" into oreo-dev
diff --git a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index 8ac8a29..3ee44f3 100644
--- a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -1057,27 +1057,34 @@
"InputStream::setGain");
}
-static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize,
- uint32_t framesCount) {
+static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize, uint32_t framesCount,
+ bool allowSucceed) {
Result res;
- // Ignore output parameters as the call should fail
+ // Ignore output parameters.
ASSERT_OK(stream->prepareForReading(
frameSize, framesCount,
[&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
- EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
+ if (allowSucceed) {
+ auto status = {
+ Result::INVALID_ARGUMENTS, Result::OK,
+ };
+ EXPECT_RESULT(status, res);
+ } else {
+ EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
+ };
}
TEST_P(InputStreamTest, PrepareForReadingWithZeroBuffer) {
doc::test(
"Preparing a stream for reading with a 0 sized buffer should fail");
- testPrepareForReading(stream.get(), 0, 0);
+ testPrepareForReading(stream.get(), 0, 0, false /*allowSucceed*/);
}
TEST_P(InputStreamTest, PrepareForReadingWithHugeBuffer) {
doc::test(
"Preparing a stream for reading with a 2^32 sized buffer should fail");
- testPrepareForReading(stream.get(), 1,
- std::numeric_limits<uint32_t>::max());
+ testPrepareForReading(stream.get(), 1, std::numeric_limits<uint32_t>::max(),
+ false /*allowSucceed*/);
}
TEST_P(InputStreamTest, PrepareForReadingCheckOverflow) {
@@ -1085,7 +1092,8 @@
"Preparing a stream for reading with a overflowing sized buffer should "
"fail");
auto uintMax = std::numeric_limits<uint32_t>::max();
- testPrepareForReading(stream.get(), uintMax, uintMax);
+ // In O, the test fails for 32-bit HAL, and succeeds for 64-bit HAL.
+ testPrepareForReading(stream.get(), uintMax, uintMax, true /*allowSucceed*/);
}
TEST_P(InputStreamTest, GetInputFramesLost) {
@@ -1125,27 +1133,34 @@
"setVolume");
}
-static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize,
- uint32_t framesCount) {
+static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize, uint32_t framesCount,
+ bool allowSucceed) {
Result res;
- // Ignore output parameters as the call should fail
+ // Ignore output parameters.
ASSERT_OK(stream->prepareForWriting(
frameSize, framesCount,
[&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
- EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
+ if (allowSucceed) {
+ auto status = {
+ Result::INVALID_ARGUMENTS, Result::OK,
+ };
+ EXPECT_RESULT(status, res);
+ } else {
+ EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
+ };
}
TEST_P(OutputStreamTest, PrepareForWriteWithZeroBuffer) {
doc::test(
"Preparing a stream for writing with a 0 sized buffer should fail");
- testPrepareForWriting(stream.get(), 0, 0);
+ testPrepareForWriting(stream.get(), 0, 0, false /*allowSucceed*/);
}
TEST_P(OutputStreamTest, PrepareForWriteWithHugeBuffer) {
doc::test(
"Preparing a stream for writing with a 2^32 sized buffer should fail");
- testPrepareForWriting(stream.get(), 1,
- std::numeric_limits<uint32_t>::max());
+ testPrepareForWriting(stream.get(), 1, std::numeric_limits<uint32_t>::max(),
+ false /*allowSucceed*/);
}
TEST_P(OutputStreamTest, PrepareForWritingCheckOverflow) {
@@ -1153,7 +1168,8 @@
"Preparing a stream for writing with a overflowing sized buffer should "
"fail");
auto uintMax = std::numeric_limits<uint32_t>::max();
- testPrepareForWriting(stream.get(), uintMax, uintMax);
+ // In O, the test fails for 32-bit HAL, and succeeds for 64-bit HAL.
+ testPrepareForWriting(stream.get(), uintMax, uintMax, true /*allowSucceed*/);
}
struct Capability {
diff --git a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.cpp b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.cpp
index 33cf84c..68aede2 100644
--- a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.cpp
+++ b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerTestUtils.cpp
@@ -290,6 +290,11 @@
: IComposerClient::Vsync::DISABLE;
Error error = mClient->setVsyncEnabled(display, vsync);
ASSERT_EQ(Error::NONE, error) << "failed to set vsync mode";
+
+ // give the hwbinder thread some time to handle any pending vsync callback
+ if (!enabled) {
+ usleep(5 * 1000);
+ }
}
} // namespace tests
diff --git a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
index 387222f..4261d00 100644
--- a/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
+++ b/graphics/composer/2.1/vts/functional/VtsHalGraphicsComposerV2_1TargetTest.cpp
@@ -118,7 +118,7 @@
// the set of all currently connected displays
std::unordered_set<Display> mDisplays;
// true only when vsync is enabled
- bool mVsyncAllowed = false;
+ bool mVsyncAllowed = true;
// track invalid callbacks
int mInvalidHotplugCount = 0;
@@ -137,6 +137,10 @@
// assume the first display is primary and is never removed
mPrimaryDisplay = waitForFirstDisplay();
+
+ // explicitly disable vsync
+ mComposerClient->setVsyncEnabled(mPrimaryDisplay, false);
+ mComposerCallback->setVsyncAllowed(false);
}
void TearDown() override {