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());
+}
diff --git a/subprojects/dhcp-done/test/meson.build b/subprojects/dhcp-done/test/meson.build
new file mode 100644
index 0000000..de5354f
--- /dev/null
+++ b/subprojects/dhcp-done/test/meson.build
@@ -0,0 +1,39 @@
+# Copyright 2024 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+gtest = dependency('gtest', main: true, disabler: true, required: false)
+if not gtest.found()
+  gtest_proj = import('cmake').subproject(
+    'googletest',
+    cmake_options: [
+      '-DCMAKE_CXX_FLAGS=-Wno-pedantic',
+    ],
+    required: false)
+  if gtest_proj.found()
+    gtest = declare_dependency(
+      dependencies: [
+        dependency('threads'),
+        gtest_proj.dependency('gtest'),
+        gtest_proj.dependency('gtest_main'),
+      ])
+  else
+    assert(not build_tests.allowed(), 'Googletest is required')
+  endif
+endif
+
+test('fileio_test', executable('fileio_test',
+  ['fileio_test.cpp'],
+  implicit_include_directories: false,
+  dependencies: [gtest, dependency('stdplus')],
+  link_with : fileio_lib))