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/image_mock.hpp b/bmc/firmware-handler/test/image_mock.hpp
index fb10c39..2a967ac 100644
--- a/bmc/firmware-handler/test/image_mock.hpp
+++ b/bmc/firmware-handler/test/image_mock.hpp
@@ -11,10 +11,11 @@
{
public:
virtual ~ImageHandlerMock() = default;
-
- MOCK_METHOD1(open, bool(const std::string&));
+ MOCK_METHOD2(open, bool(const std::string&, std::ios_base::openmode));
MOCK_METHOD0(close, void());
MOCK_METHOD2(write, bool(std::uint32_t, const std::vector<std::uint8_t>&));
+ MOCK_METHOD2(read, std::optional<std::vector<std::uint8_t>>(std::uint32_t,
+ std::uint32_t));
MOCK_METHOD0(getSize, int());
};