From aaaf125f0b2504b30abb0446adf18dae8e709a8b Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 11 Dec 2021 14:56:35 -0800 Subject: [PATCH] Disable TcpStream test on miri 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 --- tests/test.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/test.rs b/tests/test.rs index 2925835c7..7dbc21638 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -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; @@ -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}; @@ -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; @@ -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(), };