Skip to content

Commit

Permalink
Run Miri everywhere (#269)
Browse files Browse the repository at this point in the history
* Explicitly mark all tests where MIRI doesn't run

* Update the github action to run miri on the entire library
  • Loading branch information
danielsn authored Oct 6, 2023
1 parent ad8ff1f commit 340d728
Show file tree
Hide file tree
Showing 22 changed files with 71 additions and 5 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/miri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:

jobs:
profiler-test:
run-miri:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -13,7 +13,6 @@ jobs:
toolchain: nightly
override: true
components: miri
- run: cd ${GITHUB_WORKSPACE}/profiling && MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test
- run: cd ${GITHUB_WORKSPACE}/profiling-ffi && MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test
- run: MIRIFLAGS="-Zmiri-disable-isolation" cargo miri test
# We need to disable isolation because
# "unsupported operation: `clock_gettime` with `REALTIME` clocks not available when isolation is enabled"
2 changes: 2 additions & 0 deletions ddcommon/src/connector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ mod tests {
use super::*;

#[test]
#[cfg_attr(miri, ignore)]
/// Verify that the Connector type implements the correct bound Connect + Clone
/// to be able to use the hyper::Client
fn test_hyper_client_from_connector() {
let _: hyper::Client<Connector> = hyper::Client::builder().build(Connector::new());
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
/// Verify that Connector will only allow non tls connections if root certificates
/// are not found
async fn test_missing_root_certificates_only_allow_http_connections() {
Expand Down
3 changes: 3 additions & 0 deletions ddtelemetry-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ mod test_c_ffi {
use ddcommon::{parse_uri, Endpoint};

#[test]
#[cfg_attr(miri, ignore)]
fn test_set_builder_str_param() {
let mut builder = std::ptr::null_mut();

Expand Down Expand Up @@ -176,6 +177,7 @@ mod test_c_ffi {
}

#[test]
#[cfg_attr(miri, ignore)]
fn test_set_builder_enum_param() {
let mut builder = std::ptr::null_mut();

Expand Down Expand Up @@ -226,6 +228,7 @@ mod test_c_ffi {
}

#[test]
#[cfg_attr(miri, ignore)]
fn test_worker_run() {
unsafe {
let mut builder = std::ptr::null_mut();
Expand Down
1 change: 1 addition & 0 deletions ddtelemetry/src/worker/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ mod tests {
use super::*;

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn test_mock_client() {
let output: Vec<u8> = Vec::new();
let c = MockClient {
Expand Down
2 changes: 2 additions & 0 deletions ipc/src/platform/unix/platform_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ mod tests {
}

#[test]
#[cfg_attr(miri, ignore)]
fn test_platform_handles_fd_handling() {
let mut file = tempfile::tempfile().unwrap();
assert_file_is_open_for_writing!(file);
Expand All @@ -205,6 +206,7 @@ mod tests {
}

#[test]
#[cfg_attr(miri, ignore)]
fn test_platform_handle_fd_borrowing() {
let mut file = tempfile::tempfile().unwrap();
assert_file_is_open_for_writing!(file);
Expand Down
8 changes: 8 additions & 0 deletions ipc/tarpc/tarpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ mod tests {
use tracing::Span;

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn response_completes_request_future() {
let (mut dispatch, mut _channel, mut server_channel) = set_up();
let cx = &mut Context::from_waker(noop_waker_ref());
Expand All @@ -650,6 +651,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn dispatch_response_cancels_on_drop() {
let (cancellation, mut canceled_requests) = cancellations();
let (_, mut response) = oneshot::channel();
Expand All @@ -665,6 +667,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn dispatch_response_doesnt_cancel_after_complete() {
let (cancellation, mut canceled_requests) = cancellations();
let (tx, mut response) = oneshot::channel();
Expand All @@ -689,6 +692,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn stage_request() {
let (mut dispatch, mut channel, _server_channel) = set_up();
let cx = &mut Context::from_waker(noop_waker_ref());
Expand All @@ -707,6 +711,7 @@ mod tests {

// Regression test for https://github.com/google/tarpc/issues/220
#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn stage_request_channel_dropped_doesnt_panic() {
let (mut dispatch, mut channel, mut server_channel) = set_up();
let cx = &mut Context::from_waker(noop_waker_ref());
Expand All @@ -729,6 +734,7 @@ mod tests {

#[allow(unstable_name_collisions)]
#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn stage_request_response_future_dropped_is_canceled_before_sending() {
let (mut dispatch, mut channel, _server_channel) = set_up();
let cx = &mut Context::from_waker(noop_waker_ref());
Expand All @@ -745,6 +751,7 @@ mod tests {

#[allow(unstable_name_collisions)]
#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn stage_request_response_future_dropped_is_canceled_after_sending() {
let (mut dispatch, mut channel, _server_channel) = set_up();
let cx = &mut Context::from_waker(noop_waker_ref());
Expand All @@ -766,6 +773,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn stage_request_response_closed_skipped() {
let (mut dispatch, mut channel, _server_channel) = set_up();
let cx = &mut Context::from_waker(noop_waker_ref());
Expand Down
4 changes: 2 additions & 2 deletions ipc/tarpc/tarpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@
//! # future::ready(format!("Hello, {name}!"))
//! # }
//! # }
//! # #[cfg(not(feature = "tokio1"))]
//! # #[cfg(any(not(feature = "tokio1"), miri))]
//! # fn main() {}
//! # #[cfg(feature = "tokio1")]
//! # #[cfg(all(feature = "tokio1", not(miri)))]
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! let (client_transport, server_transport) = tarpc::transport::channel::unbounded();
Expand Down
13 changes: 13 additions & 0 deletions ipc/tarpc/tarpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn base_channel_start_send_duplicate_request_returns_error() {
let (mut channel, _tx) = test_channel::<(), ()>();

Expand All @@ -918,6 +919,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn base_channel_poll_next_aborts_multiple_requests() {
let (mut channel, _tx) = test_channel::<(), ()>();

Expand Down Expand Up @@ -949,6 +951,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn base_channel_poll_next_aborts_canceled_request() {
let (mut channel, mut tx) = test_channel::<(), ()>();

Expand Down Expand Up @@ -978,6 +981,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn base_channel_with_closed_transport_and_in_flight_request_returns_pending() {
let (mut channel, tx) = test_channel::<(), ()>();

Expand All @@ -999,6 +1003,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn base_channel_with_closed_transport_and_no_in_flight_requests_returns_closed() {
let (mut channel, tx) = test_channel::<(), ()>();
drop(tx);
Expand All @@ -1009,6 +1014,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn base_channel_poll_next_yields_request() {
let (mut channel, mut tx) = test_channel::<(), ()>();
tx.send(fake_request(())).await.unwrap();
Expand All @@ -1020,6 +1026,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn base_channel_poll_next_aborts_request_and_yields_request() {
let (mut channel, mut tx) = test_channel::<(), ()>();

Expand All @@ -1044,6 +1051,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn base_channel_start_send_removes_in_flight_request() {
let (mut channel, _tx) = test_channel::<(), ()>();

Expand All @@ -1067,6 +1075,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn in_flight_request_drop_cancels_request() {
let (mut requests, mut tx) = test_requests::<(), ()>();
tx.send(fake_request(())).await.unwrap();
Expand All @@ -1087,6 +1096,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn in_flight_requests_successful_execute_doesnt_cancel_request() {
let (mut requests, mut tx) = test_requests::<(), ()>();
tx.send(fake_request(())).await.unwrap();
Expand All @@ -1105,6 +1115,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn requests_poll_next_response_returns_pending_when_buffer_full() {
let (mut requests, _tx) = test_bounded_requests::<(), ()>(0);

Expand Down Expand Up @@ -1156,6 +1167,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn requests_pump_write_returns_pending_when_buffer_full() {
let (mut requests, _tx) = test_bounded_requests::<(), ()>(0);

Expand Down Expand Up @@ -1211,6 +1223,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn requests_pump_read() {
let (mut requests, mut tx) = test_requests::<(), ()>();

Expand Down
4 changes: 4 additions & 0 deletions ipc/tarpc/tarpc/src/server/in_flight_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ mod tests {
use futures_test::task::noop_context;

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn start_request_increases_len() {
let mut in_flight_requests = InFlightRequests::default();
assert_eq!(in_flight_requests.len(), 0);
Expand All @@ -147,6 +148,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn polling_expired_aborts() {
let mut in_flight_requests = InFlightRequests::default();
let abort_registration = in_flight_requests
Expand All @@ -169,6 +171,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn cancel_request_aborts() {
let mut in_flight_requests = InFlightRequests::default();
let abort_registration = in_flight_requests
Expand All @@ -185,6 +188,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn remove_request_doesnt_abort() {
let mut in_flight_requests = InFlightRequests::default();
assert!(in_flight_requests.deadlines.is_empty());
Expand Down
2 changes: 2 additions & 0 deletions ipc/tarpc/tarpc/src/server/limits/requests_per_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ mod tests {
use tracing::Span;

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn throttler_in_flight_requests() {
let throttler = MaxRequests {
max_in_flight_requests: 0,
Expand Down Expand Up @@ -320,6 +321,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn throttler_start_send() {
let throttler = MaxRequests {
max_in_flight_requests: 0,
Expand Down
1 change: 1 addition & 0 deletions ipc/tarpc/tarpc/src/transport/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ mod tests {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn integration() -> anyhow::Result<()> {
let _ = tracing_subscriber::fmt::try_init();

Expand Down
8 changes: 8 additions & 0 deletions ipc/tarpc/tarpc/tests/service_functional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl Service for Server {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn sequential() -> anyhow::Result<()> {
let _ = tracing_subscriber::fmt::try_init();

Expand All @@ -58,6 +59,7 @@ async fn sequential() -> anyhow::Result<()> {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn dropped_channel_aborts_in_flight_requests() -> anyhow::Result<()> {
#[tarpc_plugins::service]
trait Loop {
Expand Down Expand Up @@ -108,6 +110,7 @@ async fn dropped_channel_aborts_in_flight_requests() -> anyhow::Result<()> {

#[cfg(all(feature = "serde-transport", feature = "tcp"))]
#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn serde_tcp() -> anyhow::Result<()> {
use tarpc::serde_transport;
use tokio_serde::formats::Json;
Expand Down Expand Up @@ -138,6 +141,7 @@ async fn serde_tcp() -> anyhow::Result<()> {

#[cfg(all(feature = "serde-transport", feature = "unix", unix))]
#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn serde_uds() -> anyhow::Result<()> {
use tarpc::serde_transport;
use tokio_serde::formats::Json;
Expand Down Expand Up @@ -168,6 +172,7 @@ async fn serde_uds() -> anyhow::Result<()> {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn concurrent() -> anyhow::Result<()> {
let _ = tracing_subscriber::fmt::try_init();

Expand All @@ -192,6 +197,7 @@ async fn concurrent() -> anyhow::Result<()> {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn concurrent_join() -> anyhow::Result<()> {
let _ = tracing_subscriber::fmt::try_init();

Expand All @@ -217,6 +223,7 @@ async fn concurrent_join() -> anyhow::Result<()> {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn concurrent_join_all() -> anyhow::Result<()> {
let _ = tracing_subscriber::fmt::try_init();

Expand All @@ -240,6 +247,7 @@ async fn concurrent_join_all() -> anyhow::Result<()> {
}

#[tokio::test]
#[cfg_attr(miri, ignore)]
async fn counter() -> anyhow::Result<()> {
#[tarpc::service]
trait Counter {
Expand Down
1 change: 1 addition & 0 deletions ipc/tests/blocking_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use datadog_ipc::example_interface::{
};

#[test]
#[cfg_attr(miri, ignore)]
fn test_blocking_client() {
let (sock_a, sock_b) = StdUnixStream::pair().unwrap();
// Setup async server
Expand Down
1 change: 1 addition & 0 deletions ipc/tests/flock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub extern "C" fn flock_test_entrypoint() {
}

#[test]
#[cfg_attr(miri, ignore)]
fn test_file_locking_works_as_expected() {
let d = tempdir().unwrap();
let lock_path = d.path().join("file.lock");
Expand Down
Loading

0 comments on commit 340d728

Please sign in to comment.