use super::*;

#[test]
fn exact_grid_and_parameters_cover_extreme_count_without_rounding() {
    for count in [0, 1, 63, 64, 65, u32::MAX] {
        assert_eq!(grid(count, 64, (64, 1, 1)).unwrap(), count as usize);
    }
    for limits in [
        (63, (64, 1, 1)),
        (64, (63, 1, 1)),
        (64, (64, 0, 1)),
        (64, (64, 1, 0)),
    ] {
        assert!(grid(1, limits.0, limits.1).is_err());
    }
    assert_eq!(
        parameters(0x0706_0504_0302_0100, 0x0f0e_0d0c_0b0a_0908, 0x1312_1110),
        [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 0, 0, 0]
    );
}

#[test]
fn simulated_completion_facts_gate_both_owners_including_zero_count() {
    let gpu = Gpu::open().unwrap();
    let mut table = RTable::open(&gpu, 1).unwrap();
    let mut probe = Probe::open(&gpu).unwrap();
    for status in [0, 1, 2, 3, 4, 5, u64::MAX] {
        for has_error in [false, true] {
            table.close();
            probe.failed = true;
            let error = has_error.then(|| "simulated native error".to_owned());
            let result = probe.completed(&mut table, status, error);
            if status == Commands::STATUS_COMPLETED && !has_error {
                result.unwrap();
                assert!(!probe.failed);
                assert!(table.bytes().is_ok());
                assert_eq!(probe.run(&mut table, 0, 0).unwrap(), 0);
            } else {
                assert!(result
                    .unwrap_err()
                    .to_string()
                    .contains(&format!("status {status}")));
                assert!(probe.failed);
                assert!(matches!(table.bytes(), Err(BenchError::Unavailable)));
                assert!(matches!(
                    probe.run(&mut table, 0, 0),
                    Err(BenchError::Unavailable)
                ));
                assert!(matches!(
                    table.build_parallel(0, 1),
                    Err(BenchError::Unavailable)
                ));
            }
        }
    }
}

#[test]
fn unavailable_probe_rejects_an_independent_usable_table_without_changes() {
    let gpu = Gpu::open().unwrap();
    let mut table = RTable::open(&gpu, 3).unwrap();
    table.build_parallel(7, 2).unwrap();
    let before = table.bytes().unwrap().to_vec();
    let mut probe = Probe::open(&gpu).unwrap();
    probe.failed = true;
    assert!(matches!(
        probe.run(&mut table, 0, 1),
        Err(BenchError::Unavailable)
    ));
    assert_eq!(table.bytes().unwrap(), before);
    table.build_parallel(8, 1).unwrap();
}

Homonyms

warriors/trisha/rs/lower/tests.rs
cyb/honeycrisp/aruminium/src/tests.rs
soft3/radio/iroh-blobs/src/tests.rs
neural/trident/src/neural/tests.rs
soft3/lens/cli/src/tests.rs
neural/trident/src/deploy/tests.rs
neural/trident/src/package/registry/tests.rs
neural/trident/src/lsp/semantic/tests.rs
neural/trident/src/verify/sym/tests.rs
cyb/wysm/crates/wasmi/src/tests.rs
soft3/radio/cyber-bao/src/tree/tests.rs
neural/trident/src/verify/report/tests.rs
neural/trident/src/config/resolve/tests.rs
neural/trident/src/verify/solve/tests.rs
neural/trident/src/syntax/grammar/tests.rs
neural/trident/src/package/hash/tests.rs
neural/trident/src/lsp/util/tests.rs
neural/trident/src/config/scaffold/tests.rs
neural/trident/src/verify/synthesize/tests.rs
neural/trident/src/package/manifest/tests.rs
neural/trident/src/verify/equiv/tests.rs
neural/trident/src/verify/smt/tests.rs
soft3/radio/quinn/quinn-udp/tests/tests.rs
cyb/honeycrisp/aruminium/src/render/tests.rs
warriors/trisha/rs/lower/legalize/tests.rs
soft3/radio/quinn/quinn/src/tests.rs
cyb/wysm/crates/collections/src/tests.rs
cyb/honeycrisp/unimem/src/block/tests.rs
cyb/wysm/crates/cli/src/tests.rs
neural/trident/src/package/store/tests.rs
warriors/trisha/rs/cost/stack_verifier/tests.rs
soft3/radio/cyber-bao/src/group/tests.rs
neural/trident/src/syntax/lexer/tests.rs
neural/trident/src/syntax/format/tests.rs
cyb/wysm/crates/core/src/table/tests.rs
soft3/radio/quinn/quinn-proto/src/range_set/tests.rs
neural/trident/src/neural/data/tir_graph/tests.rs
cyb/wysm/crates/wasmi/src/instance/tests.rs
warriors/erga/rs/mine-bench/src/texture_ffi/tests.rs
warriors/erga/rs/blake-bench/src/batch/tests.rs
neural/trident/src/ir/tir/optimize/tests.rs
soft3/zheng/rs/src/ccs/universal/tests.rs
neural/trident/src/ir/tir/stack/tests.rs
warriors/erga/rs/rtable-bench/src/table/tests.rs
cyb/evy/forks/bevy_ecs/src/bundle/tests.rs
warriors/erga/rs/mine-bench/src/owner/tests.rs
cyb/wysm/crates/core/src/memory/tests.rs
cyb/wysm/crates/wasmi/src/module/instantiate/tests.rs
cyb/wysm/crates/wasmi/src/engine/limits/tests.rs
cyb/evy/forks/naga/src/front/wgsl/tests.rs
warriors/erga/rs/mine-bench/src/cli/timed/tests.rs

Graph