test: autobahn: add strict error reporting

Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
pull/104/head
Alexey Galakhov 5 years ago
parent da3acc107e
commit 010266e001
  1. 6
      examples/autobahn-client.rs
  2. 11
      examples/autobahn-server.rs

@ -50,10 +50,8 @@ fn main() {
for case in 1..=total { for case in 1..=total {
if let Err(e) = run_test(case) { if let Err(e) = run_test(case) {
match e { match e {
Error::Protocol(_) => {} Error::ConnectionClosed | Error::Protocol(_) | Error::Utf8 => (),
err => { err => error!("test: {}", err),
warn!("test: {}", err);
}
} }
} }
} }

@ -14,6 +14,7 @@ fn must_not_block<Role: HandshakeRole>(err: HandshakeError<Role>) -> Error {
fn handle_client(stream: TcpStream) -> Result<()> { fn handle_client(stream: TcpStream) -> Result<()> {
let mut socket = accept(stream).map_err(must_not_block)?; let mut socket = accept(stream).map_err(must_not_block)?;
info!("Running test");
loop { loop {
match socket.read_message()? { match socket.read_message()? {
msg @ Message::Text(_) | msg @ Message::Binary(_) => { msg @ Message::Text(_) | msg @ Message::Binary(_) => {
@ -31,11 +32,13 @@ fn main() {
for stream in server.incoming() { for stream in server.incoming() {
spawn(move || match stream { spawn(move || match stream {
Ok(stream) => match handle_client(stream) { Ok(stream) => if let Err(err) = handle_client(stream) {
Ok(_) => (), match err {
Err(e) => warn!("Error in client: {}", e), Error::ConnectionClosed | Error::Protocol(_) | Error::Utf8 => (),
e => error!("test: {}", e),
}
}, },
Err(e) => warn!("Error accepting stream: {}", e), Err(e) => error!("Error accepting stream: {}", e),
}); });
} }
} }

Loading…
Cancel
Save