Validate profile databases and make the power check meaningful
source-pr / source (pull_request) Successful in 12s
source-pr / source (pull_request) Successful in 12s
--check-profiles parses a database and reports schema, count and validation, so envelope work can be checked before an image ever boots with it. An inverted envelope is rejected with a non-zero exit. The conformance power check now sets 500 MHz before reading, because a backend that always reports 0 W passed a range check while being useless to a power-target loop. It must now report a plausible non-zero draw at a known operating point.
This commit is contained in:
+16
-5
@@ -143,11 +143,22 @@ fn check_power(socket: &Path) -> Check {
|
||||
Ok(mask) if mask & CAP_POWER == 0 => {
|
||||
Check::fail(NAME, "backend does not advertise power telemetry")
|
||||
}
|
||||
Ok(_) => match client.read_power_w() {
|
||||
Ok(watts) if watts <= 10_000 => Check::pass(NAME, format!("{watts} W")),
|
||||
Ok(watts) => Check::fail(NAME, format!("implausible power {watts} W")),
|
||||
Err(error) => Check::fail(NAME, format!("{error:?}")),
|
||||
},
|
||||
Ok(_) => {
|
||||
// Ask for a known operating point first: a backend that always reports 0 W would
|
||||
// otherwise pass a range check while being useless to a power-target loop.
|
||||
if let Err(error) = client.set_chain_frequency(0, 500) {
|
||||
return Check::fail(NAME, format!("set frequency: {error:?}"));
|
||||
}
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
match client.read_power_w() {
|
||||
Ok(0) => Check::fail(NAME, "reports 0 W at 500 MHz"),
|
||||
Ok(watts) if watts <= 10_000 => {
|
||||
Check::pass(NAME, format!("{watts} W at 500 MHz"))
|
||||
}
|
||||
Ok(watts) => Check::fail(NAME, format!("implausible power {watts} W")),
|
||||
Err(error) => Check::fail(NAME, format!("{error:?}")),
|
||||
}
|
||||
}
|
||||
Err(error) => Check::fail(NAME, format!("{error:?}")),
|
||||
},
|
||||
Err(error) => Check::fail(NAME, error),
|
||||
|
||||
+26
-1
@@ -334,6 +334,31 @@ fn main() {
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
Some("--check-profiles") => {
|
||||
let path = match args.next() {
|
||||
Some(path) => path,
|
||||
None => {
|
||||
eprintln!("usage: alkane-os --check-profiles PATH");
|
||||
std::process::exit(2);
|
||||
}
|
||||
};
|
||||
let text = match std::fs::read_to_string(&path) {
|
||||
Ok(text) => text,
|
||||
Err(error) => {
|
||||
eprintln!("cannot read {path}: {error}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
match alkane_os::profiles::ProfileDb::from_json(&text) {
|
||||
Ok(db) => {
|
||||
println!("{} profiles, schema 1, validated", db.len());
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!("profile database rejected: {error:?}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some("--check-hal") => {
|
||||
let socket = match args.next() {
|
||||
Some(path) => path,
|
||||
@@ -372,7 +397,7 @@ fn main() {
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
eprintln!("usage: alkane-os --list-targets | --version | --self-check | --boot HAL_SOCKET PROFILES.json TARGET [PIC|NOPIC] [TICKS] | --sim-hal SOCKET | --check-hal SOCKET | --mine-simulator HAL_SOCKET POOL_ADDRESS WORKER BM1362|BM1366 [MAX_ACCEPTS]");
|
||||
eprintln!("usage: alkane-os --list-targets | --version | --self-check | --boot HAL_SOCKET PROFILES.json TARGET [PIC|NOPIC] [TICKS] | --sim-hal SOCKET | --check-hal SOCKET | --check-profiles PATH | --mine-simulator HAL_SOCKET POOL_ADDRESS WORKER BM1362|BM1366 [MAX_ACCEPTS]");
|
||||
eprintln!(
|
||||
"env: ALKANE_API_LISTEN=ADDR ALKANE_WEB_LISTEN=ADDR ALKANE_POOL_PASSWORD=..."
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user