summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Naganov2017-10-10 12:31:07 -0500
committerMikhail Naganov2017-10-10 16:30:00 -0500
commitce607879baf84d5b3a8df95a609ad06204c56711 (patch)
tree8b8e559c12d0884455b7a2f5e7d113b9a839b763
parent926a8e7440a0c85d39dbf7143bfe03964363ddec (diff)
downloadplatform-hardware-interfaces-ce607879baf84d5b3a8df95a609ad06204c56711.tar.gz
platform-hardware-interfaces-ce607879baf84d5b3a8df95a609ad06204c56711.tar.xz
platform-hardware-interfaces-ce607879baf84d5b3a8df95a609ad06204c56711.zip
Audio VTS: Allow 4GB buffer prepareToWrite/Read to succeed on 64 bits
Because on oc-dev the runtime image can not be modified and that this is not a bug but a test and implementation misalignment, allow prepareForWrite/Read(UINT32_MAX, UINT32_MAX) to succeed on oc-dev. MR1 will have a better fix where the HAL will always reject > 1GiB buffers independently of the architecture. Test: vts-tradefed run commandAndExit vts --module VtsHalAudioV2_0Target Bug: 67030516 Change-Id: I10a5ee3868c67c45ed5297d9c5c89129d762c7cd Merged-In: I4cc3efda9bb66e6dae8b4e6785f52d9e51440aee Signed-off-by: Kevin Rocard <krocard@google.com>
-rw-r--r--audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp48
1 files changed, 32 insertions, 16 deletions
diff --git a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index 8ac8a297..3ee44f33 100644
--- a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -1057,27 +1057,34 @@ TEST_P(InputStreamTest, SetGain) {
1057 "InputStream::setGain"); 1057 "InputStream::setGain");
1058} 1058}
1059 1059
1060static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize, 1060static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize, uint32_t framesCount,
1061 uint32_t framesCount) { 1061 bool allowSucceed) {
1062 Result res; 1062 Result res;
1063 // Ignore output parameters as the call should fail 1063 // Ignore output parameters.
1064 ASSERT_OK(stream->prepareForReading( 1064 ASSERT_OK(stream->prepareForReading(
1065 frameSize, framesCount, 1065 frameSize, framesCount,
1066 [&res](auto r, auto&, auto&, auto&, auto&) { res = r; })); 1066 [&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
1067 EXPECT_RESULT(Result::INVALID_ARGUMENTS, res); 1067 if (allowSucceed) {
1068 auto status = {
1069 Result::INVALID_ARGUMENTS, Result::OK,
1070 };
1071 EXPECT_RESULT(status, res);
1072 } else {
1073 EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
1074 };
1068} 1075}
1069 1076
1070TEST_P(InputStreamTest, PrepareForReadingWithZeroBuffer) { 1077TEST_P(InputStreamTest, PrepareForReadingWithZeroBuffer) {
1071 doc::test( 1078 doc::test(
1072 "Preparing a stream for reading with a 0 sized buffer should fail"); 1079 "Preparing a stream for reading with a 0 sized buffer should fail");
1073 testPrepareForReading(stream.get(), 0, 0); 1080 testPrepareForReading(stream.get(), 0, 0, false /*allowSucceed*/);
1074} 1081}
1075 1082
1076TEST_P(InputStreamTest, PrepareForReadingWithHugeBuffer) { 1083TEST_P(InputStreamTest, PrepareForReadingWithHugeBuffer) {
1077 doc::test( 1084 doc::test(
1078 "Preparing a stream for reading with a 2^32 sized buffer should fail"); 1085 "Preparing a stream for reading with a 2^32 sized buffer should fail");
1079 testPrepareForReading(stream.get(), 1, 1086 testPrepareForReading(stream.get(), 1, std::numeric_limits<uint32_t>::max(),
1080 std::numeric_limits<uint32_t>::max()); 1087 false /*allowSucceed*/);
1081} 1088}
1082 1089
1083TEST_P(InputStreamTest, PrepareForReadingCheckOverflow) { 1090TEST_P(InputStreamTest, PrepareForReadingCheckOverflow) {
@@ -1085,7 +1092,8 @@ TEST_P(InputStreamTest, PrepareForReadingCheckOverflow) {
1085 "Preparing a stream for reading with a overflowing sized buffer should " 1092 "Preparing a stream for reading with a overflowing sized buffer should "
1086 "fail"); 1093 "fail");
1087 auto uintMax = std::numeric_limits<uint32_t>::max(); 1094 auto uintMax = std::numeric_limits<uint32_t>::max();
1088 testPrepareForReading(stream.get(), uintMax, uintMax); 1095 // In O, the test fails for 32-bit HAL, and succeeds for 64-bit HAL.
1096 testPrepareForReading(stream.get(), uintMax, uintMax, true /*allowSucceed*/);
1089} 1097}
1090 1098
1091TEST_P(InputStreamTest, GetInputFramesLost) { 1099TEST_P(InputStreamTest, GetInputFramesLost) {
@@ -1125,27 +1133,34 @@ TEST_P(OutputStreamTest, setVolume) {
1125 "setVolume"); 1133 "setVolume");
1126} 1134}
1127 1135
1128static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize, 1136static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize, uint32_t framesCount,
1129 uint32_t framesCount) { 1137 bool allowSucceed) {
1130 Result res; 1138 Result res;
1131 // Ignore output parameters as the call should fail 1139 // Ignore output parameters.
1132 ASSERT_OK(stream->prepareForWriting( 1140 ASSERT_OK(stream->prepareForWriting(
1133 frameSize, framesCount, 1141 frameSize, framesCount,
1134 [&res](auto r, auto&, auto&, auto&, auto&) { res = r; })); 1142 [&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
1135 EXPECT_RESULT(Result::INVALID_ARGUMENTS, res); 1143 if (allowSucceed) {
1144 auto status = {
1145 Result::INVALID_ARGUMENTS, Result::OK,
1146 };
1147 EXPECT_RESULT(status, res);
1148 } else {
1149 EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
1150 };
1136} 1151}
1137 1152
1138TEST_P(OutputStreamTest, PrepareForWriteWithZeroBuffer) { 1153TEST_P(OutputStreamTest, PrepareForWriteWithZeroBuffer) {
1139 doc::test( 1154 doc::test(
1140 "Preparing a stream for writing with a 0 sized buffer should fail"); 1155 "Preparing a stream for writing with a 0 sized buffer should fail");
1141 testPrepareForWriting(stream.get(), 0, 0); 1156 testPrepareForWriting(stream.get(), 0, 0, false /*allowSucceed*/);
1142} 1157}
1143 1158
1144TEST_P(OutputStreamTest, PrepareForWriteWithHugeBuffer) { 1159TEST_P(OutputStreamTest, PrepareForWriteWithHugeBuffer) {
1145 doc::test( 1160 doc::test(
1146 "Preparing a stream for writing with a 2^32 sized buffer should fail"); 1161 "Preparing a stream for writing with a 2^32 sized buffer should fail");
1147 testPrepareForWriting(stream.get(), 1, 1162 testPrepareForWriting(stream.get(), 1, std::numeric_limits<uint32_t>::max(),
1148 std::numeric_limits<uint32_t>::max()); 1163 false /*allowSucceed*/);
1149} 1164}
1150 1165
1151TEST_P(OutputStreamTest, PrepareForWritingCheckOverflow) { 1166TEST_P(OutputStreamTest, PrepareForWritingCheckOverflow) {
@@ -1153,7 +1168,8 @@ TEST_P(OutputStreamTest, PrepareForWritingCheckOverflow) {
1153 "Preparing a stream for writing with a overflowing sized buffer should " 1168 "Preparing a stream for writing with a overflowing sized buffer should "
1154 "fail"); 1169 "fail");
1155 auto uintMax = std::numeric_limits<uint32_t>::max(); 1170 auto uintMax = std::numeric_limits<uint32_t>::max();
1156 testPrepareForWriting(stream.get(), uintMax, uintMax); 1171 // In O, the test fails for 32-bit HAL, and succeeds for 64-bit HAL.
1172 testPrepareForWriting(stream.get(), uintMax, uintMax, true /*allowSucceed*/);
1157} 1173}
1158 1174
1159struct Capability { 1175struct Capability {