Files
@ 8fc9f53cc0f5
Branch filter:
Location: CSY/reowolf/src/test/setup.rs - annotation
8fc9f53cc0f5
3.6 KiB
application/rls-services+xml
more tests
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 | 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 0fb83f27a238 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 0fb83f27a238 0fb83f27a238 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 0fb83f27a238 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 0fb83f27a238 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 0fb83f27a238 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 0fb83f27a238 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 e71e02fb13d4 0fb83f27a238 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 0fb83f27a238 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 0fb83f27a238 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 | use crate::common::*;
use crate::runtime::*;
use PortBinding::*;
use super::*;
#[test]
fn config_ok_0() {
let pdl = b"primitive main() {}";
let d = ProtocolD::parse(pdl).unwrap();
let pol = d.component_polarities(b"main").unwrap();
assert_eq!(&pol[..], &[]);
}
#[test]
fn config_ok_2() {
let pdl = b"primitive main(in x, out y) {}";
let d = ProtocolD::parse(pdl).unwrap();
let pol = d.component_polarities(b"main").unwrap();
assert_eq!(&pol[..], &[Getter, Putter]);
}
#[test]
#[should_panic]
fn config_non_port() {
let pdl = b"primitive main(in q, int q) {}";
ProtocolD::parse(pdl).unwrap();
}
#[test]
fn config_and_connect_2() {
let timeout = Duration::from_millis(1_500);
let addrs = ["127.0.0.1:9000".parse().unwrap(), "127.0.0.1:9001".parse().unwrap()];
use std::thread;
let handles = vec![
//
thread::spawn(move || {
let mut x = Connector::Unconfigured(Unconfigured { controller_id: 0 });
x.configure(b"primitive main(in a, out b) {}", b"main").unwrap();
x.bind_port(0, Passive(addrs[0])).unwrap();
x.bind_port(1, Passive(addrs[1])).unwrap();
x.connect(timeout).unwrap();
}),
thread::spawn(move || {
let mut x = Connector::Unconfigured(Unconfigured { controller_id: 1 });
x.configure(b"primitive main(out a, in b) {}", b"main").unwrap();
x.bind_port(0, Active(addrs[0])).unwrap();
x.bind_port(1, Active(addrs[1])).unwrap();
x.connect(timeout).unwrap();
}),
];
for h in handles {
handle(h.join())
}
}
#[test]
fn bind_too_much() {
let mut x = Connector::Unconfigured(Unconfigured { controller_id: 0 });
x.configure(b"primitive main(in a) {}", b"main").unwrap();
x.bind_port(0, Native).unwrap();
assert!(x.bind_port(1, Native).is_err());
}
#[test]
fn config_and_connect_chain() {
let timeout = Duration::from_millis(1_500);
let addrs = [
"127.0.0.1:9002".parse().unwrap(),
"127.0.0.1:9003".parse().unwrap(),
"127.0.0.1:9004".parse().unwrap(),
];
use std::thread;
let handles = vec![
//
thread::spawn(move || {
// PRODUCER A->
let mut x = Connector::Unconfigured(Unconfigured { controller_id: 0 });
x.configure(b"primitive main(out a) {}", b"main").unwrap();
x.bind_port(0, Active(addrs[0])).unwrap();
x.connect(timeout).unwrap();
}),
thread::spawn(move || {
// FORWARDER ->B->
let mut x = Connector::Unconfigured(Unconfigured { controller_id: 1 });
x.configure(b"primitive main(in a, out b) {}", b"main").unwrap();
x.bind_port(0, Passive(addrs[0])).unwrap();
x.bind_port(1, Active(addrs[1])).unwrap();
x.connect(timeout).unwrap();
}),
thread::spawn(move || {
// FORWARDER ->C->
let mut x = Connector::Unconfigured(Unconfigured { controller_id: 2 });
x.configure(b"primitive main(in a, out b) {}", b"main").unwrap();
x.bind_port(0, Passive(addrs[1])).unwrap();
x.bind_port(1, Active(addrs[2])).unwrap();
x.connect(timeout).unwrap();
}),
thread::spawn(move || {
// CONSUMER ->D
let mut x = Connector::Unconfigured(Unconfigured { controller_id: 3 });
x.configure(b"primitive main(in a) {}", b"main").unwrap();
x.bind_port(0, Passive(addrs[2])).unwrap();
x.connect(timeout).unwrap();
}),
];
for h in handles {
handle(h.join())
}
}
|