Changeset - 0b0b0a9c786b
[Not reviewed]
0 1 0
MH - 3 years ago 2022-02-02 16:21:27
contact@maxhenger.nl
WIP: Restructured test, new bugs
1 file changed with 39 insertions and 34 deletions:
0 comments (0 inline, 0 general)
src/runtime2/tests/mod.rs
Show inline comments
 
@@ -30,50 +30,55 @@ fn test_component_creation() {
 
    }
 
}
 

	
 
#[test]
 
fn test_component_communication_a() {
 
    let pd = ProtocolDescription::parse(b"
 
    primitive sender(out<u32> o) {
 
        sync put(o, 1);
 
    }
 
    primitive receiver(in<u32> i) {
 
        sync auto a = get(i);
 
    }
 
    composite constructor() {
 
        channel o -> i;
 
        new sender(o);
 
        new receiver(i);
 
    }
 
    ").expect("compilation");
 
    let rt = Runtime::new(1, pd);
 

	
 
    create_component(&rt, "", "constructor", no_args());
 
}
 

	
 
#[test]
 
fn test_component_communication_b() {
 
    let pd = ProtocolDescription::parse(b"
 
    primitive sender(out<u32> o, u32 rounds) {
 
        u32 index = 0;
 
        sync while (index < rounds) {
 
            put(o, index);
 
            index += 1;
 
    primitive 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;
 
        }
 
    }
 

	
 
    primitive receiver(in<u32> i, u32 rounds) {
 
        u32 index = 0;
 
        sync while (index < rounds) {
 
            auto val = get(i);
 
            while (val != index) {} // infinite loop if incorrect value is received
 
            index += 1;
 
    primitive 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;
 
        }
 
    }
 

	
 
    composite constructor() {
 
        channel o -> i;
 
        new sender(o, 5);
 
        new receiver(i, 5);
 
        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(1, pd);
 
    create_component(&rt, "", "constructor", no_args());
0 comments (0 inline, 0 general)