Files
@ 98bb2b044b92
Branch filter:
Location: CSY/reowolf/src/runtime2/tests/messaging.rs - annotation
98bb2b044b92
3.2 KiB
application/rls-services+xml
Fix bug related to transferred data messages
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 2811715674ea 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 2811715674ea 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 2811715674ea 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 2811715674ea 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 2811715674ea 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 2811715674ea 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 2811715674ea 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 2811715674ea 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 2811715674ea 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 38c129959044 | use super::*;
#[test]
fn test_component_communication() {
let pd = ProtocolDescription::parse(b"
comp sender(out<u32> o, u32 outside_loops, u32 inside_loops) {
u32 outside_index = 0;
while (outside_index < outside_loops) {
u32 inside_index = 0;
sync while (inside_index < inside_loops) {
put(o, inside_index);
inside_index += 1;
}
outside_index += 1;
}
}
comp receiver(in<u32> i, u32 outside_loops, u32 inside_loops) {
u32 outside_index = 0;
while (outside_index < outside_loops) {
u32 inside_index = 0;
sync while (inside_index < inside_loops) {
auto val = get(i);
while (val != inside_index) {} // infinite loop if incorrect value is received
inside_index += 1;
}
outside_index += 1;
}
}
comp constructor() {
channel o_orom -> i_orom;
channel o_mrom -> i_mrom;
channel o_ormm -> i_ormm;
channel o_mrmm -> i_mrmm;
// one round, one message per round
new sender(o_orom, 1, 1);
new receiver(i_orom, 1, 1);
// multiple rounds, one message per round
new sender(o_mrom, 5, 1);
new receiver(i_mrom, 5, 1);
// one round, multiple messages per round
new sender(o_ormm, 1, 5);
new receiver(i_ormm, 1, 5);
// multiple rounds, multiple messages per round
new sender(o_mrmm, 5, 5);
new receiver(i_mrmm, 5, 5);
}").expect("compilation");
let rt = Runtime::new(3, LOG_LEVEL, pd).unwrap();
create_component(&rt, "", "constructor", no_args());
}
#[test]
fn test_send_to_self() {
compile_and_create_component("
comp insane_in_the_membrane() {
channel a -> b;
sync {
put(a, 1);
auto v = get(b);
while (v != 1) {}
}
}
", "insane_in_the_membrane", no_args());
}
#[test]
fn test_intermediate_messenger() {
let pd = ProtocolDescription::parse(b"
comp receiver<T>(in<T> rx, u32 num) {
auto index = 0;
while (index < num) {
sync { auto v = get(rx); }
index += 1;
}
}
comp middleman<T>(in<T> rx, out<T> tx, u32 num) {
auto index = 0;
while (index < num) {
sync { put(tx, get(rx)); }
index += 1;
}
}
comp sender<T>(out<T> tx, u32 num) {
auto index = 0;
while (index < num) {
sync put(tx, 1337);
index += 1;
}
}
comp constructor_template<T>() {
auto num = 0;
channel<T> tx_a -> rx_a;
channel tx_b -> rx_b;
new sender(tx_a, 3);
new middleman(rx_a, tx_b, 3);
new receiver(rx_b, 3);
}
comp constructor() {
new constructor_template<u16>();
new constructor_template<u32>();
new constructor_template<u64>();
new constructor_template<s16>();
new constructor_template<s32>();
new constructor_template<s64>();
}
").expect("compilation");
let rt = Runtime::new(3, LOG_LEVEL, pd).unwrap();
create_component(&rt, "", "constructor", no_args());
}
|