Skip to content

Commit

Permalink
Disable TcpStream test on miri
Browse files Browse the repository at this point in the history
    error: unsupported operation: can't call foreign function: getaddrinfo
        --> nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/net.rs:191:21
         |
    191  |             cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), &hints, &mut res))
         |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function: getaddrinfo
         |
         = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
  • Loading branch information
dtolnay committed Dec 11, 2021
1 parent f0774c4 commit aaaf125
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use serde_bytes::{ByteBuf, Bytes};
use serde_json::value::RawValue;
use serde_json::{
from_reader, from_slice, from_str, from_value, json, to_string, to_string_pretty, to_value,
to_vec, to_writer, Deserializer, Number, Value,
to_vec, Deserializer, Number, Value,
};
use std::collections::hash_map::DefaultHasher;
use std::collections::BTreeMap;
Expand All @@ -37,10 +37,8 @@ use std::io;
use std::iter;
use std::marker::PhantomData;
use std::mem;
use std::net;
use std::str::FromStr;
use std::string::ToString;
use std::thread;
use std::{f32, f64};
use std::{i16, i32, i64, i8};
use std::{u16, u32, u64, u8};
Expand Down Expand Up @@ -1623,14 +1621,19 @@ fn test_serialize_map_with_no_len() {
assert_eq!(s, expected);
}

#[cfg(not(miri))]
#[test]
fn test_deserialize_from_stream() {
use serde_json::to_writer;
use std::net::{TcpListener, TcpStream};
use std::thread;

#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct Message {
message: String,
}

let l = net::TcpListener::bind("localhost:20000").unwrap();
let l = TcpListener::bind("localhost:20000").unwrap();

thread::spawn(|| {
let l = l;
Expand All @@ -1647,7 +1650,7 @@ fn test_deserialize_from_stream() {
}
});

let mut stream = net::TcpStream::connect("localhost:20000").unwrap();
let mut stream = TcpStream::connect("localhost:20000").unwrap();
let request = Message {
message: "hi there".to_string(),
};
Expand Down

0 comments on commit aaaf125

Please sign in to comment.