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

Commit ce607879 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

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: default avatarKevin Rocard <krocard@google.com>
parent 926a8e74
Loading
Loading
Loading
Loading
+32 −16
Original line number Original line Diff line number Diff line
@@ -1057,27 +1057,34 @@ TEST_P(InputStreamTest, SetGain) {
        "InputStream::setGain");
        "InputStream::setGain");
}
}


static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize,
static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize, uint32_t framesCount,
                                  uint32_t framesCount) {
                                  bool allowSucceed) {
    Result res;
    Result res;
    // Ignore output parameters as the call should fail
    // Ignore output parameters.
    ASSERT_OK(stream->prepareForReading(
    ASSERT_OK(stream->prepareForReading(
        frameSize, framesCount,
        frameSize, framesCount,
        [&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
        [&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
    if (allowSucceed) {
        auto status = {
            Result::INVALID_ARGUMENTS, Result::OK,
        };
        EXPECT_RESULT(status, res);
    } else {
        EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
        EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
    };
}
}


TEST_P(InputStreamTest, PrepareForReadingWithZeroBuffer) {
TEST_P(InputStreamTest, PrepareForReadingWithZeroBuffer) {
    doc::test(
    doc::test(
        "Preparing a stream for reading with a 0 sized buffer should fail");
        "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) {
TEST_P(InputStreamTest, PrepareForReadingWithHugeBuffer) {
    doc::test(
    doc::test(
        "Preparing a stream for reading with a 2^32 sized buffer should fail");
        "Preparing a stream for reading with a 2^32 sized buffer should fail");
    testPrepareForReading(stream.get(), 1,
    testPrepareForReading(stream.get(), 1, std::numeric_limits<uint32_t>::max(),
                          std::numeric_limits<uint32_t>::max());
                          false /*allowSucceed*/);
}
}


TEST_P(InputStreamTest, PrepareForReadingCheckOverflow) {
TEST_P(InputStreamTest, PrepareForReadingCheckOverflow) {
@@ -1085,7 +1092,8 @@ TEST_P(InputStreamTest, PrepareForReadingCheckOverflow) {
        "Preparing a stream for reading with a overflowing sized buffer should "
        "Preparing a stream for reading with a overflowing sized buffer should "
        "fail");
        "fail");
    auto uintMax = std::numeric_limits<uint32_t>::max();
    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) {
TEST_P(InputStreamTest, GetInputFramesLost) {
@@ -1125,27 +1133,34 @@ TEST_P(OutputStreamTest, setVolume) {
        "setVolume");
        "setVolume");
}
}


static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize,
static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize, uint32_t framesCount,
                                  uint32_t framesCount) {
                                  bool allowSucceed) {
    Result res;
    Result res;
    // Ignore output parameters as the call should fail
    // Ignore output parameters.
    ASSERT_OK(stream->prepareForWriting(
    ASSERT_OK(stream->prepareForWriting(
        frameSize, framesCount,
        frameSize, framesCount,
        [&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
        [&res](auto r, auto&, auto&, auto&, auto&) { res = r; }));
    if (allowSucceed) {
        auto status = {
            Result::INVALID_ARGUMENTS, Result::OK,
        };
        EXPECT_RESULT(status, res);
    } else {
        EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
        EXPECT_RESULT(Result::INVALID_ARGUMENTS, res);
    };
}
}


TEST_P(OutputStreamTest, PrepareForWriteWithZeroBuffer) {
TEST_P(OutputStreamTest, PrepareForWriteWithZeroBuffer) {
    doc::test(
    doc::test(
        "Preparing a stream for writing with a 0 sized buffer should fail");
        "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) {
TEST_P(OutputStreamTest, PrepareForWriteWithHugeBuffer) {
    doc::test(
    doc::test(
        "Preparing a stream for writing with a 2^32 sized buffer should fail");
        "Preparing a stream for writing with a 2^32 sized buffer should fail");
    testPrepareForWriting(stream.get(), 1,
    testPrepareForWriting(stream.get(), 1, std::numeric_limits<uint32_t>::max(),
                          std::numeric_limits<uint32_t>::max());
                          false /*allowSucceed*/);
}
}


TEST_P(OutputStreamTest, PrepareForWritingCheckOverflow) {
TEST_P(OutputStreamTest, PrepareForWritingCheckOverflow) {
@@ -1153,7 +1168,8 @@ TEST_P(OutputStreamTest, PrepareForWritingCheckOverflow) {
        "Preparing a stream for writing with a overflowing sized buffer should "
        "Preparing a stream for writing with a overflowing sized buffer should "
        "fail");
        "fail");
    auto uintMax = std::numeric_limits<uint32_t>::max();
    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 {
struct Capability {