Changeset - e71e02fb13d4
[Not reviewed]
v0.1.0
0 2 0
Hans-Dieter Hiep - 5 years ago 2020-02-04 17:53:20
hdh@cwi.nl
Fix test cases
2 files changed with 18 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/test/connector.rs
Show inline comments
 
@@ -59,7 +59,8 @@ 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 });
 
        let controller_id = 0;
 
        let mut x = Connector::Unconfigured(Unconfigured { controller_id });
 
        x.configure(
 
            b"
 
        primitive main(out a, out b) {
 
@@ -83,9 +84,11 @@ fn duo_positive() {
 
        assert_eq!(0, x.sync(timeout).unwrap());
 
        assert_eq!(0, x.sync(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 mut x = Connector::Unconfigured(Unconfigured { controller_id: 1 });
 
        let controller_id = 1;
 
        let mut x = Connector::Unconfigured(Unconfigured { controller_id });
 
        x.configure(
 
            b"
 
        primitive main(in a, in b) {
 
@@ -111,6 +114,7 @@ fn duo_positive() {
 
        assert_eq!(0, x.sync(timeout).unwrap());
 
        assert_eq!(0, x.sync(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());
 
@@ -119,9 +123,10 @@ fn duo_positive() {
 
#[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 addrs = ["127.0.0.1:7014".parse().unwrap(), "127.0.0.1:7015".parse().unwrap()];
 
    let a = thread::spawn(move || {
 
        let mut x = Connector::Unconfigured(Unconfigured { controller_id: 0 });
 
        let controller_id = 0;
 
        let mut x = Connector::Unconfigured(Unconfigured { controller_id });
 
        x.configure(b"
 
        primitive main(out a, out b) {
 
            synchronous {}
 
@@ -134,13 +139,16 @@ fn duo_negative() {
 
        x.bind_port(1, PortBinding::Passive(addrs[1])).unwrap();
 
        x.connect(timeout).unwrap();
 
        assert_eq!(0, x.sync(timeout).unwrap());
 
        match x.sync(timeout) {
 
        let r = x.sync(timeout);
 
        println!("\n---------\nLOG CID={}\n{}", controller_id, x.get_mut_logger().unwrap());
 
        match r {
 
            Err(SyncErr::Timeout) => {}
 
            x => unreachable!("{:?}", x)
 
        }
 
    });
 
    let b = thread::spawn(move || {
 
        let mut x = Connector::Unconfigured(Unconfigured { controller_id: 1 });
 
        let controller_id = 1;
 
        let mut x = Connector::Unconfigured(Unconfigured { controller_id });
 
        x.configure(b"
 
        primitive main(in a, in b) {
 
            while (true) {
 
@@ -160,7 +168,9 @@ fn duo_negative() {
 
        x.bind_port(1, PortBinding::Active(addrs[1])).unwrap();
 
        x.connect(timeout).unwrap();
 
        assert_eq!(0, x.sync(timeout).unwrap());
 
        match x.sync(timeout) {
 
        let r = x.sync(timeout);
 
        println!("\n---------\nLOG CID={}\n{}", controller_id, x.get_mut_logger().unwrap());
 
        match r {
 
            Err(SyncErr::Timeout) => {}
 
            x => unreachable!("{:?}", x)
 
        }
src/test/setup.rs
Show inline comments
 
@@ -83,7 +83,7 @@ fn config_and_connect_chain() {
 
        }),
 
        thread::spawn(move || {
 
            // FORWARDER ->B->
 
            let mut x = Connector::Unconfigured(Unconfigured { controller_id: 0 });
 
            let mut x = Connector::Unconfigured(Unconfigured { controller_id: 1 });
 
            x.configure(b"primitive main(in a, out b) {}").unwrap();
 
            x.bind_port(0, Passive(addrs[0])).unwrap();
 
            x.bind_port(1, Active(addrs[1])).unwrap();
0 comments (0 inline, 0 general)