extend file_handler to support reads
Problem: the upcomming version handler will need to read from files.
Currently file hander (image handler) does not support reads.
Solution: Add read support by providing an optional mode parameter.
Tests added:
FileHanderTest added to
- Test out open for reads
- Test out reading out bytes and verifying size and content
- Test out trying to read beyond EOF
- Test out offset reads that go beyond EOF
Tested:
Existing unit tests pass
New unit tests for reading all pass
Signed-off-by: Jason Ling <jasonling@google.com>
Change-Id: Ie416a6b4b452d8d04fa158bd55989d07a891896f
diff --git a/bmc/firmware-handler/test/firmware_unittest.hpp b/bmc/firmware-handler/test/firmware_unittest.hpp
index e9db343..da2e8f7 100644
--- a/bmc/firmware-handler/test/firmware_unittest.hpp
+++ b/bmc/firmware-handler/test/firmware_unittest.hpp
@@ -76,11 +76,13 @@
{
if (blobId == hashBlobId)
{
- EXPECT_CALL(*hashImageMock, open(blobId)).WillOnce(Return(true));
+ EXPECT_CALL(*hashImageMock, open(blobId, std::ios::out))
+ .WillOnce(Return(true));
}
else
{
- EXPECT_CALL(*imageMock2, open(blobId)).WillOnce(Return(true));
+ EXPECT_CALL(*imageMock2, open(blobId, std::ios::out))
+ .WillOnce(Return(true));
}
if (blobId != hashBlobId)