use super::backend;
use super::types::{
IncompleteExploration, MODEL_BROKE, PreemptionBounds, PreemptionModelResult, PreemptionOutcome,
PreemptionReading, PreemptionVerdict,
};
use crate::report::{
FailureClass, FindingLocation, InfrastructureFailure, InfrastructureFault, RunAttempt,
TrialConclusion, TrialFinding,
};
#[must_use]
pub fn explored(
bounds: PreemptionBounds,
model: fn() -> PreemptionModelResult,
) -> PreemptionReading {
backend::explored(bounds, model)
}
#[must_use]
pub fn attempted(reading: &PreemptionReading) -> RunAttempt {
match reading.outcome() {
PreemptionOutcome::Completed(PreemptionVerdict::AllInterleavingsHeld) => {
RunAttempt::Executed(TrialConclusion::Passed)
}
PreemptionOutcome::Completed(PreemptionVerdict::ModelBroke { report }) => {
RunAttempt::Executed(TrialConclusion::Refused(TrialFinding::established(
FailureClass::RefusedByCheck,
MODEL_BROKE,
FindingLocation::at(file!(), line!()),
report.clone(),
)))
}
PreemptionOutcome::Incomplete(IncompleteExploration::Unavailable) => {
RunAttempt::InfrastructureFailed(InfrastructureFailure::recorded(
InfrastructureFault::BackendUnavailable,
None,
))
}
PreemptionOutcome::Incomplete(IncompleteExploration::InitializationFailed { report }) => {
RunAttempt::InfrastructureFailed(InfrastructureFailure::recorded(
InfrastructureFault::BackendInitializationFailed,
report.clone(),
))
}
PreemptionOutcome::Incomplete(IncompleteExploration::ExecutionUnresolved { report }) => {
RunAttempt::InfrastructureFailed(InfrastructureFailure::recorded(
InfrastructureFault::BackendExecutionUnresolved,
report.clone(),
))
}
}
}