Files @ 9972a4c3928b
Branch filter:

Location: CSY/reowolf/src/runtime2/tests/transfer_ports.rs - annotation

9972a4c3928b 4.7 KiB application/rls-services+xml Show Source Show as Raw Download as Raw
MH
Add extra transfer test, fix bug related to delayed update of consensus manager
ebea15dffde4
ebea15dffde4
ebea15dffde4
935c576f54d0
ebea15dffde4
ebea15dffde4
ebea15dffde4
ebea15dffde4
ebea15dffde4
ebea15dffde4
ebea15dffde4
ebea15dffde4
ebea15dffde4
ebea15dffde4
ebea15dffde4
ebea15dffde4
ebea15dffde4
ebea15dffde4
ebea15dffde4
ebea15dffde4
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
cdb4810532c2
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
cdb4810532c2
cdb4810532c2
cdb4810532c2
cdb4810532c2
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
cdb4810532c2
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
a1b2108ed856
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
9972a4c3928b
ebea15dffde4
use super::*;

#[test]
fn test_transfer_precreated_port_with_owned_peer() {
    compile_and_create_component("
    primitive port_sender(out<in<u32>> tx) {
        channel a -> b;
        sync put(tx, b);
    }

    primitive port_receiver(in<in<u32>> rx) {
        sync auto a = get(rx);
    }

    composite constructor() {
        channel a -> b;
        new port_sender(a);
        new port_receiver(b);
    }
    ", "constructor", no_args());
}

#[test]
fn test_transfer_precreated_port_with_foreign_peer() {
    compile_and_create_component("
    primitive port_sender(out<in<u32>> tx, in<u32> to_send) {
        sync put(tx, to_send);
    }

    primitive port_receiver(in<in<u32>> rx) {
        sync auto a = get(rx);
    }

    composite constructor() {
        channel tx -> rx;
        channel forgotten -> to_send;
        new port_sender(tx, to_send);
        new port_receiver(rx);
    }
    ", "constructor", no_args());
}

#[test]
fn test_transfer_synccreated_port() {
    compile_and_create_component("
    primitive port_sender(out<in<u32>> tx) {
        sync {
            channel a -> b;
            put(tx, b);
        }
    }

    primitive port_receiver(in<in<u32>> rx) {
        sync auto a = get(rx);
    }

    composite constructor() {
        channel a -> b;
        new port_sender(a);
        new port_receiver(b);
    }
    ", "constructor", no_args());
}

#[test]
fn test_transfer_precreated_port_with_owned_peer_and_communication() {
    compile_and_create_component("
    primitive port_sender(out<in<u32>> tx) {
        channel a -> b;
        sync put(tx, b);
        sync put(a, 1337);
    }

    primitive port_receiver(in<in<u32>> rx) {
        channel a -> b; // this is stupid, but we need to have a variable to use
        sync b = get(rx);
        u32 value = 0;
        sync value = get(b);
        while (value != 1337) {}
    }
    composite constructor() {
        channel a -> b;
        new port_sender(a);
        new port_receiver(b);
    }
    ", "constructor", no_args());
}

#[test]
fn test_transfer_precreated_port_with_foreign_peer_and_communication() {
    compile_and_create_component("
    primitive port_sender(out<in<u32>> tx, in<u32> to_send) {
        sync put(tx, to_send);
    }

    primitive message_transmitter(out<u32> tx) {
        sync put(tx, 1337);
    }

    primitive port_receiver(in<in<u32>> rx) {
        channel unused -> b;
        sync b = get(rx);
        u32 value = 0;
        sync value = get(b);
        while (value != 1337) {}
    }

    composite constructor() {
        channel port_tx -> port_rx;
        channel value_tx -> value_rx;
        new port_sender(port_tx, value_rx);
        new port_receiver(port_rx);
        new message_transmitter(value_tx);
    }
    ", "constructor", no_args());
}

#[test]
fn test_transfer_precreated_port_with_owned_peer_back_and_forth() {
    compile_and_create_component("
    primitive port_send_and_receive(out<in<u32>> tx, in<in<u32>> rx) {
        channel a -> b;
        sync {
            put(tx, b);
            b = get(rx);
        }
    }

    primitive port_receive_and_send(in<in<u32>> rx, out<in<u32>> tx) {
        channel unused -> transferred; // same problem as in different tests
        sync {
            transferred = get(rx);
            put(tx, transferred);
        }
    }

    composite constructor() {
        channel port_tx_forward -> port_rx_forward;
        channel port_tx_backward -> port_rx_backward;

        new port_send_and_receive(port_tx_forward, port_rx_backward);
        new port_receive_and_send(port_rx_forward, port_tx_backward);
    }", "constructor", no_args());
}

#[test]
fn test_transfer_precreated_port_with_foreign_peer_back_and_forth_and_communication() {
    compile_and_create_component("
    primitive port_send_and_receive(out<in<u32>> tx, in<in<u32>> rx, in<u32> to_transfer) {
        sync {
            put(tx, to_transfer);
            to_transfer = get(rx);
        }
        sync {
            auto value = get(to_transfer);
            while (value != 1337) {}
        }
    }

    primitive port_receive_and_send(in<in<u32>> rx, out<in<u32>> tx) {
        channel unused -> transferred;
        sync {
            transferred = get(rx);
            put(tx, transferred);
        }
    }

    primitive value_sender(out<u32> tx) {
        sync put(tx, 1337);
    }

    composite constructor() {
        channel port_tx_forward -> port_rx_forward;
        channel port_tx_backward -> port_rx_backward;
        channel message_tx -> message_rx;
        new port_send_and_receive(port_tx_forward, port_rx_backward, message_rx);
        new port_receive_and_send(port_rx_forward, port_tx_backward);
        new value_sender(message_tx);
    }
    ", "constructor", no_args());
}