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/firmware_handler.cpp b/bmc/firmware-handler/firmware_handler.cpp
index d71cc9f..f5f1023 100644
--- a/bmc/firmware-handler/firmware_handler.cpp
+++ b/bmc/firmware-handler/firmware_handler.cpp
@@ -458,7 +458,7 @@
}
/* Ok, so we found a handler that matched, so call open() */
- if (!h->handler->open(path))
+ if (!h->handler->open(path, std::ios::out))
{
return false;
}