Files
@ 9154f8a5674d
Branch filter:
Location: CSY/reowolf/src/test/connector.rs - annotation
9154f8a5674d
5.4 KiB
application/rls-services+xml
Merge branch 'master' of github.com:sirkibsirkib/Reowolf
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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 58e19b42641f 06f259bf8031 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 06f259bf8031 91c57e99c66e 91c57e99c66e 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 06f259bf8031 63a9f085c357 06f259bf8031 06f259bf8031 91c57e99c66e 06f259bf8031 06f259bf8031 91c57e99c66e 91c57e99c66e 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 06f259bf8031 06f259bf8031 91c57e99c66e 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 b788ae5c2251 b788ae5c2251 58e19b42641f b788ae5c2251 63a9f085c357 b788ae5c2251 b788ae5c2251 91c57e99c66e 91c57e99c66e 63a9f085c357 63a9f085c357 63a9f085c357 b788ae5c2251 b788ae5c2251 b788ae5c2251 b788ae5c2251 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 91c57e99c66e 91c57e99c66e 91c57e99c66e b788ae5c2251 b788ae5c2251 b788ae5c2251 b788ae5c2251 63a9f085c357 63a9f085c357 63a9f085c357 b788ae5c2251 b788ae5c2251 b788ae5c2251 91c57e99c66e 91c57e99c66e 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 63a9f085c357 b788ae5c2251 91c57e99c66e 91c57e99c66e 91c57e99c66e b788ae5c2251 b788ae5c2251 b788ae5c2251 b788ae5c2251 63a9f085c357 63a9f085c357 63a9f085c357 b788ae5c2251 b788ae5c2251 b788ae5c2251 b788ae5c2251 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f 58e19b42641f | extern crate test_generator;
use super::*;
use std::fs;
use std::path::Path;
use std::thread;
use test_generator::test_resources;
use crate::common::*;
use crate::runtime::*;
use crate::runtime::errors::*;
#[test]
fn incremental() {
let timeout = Duration::from_millis(1_500);
let addrs = ["127.0.0.1:7010".parse().unwrap(), "127.0.0.1:7011".parse().unwrap()];
let a = thread::spawn(move || {
let controller_id = 0;
let mut x = Connector::Unconfigured(Unconfigured { controller_id });
x.configure(
b"primitive main(out a, out b) {
synchronous {
msg m = create(0);
put(a, m);
}
}",
)
.unwrap();
x.bind_port(0, PortBinding::Passive(addrs[0])).unwrap();
x.bind_port(1, PortBinding::Passive(addrs[1])).unwrap();
x.connect(timeout).unwrap();
assert_eq!(0, x.sync(timeout).unwrap());
println!("\n---------\nLOG CID={}\n{}", controller_id, x.get_mut_logger().unwrap());
});
let b = thread::spawn(move || {
let controller_id = 1;
let mut x = Connector::Unconfigured(Unconfigured { controller_id });
x.configure(
b"primitive main(in a, in b) {
synchronous {
get(a);
}
}",
)
.unwrap();
x.bind_port(0, PortBinding::Active(addrs[0])).unwrap();
x.bind_port(1, PortBinding::Active(addrs[1])).unwrap();
x.connect(timeout).unwrap();
assert_eq!(0, x.sync(timeout).unwrap());
println!("\n---------\nLOG CID={}\n{}", controller_id, x.get_mut_logger().unwrap());
});
handle(a.join());
handle(b.join());
}
#[test]
fn duo_positive() {
let timeout = Duration::from_millis(1_500);
let addrs = ["127.0.0.1:7012".parse().unwrap(), "127.0.0.1:7013".parse().unwrap()];
let a = thread::spawn(move || {
let mut x = Connector::Unconfigured(Unconfigured { controller_id: 0 });
x.configure(
b"
primitive main(out a, out b) {
synchronous {}
synchronous {}
synchronous {
msg m = create(0);
put(a, m);
}
synchronous {
msg m = create(0);
put(b, m);
}
}",
)
.unwrap();
x.bind_port(0, PortBinding::Passive(addrs[0])).unwrap();
x.bind_port(1, PortBinding::Passive(addrs[1])).unwrap();
x.connect(timeout).unwrap();
assert_eq!(0, x.sync(timeout).unwrap());
assert_eq!(0, x.sync(timeout).unwrap());
assert_eq!(0, x.sync(timeout).unwrap());
assert_eq!(0, x.sync(timeout).unwrap());
});
let b = thread::spawn(move || {
let mut x = Connector::Unconfigured(Unconfigured { controller_id: 1 });
x.configure(
b"
primitive main(in a, in b) {
while (true) {
synchronous {
if (fires(a)) {
get(a);
}
}
synchronous {
if (fires(b)) {
get(b);
}
}
}
}",
)
.unwrap();
x.bind_port(0, PortBinding::Active(addrs[0])).unwrap();
x.bind_port(1, PortBinding::Active(addrs[1])).unwrap();
x.connect(timeout).unwrap();
assert_eq!(0, x.sync(timeout).unwrap());
assert_eq!(0, x.sync(timeout).unwrap());
assert_eq!(0, x.sync(timeout).unwrap());
assert_eq!(0, x.sync(timeout).unwrap());
});
handle(a.join());
handle(b.join());
}
#[test]
fn duo_negative() {
let timeout = Duration::from_millis(500);
let addrs = ["127.0.0.1:7012".parse().unwrap(), "127.0.0.1:7013".parse().unwrap()];
let a = thread::spawn(move || {
let mut x = Connector::Unconfigured(Unconfigured { controller_id: 0 });
x.configure(b"
primitive main(out a, out b) {
synchronous {}
synchronous {
msg m = create(0);
put(a, m); // fires a on second round
}
}").unwrap();
x.bind_port(0, PortBinding::Passive(addrs[0])).unwrap();
x.bind_port(1, PortBinding::Passive(addrs[1])).unwrap();
x.connect(timeout).unwrap();
assert_eq!(0, x.sync(timeout).unwrap());
match x.sync(timeout) {
Err(SyncErr::Timeout) => {}
x => unreachable!("{:?}", x)
}
});
let b = thread::spawn(move || {
let mut x = Connector::Unconfigured(Unconfigured { controller_id: 1 });
x.configure(b"
primitive main(in a, in b) {
while (true) {
synchronous {
if (fires(a)) {
get(a);
}
}
synchronous {
if (fires(b)) { // never fire a on even round
get(b);
}
}
}
}").unwrap();
x.bind_port(0, PortBinding::Active(addrs[0])).unwrap();
x.bind_port(1, PortBinding::Active(addrs[1])).unwrap();
x.connect(timeout).unwrap();
assert_eq!(0, x.sync(timeout).unwrap());
match x.sync(timeout) {
Err(SyncErr::Timeout) => {}
x => unreachable!("{:?}", x)
}
});
handle(a.join());
handle(b.join());
}
|