blob: dec270c9cf5ced50ba0319e5edc349fbd32a2bab [file] [log] [blame] [edit]
/*
* 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.
*/
#include "health_scan.hpp"
#include "gBMCMachine.pb.h"
#include <fstream>
#include <iostream>
int main(int argc, char **argv)
{
gbmc::GBMCHost model;
if (argc != 2)
{
std::cerr << "Usage: " << argv[0] << " model.pb" << std::endl;
return 1;
}
{
std::ifstream proto_file(argv[1], std::ios::binary);
if (!proto_file.is_open())
{
std::cerr << "Failed to open " << argv[1] << std::endl;
return 1;
}
bool status = model.ParseFromIstream(&proto_file);
if (!status)
{
std::cerr << "Decode failed" << std::endl;
return 1;
}
}
std::cout << "Protobuf model for machine family: " << model.stable_name() << std::endl;
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;
}
}