meta-google: dhcp-done: Adding status report
Previously dhcp-done only sends status code, this one provides the
capability to send status code + status message for better
troubleshooting.
Provide a way to let other process upgrade the status.
Tested: Unit test passed.
Change-Id: I9c689f90502a32b586c41e3491ad47ebc78fcc38
Signed-off-by: Yuxiao Zhang <yuxiaozhang@google.com>
diff --git a/subprojects/dhcp-done/test/fileio_test.cpp b/subprojects/dhcp-done/test/fileio_test.cpp
new file mode 100644
index 0000000..8a79cf2
--- /dev/null
+++ b/subprojects/dhcp-done/test/fileio_test.cpp
@@ -0,0 +1,34 @@
+#include "../file-io.hpp"
+
+#include <stdio.h>
+#include <sys/file.h>
+#include <unistd.h>
+
+#include <fstream>
+#include <iostream>
+#include <string>
+
+#include <gtest/gtest.h>
+
+TEST(TestFileIO, TestFileReadWrite)
+{
+ std::string testFile = "./tmp_test_file";
+
+ std::string testStatus, testStatusUpdated;
+
+ testStatus.push_back(2);
+ testStatus.append("image downloading in progress");
+
+ testStatusUpdated.push_back(0);
+ testStatusUpdated.append("finished netboot");
+
+ fileWrite(testFile, testStatus);
+
+ EXPECT_TRUE(testStatus == fileRead(testFile));
+
+ fileWrite(testFile, testStatusUpdated);
+
+ EXPECT_TRUE(testStatusUpdated == fileRead(testFile));
+
+ remove(testFile.c_str());
+}