Create Checker class
Each implementation of this class will perform a different type of
health check.
Tested:
$ ./health-scan gBMCExample.pb
Protobuf model for machine family: Example
Verified that model matches current hardware
Signed-off-by: Benjamin Fair <benjaminfair@google.com>
Change-Id: I360539f913cfc659fc658b949a3a0f1ce102e5e3
diff --git a/src/health_scan.cpp b/src/health_scan.cpp
index 2ea2ac7..dec270c 100644
--- a/src/health_scan.cpp
+++ b/src/health_scan.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include "health_scan.hpp"
+
#include "gBMCMachine.pb.h"
#include <fstream>
@@ -48,5 +50,27 @@
std::cout << "Protobuf model for machine family: " << model.stable_name() << std::endl;
- return 0;
+ std::vector<std::unique_ptr<Checker>> checkers;
+
+ bool pass = true;
+
+ for (auto& checker : checkers)
+ {
+ std::cout << "Running " << checker->name() << "..." << std::endl;
+ if (!checker->run())
+ {
+ pass = false;
+ }
+ }
+
+ if (pass)
+ {
+ std::cout << "Verified that model matches current hardware" << std::endl;
+ return 0;
+ }
+ else
+ {
+ std::cout << "One or more devices from the model didn't match current hardware" << std::endl;
+ return 1;
+ }
}
diff --git a/src/health_scan.hpp b/src/health_scan.hpp
new file mode 100644
index 0000000..30985fe
--- /dev/null
+++ b/src/health_scan.hpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2025 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.
+ */
+
+#pragma once
+
+#include <string>
+
+class Checker {
+ public:
+ virtual bool run() = 0;
+ virtual std::string_view name() = 0;
+};
+