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_close_unittest.cpp b/bmc/firmware-handler/test/firmware_close_unittest.cpp
index 6d1fe55..2a722b6 100644
--- a/bmc/firmware-handler/test/firmware_close_unittest.cpp
+++ b/bmc/firmware-handler/test/firmware_close_unittest.cpp
@@ -28,7 +28,8 @@
* everything looks right.
*/
EXPECT_CALL(*dataMock, open()).WillOnce(Return(true));
- EXPECT_CALL(*hashImageMock, open(StrEq(hashBlobId))).WillOnce(Return(true));
+ EXPECT_CALL(*hashImageMock, open(StrEq(hashBlobId), std::ios::out))
+ .WillOnce(Return(true));
EXPECT_TRUE(handler->open(
0, blobs::OpenFlags::write | FirmwareFlags::UpdateFlags::lpc,
@@ -55,7 +56,8 @@
/* Boring test where you open a blob_id using ipmi, so there's no data
* handler, and it's closed and everything looks right.
*/
- EXPECT_CALL(*hashImageMock, open(StrEq(hashBlobId))).WillOnce(Return(true));
+ EXPECT_CALL(*hashImageMock, open(StrEq(hashBlobId), std::ios::out))
+ .WillOnce(Return(true));
EXPECT_TRUE(handler->open(
0, blobs::OpenFlags::write | FirmwareFlags::UpdateFlags::ipmi,