06 - atomic update

This commit is contained in:
deeaitch committed 2026-10-20 12:27:04 -04:00
1 parent 6d63457737
commit 2bdacaf37a
21 files changed
+1302 -365

No files matched your search

@@ -0,0 +1,49 @@
#include "simulation.hpp"
#include <exception>
#include <iostream>
#include <stdexcept>
#include <string>
namespace model = ota::installation;
int main(int argc, char **argv) {
if (argc == 2 && std::string(argv[1]) == "--help") {
std::cout << "Usage: installation-simulate [all|--help]\n";
return 0;
}
if (argc > 2 || (argc == 2 && std::string(argv[1]) != "all")) {
std::cerr << "Usage: installation-simulate [all|--help]\n";
return 1;
}
try {
for (int cut = 0; cut <= model::installation_steps; ++cut) {
model::Storage storage;
{
model::Installer installer(storage);
for (int step = 0; step < cut; ++step) model::perform_step(installer, step);
}
model::Installer restarted(storage);
const auto action = restarted.recover();
std::cout << "Reset after " << cut << " steps: boot=" << model::boot_choice(storage.boot)
<< "; " << model::name(action) << '\n';
}
for (const auto result: {model::WriteResult::OldRecord, model::WriteResult::NewRecord, model::WriteResult::InvalidRecord}) {
model::Storage storage;
{
model::Installer installer(storage);
for (int step = 0; step < 5; ++step) model::perform_step(installer, step);
try {
installer.request_trial(result);
} catch (const std::runtime_error &error) {
std::cout << error.what() << '\n';
}
}
model::Installer restarted(storage);
std::cout << "Boot-state write outcome: " << model::name(restarted.recover()) << '\n';
}
} catch (const std::exception &error) {
std::cerr << error.what() << '\n';
return 1;
}
}