diff --git a/src/hal_conformance.rs b/src/hal_conformance.rs index fda3da7..4ec6adc 100644 --- a/src/hal_conformance.rs +++ b/src/hal_conformance.rs @@ -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), diff --git a/src/main.rs b/src/main.rs index d7aa401..c92f828 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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=..." );