Files
@ 52ae67e7183e
Branch filter:
Location: CSY/reowolf/src/runtime/tests/speculation.rs - annotation
52ae67e7183e
2.3 KiB
application/rls-services+xml
Remove stale code in testing suite
a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 cb4c9d11dfe6 a2bfd792a202 a2bfd792a202 a2bfd792a202 cb4c9d11dfe6 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 a2bfd792a202 cb4c9d11dfe6 a2bfd792a202 a2bfd792a202 a2bfd792a202 cb4c9d11dfe6 a2bfd792a202 a2bfd792a202 | // Testing speculation - Basic forms
use super::*;
#[test]
fn test_maybe_do_nothing() {
// Three variants in which the behaviour in which nothing is performed is
// somehow not allowed. Note that we "check" by seeing if the test finishes.
// Only the branches in which ports fire increment the loop index
const CODE: &'static str = "
primitive only_puts(out<bool> output, u32 num_loops) {
u32 index = 0;
while (index < num_loops) {
sync { put(output, true); }
index += 1;
}
}
primitive might_put(out<bool> output, u32 num_loops) {
u32 index = 0;
while (index < num_loops) {
sync {
fork { put(output, true); index += 1; }
or {}
}
}
}
primitive only_gets(in<bool> input, u32 num_loops) {
u32 index = 0;
while (index < num_loops) {
sync { auto res = get(input); assert(res); }
index += 1;
}
}
primitive might_get(in<bool> input, u32 num_loops) {
u32 index = 0;
while (index < num_loops) {
sync fork { auto res = get(input); assert(res); index += 1; } or {}
}
}
";
// Construct all variants which should work and wait until the runtime exits
run_test_in_runtime(CODE, |api| {
// only putting -> maybe getting
let channel = api.create_channel().unwrap();
api.create_connector("", "only_puts", ValueGroup::new_stack(vec![
Value::Output(PortId::new(channel.putter_id.index)),
Value::UInt32(NUM_LOOPS),
])).unwrap();
api.create_connector("", "might_get", ValueGroup::new_stack(vec![
Value::Input(PortId::new(channel.getter_id.index)),
Value::UInt32(NUM_LOOPS),
])).unwrap();
// maybe putting -> only getting
let channel = api.create_channel().unwrap();
api.create_connector("", "might_put", ValueGroup::new_stack(vec![
Value::Output(PortId::new(channel.putter_id.index)),
Value::UInt32(NUM_LOOPS),
])).unwrap();
api.create_connector("", "only_gets", ValueGroup::new_stack(vec![
Value::Input(PortId::new(channel.getter_id.index)),
Value::UInt32(NUM_LOOPS),
])).unwrap();
})
}
|