Add checkpoint while reboot complete
Tested:
https://paste.googleplex.com/5185217167622144?raw
Change-Id: I520d38b2a69343059e65c81fabdd044cc1b5d23a
Google-Bug-Id: 369744413
Signed-off-by: Jack Huang <huangweichieh@google.com>
diff --git a/include/resource.hpp b/include/resource.hpp
index bfc6e21..75e5d52 100644
--- a/include/resource.hpp
+++ b/include/resource.hpp
@@ -25,6 +25,8 @@
/** @brief Default directory for storing boot time monitor data files. */
extern std::string BTMonitorDir;
+/** @brief Reboot complete checkpoint name */
+const std::string kRebootCompleteCheckpoint = "RebootEnd";
/** @brief Suffix appended to filenames when a boot cycle is completed. */
const std::string kCompletedSuffix = ".completed";
/** @brief Suffix added to a checkpoint name to indicate the start of a
diff --git a/src/resource.cpp b/src/resource.cpp
index 8c6f176..a78e442 100644
--- a/src/resource.cpp
+++ b/src/resource.cpp
@@ -85,7 +85,6 @@
}
AppendCheckpointToFile(std::string(name), wallTime, upTime.value());
- // TODO(@huangweichieh): Check reboot complete.
}
void File::SetDuration(std::string_view name, int64_t duration)
@@ -121,6 +120,7 @@
void File::MarkComplete()
{
+ SetCheckpoint(kRebootCompleteCheckpoint, 0, 0);
std::swap(mCheckpointCompletedCache, mCheckpointCache);
mCheckpointCache.clear();
std::swap(mDurationCompletedCache, mDurationCache);
diff --git a/test/api_test.cpp b/test/api_test.cpp
index f6b3c56..c70a6ca 100644
--- a/test/api_test.cpp
+++ b/test/api_test.cpp
@@ -224,9 +224,10 @@
// Mark the initial set as complete
api->NotifyNodeComplete(host4NodeConfig);
- // GetCheckpointList should return the *completed* list
+ // GetCheckpointList should return the *completed* list, also add one to the
+ // "RebootEnd" checkpoint
EXPECT_EQ(api->GetNodeCheckpointList(host4NodeConfig).size(),
- expectedLines);
+ expectedLines + 1);
// Set a new checkpoint (part of the *next* boot cycle)
api->SetNodeCheckpoint(host4NodeConfig, "NewCycleCheckpoint", 0, 0);