Skip to content

Commit e12fa5a

Browse files
authored
Selectively enable and fix (slow) Tokio tests (#4203)
1. Some of the tests that were disabled wouldn't even compile. Fixed, even when they may still be disabled. 2. Adjusted unwinding bounds and `should_fail` attributes to avoid spurious test failures. 3. Updated comments to clarify why tests are (still) disabled. 4. Enabled all tests that completed under 15 minutes and with less than 10 GB of memory footprint (14 additional tests). By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
1 parent b6c4a15 commit e12fa5a

26 files changed

+44
-78
lines changed

tests/slow/tokio-proofs/expected

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Complete - 13 successfully verified harnesses, 0 failures, 13 total.
1+
Complete - 27 successfully verified harnesses, 0 failures, 27 total.

tests/slow/tokio-proofs/src/tokio/io_chain.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
use tokio::io::AsyncReadExt;
1313
use tokio_test::assert_ok;
1414

15-
#[cfg(disabled)] // because it timed out after 2h
1615
#[kani::proof]
17-
#[kani::unwind(2)]
16+
#[kani::unwind(12)]
1817
async fn chain() {
1918
let mut buf = Vec::new();
2019
let rd1: &[u8] = b"hello ";

tests/slow/tokio-proofs/src/tokio/io_copy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use tokio_test::assert_ok;
1717
use std::pin::Pin;
1818
use std::task::{Context, Poll};
1919

20-
#[cfg(disabled)] // because it timed out after 2h
20+
#[cfg(disabled)] // requires pthread_key_create
2121
#[kani::proof]
2222
#[kani::unwind(2)]
2323
async fn copy() {
@@ -47,7 +47,7 @@ async fn copy() {
4747
assert_eq!(wr, b"hello world");
4848
}
4949

50-
#[cfg(disabled)] // because it timed out after 2h
50+
#[cfg(disabled)] // requires pthread_key_create
5151
#[kani::proof]
5252
#[kani::unwind(2)]
5353
async fn proxy() {

tests/slow/tokio-proofs/src/tokio/io_lines.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use tokio::io::AsyncBufReadExt;
1313
use tokio_test::assert_ok;
1414

15-
#[cfg(disabled)] // because it timed out after 2h
15+
#[cfg(disabled)] // requires memchr
1616
#[kani::proof]
1717
#[kani::unwind(2)]
1818
async fn lines_inherent() {

tests/slow/tokio-proofs/src/tokio/io_mem_stream.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use tokio::io::{AsyncReadExt, AsyncWriteExt, duplex};
1313

14-
#[cfg(disabled)] // because it timed out after 2h
14+
#[cfg(disabled)] // requires pthread_key_create
1515
#[kani::proof]
1616
#[kani::unwind(2)]
1717
async fn ping_pong() {
@@ -29,7 +29,7 @@ async fn ping_pong() {
2929
}
3030

3131
// Kani does not support this one yet because it uses spawn
32-
#[cfg(disabled)] // because it timed out after 2h
32+
#[cfg(disabled)] // requires pthread_key_create
3333
#[kani::proof]
3434
#[kani::unwind(2)]
3535
async fn across_tasks() {
@@ -54,7 +54,7 @@ async fn across_tasks() {
5454
}
5555

5656
// Kani does not support this one yet because it uses spawn
57-
#[cfg(disabled)] // because it timed out after 2h
57+
#[cfg(disabled)] // requires pthread_key_create
5858
#[kani::proof]
5959
#[kani::unwind(2)]
6060
async fn disconnect() {
@@ -79,7 +79,7 @@ async fn disconnect() {
7979
}
8080

8181
// Kani does not support this one yet because it uses spawn
82-
#[cfg(disabled)] // because it timed out after 2h
82+
#[cfg(disabled)] // requires pthread_key_create
8383
#[kani::proof]
8484
#[kani::unwind(2)]
8585
async fn disconnect_reader() {
@@ -101,7 +101,7 @@ async fn disconnect_reader() {
101101
}
102102

103103
// Kani does not support this one yet because it uses spawn
104-
#[cfg(disabled)] // because it timed out after 2h
104+
#[cfg(disabled)] // requires pthread_key_create
105105
#[kani::proof]
106106
#[kani::unwind(2)]
107107
async fn max_write_size() {
@@ -124,7 +124,7 @@ async fn max_write_size() {
124124
}
125125

126126
// Kani does not support this one yet because it uses select
127-
#[cfg(disabled)] // because it timed out after 2h
127+
#[cfg(disabled)] // requires pthread_key_create
128128
#[kani::proof]
129129
#[kani::unwind(2)]
130130
async fn duplex_is_cooperative() {

tests/slow/tokio-proofs/src/tokio/io_read.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ impl AsyncRead for BadAsyncRead {
7171
}
7272
}
7373

74-
#[cfg(disabled)] // because Kani does not support should_panic
7574
#[kani::proof]
7675
#[kani::unwind(2)]
77-
#[tokio::test]
78-
#[should_panic]
76+
#[kani::should_panic]
7977
async fn read_buf_bad_async_read() {
8078
let mut buf = Vec::with_capacity(10);
8179
BadAsyncRead::new().read_buf(&mut buf).await.unwrap();

tests/slow/tokio-proofs/src/tokio/io_read_buf.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use std::io;
1616
use std::pin::Pin;
1717
use std::task::{Context, Poll};
1818

19-
#[cfg(disabled)] // because it timed out after 2h
2019
#[kani::proof]
2120
#[kani::unwind(12)]
2221
async fn read_buf() {

tests/slow/tokio-proofs/src/tokio/io_read_line.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use tokio_test::{assert_ok, io::Builder};
1515

1616
use std::io::Cursor;
1717

18-
#[cfg(disabled)] // because it timed out after 2h
18+
#[cfg(disabled)] // requires pthread_key_create
1919
#[kani::proof]
2020
#[kani::unwind(2)]
2121
async fn read_line() {
@@ -39,7 +39,7 @@ async fn read_line() {
3939
assert_eq!(buf, "");
4040
}
4141

42-
#[cfg(disabled)] // because it timed out after 2h
42+
#[cfg(disabled)] // CBMC consumes more than 10 GB
4343
#[kani::proof]
4444
#[kani::unwind(2)]
4545
async fn read_line_not_all_ready() {
@@ -68,7 +68,7 @@ async fn read_line_not_all_ready() {
6868
assert_eq!(line.as_str(), "2");
6969
}
7070

71-
#[cfg(disabled)] // because it timed out after 2h
71+
#[cfg(disabled)] // CBMC consumes more than 10 GB
7272
#[kani::proof]
7373
#[kani::unwind(2)]
7474
async fn read_line_invalid_utf8() {
@@ -83,7 +83,7 @@ async fn read_line_invalid_utf8() {
8383
assert_eq!(line.as_str(), "Foo");
8484
}
8585

86-
#[cfg(disabled)] // because it timed out after 2h
86+
#[cfg(disabled)] // CBMC consumes more than 10 GB
8787
#[kani::proof]
8888
#[kani::unwind(2)]
8989
async fn read_line_fail() {
@@ -101,7 +101,7 @@ async fn read_line_fail() {
101101
assert_eq!(line.as_str(), "FooHello Wor");
102102
}
103103

104-
#[cfg(disabled)] // because it timed out after 2h
104+
#[cfg(disabled)] // CBMC consumes more than 10 GB
105105
#[kani::proof]
106106
#[kani::unwind(2)]
107107
async fn read_line_fail_and_utf8_fail() {

tests/slow/tokio-proofs/src/tokio/io_read_to_end.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ use std::task::{Context, Poll};
1414
use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf};
1515
use tokio_test::assert_ok;
1616

17-
#[cfg(disabled)] // because it timed out after 2h
1817
#[kani::proof]
19-
#[kani::unwind(2)]
18+
#[kani::unwind(12)]
2019
async fn read_to_end() {
2120
let mut buf = vec![];
2221
let mut rd: &[u8] = b"hello world";
@@ -75,9 +74,8 @@ impl AsyncRead for UninitTest {
7574
}
7675
}
7776

78-
#[cfg(disabled)] // because it timed out after 2h
7977
#[kani::proof]
80-
#[kani::unwind(2)]
78+
#[kani::unwind(65)]
8179
async fn read_to_end_uninit() {
8280
let mut buf = Vec::with_capacity(64);
8381
let mut test = UninitTest { num_init: 0, state: State::Initializing };

tests/slow/tokio-proofs/src/tokio/io_read_to_string.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use tokio::io::AsyncReadExt;
1414
use tokio_test::assert_ok;
1515
use tokio_test::io::Builder;
1616

17-
#[cfg(disabled)] // because it timed out after 2h
17+
#[cfg(disabled)] // CBMC takes more than 15 minutes
1818
#[kani::proof]
19-
#[kani::unwind(2)]
19+
#[kani::unwind(12)]
2020
async fn read_to_string() {
2121
let mut buf = String::new();
2222
let mut rd: &[u8] = b"hello world";
@@ -26,7 +26,7 @@ async fn read_to_string() {
2626
assert_eq!(buf[..], "hello world"[..]);
2727
}
2828

29-
#[cfg(disabled)] // because it timed out after 2h
29+
#[cfg(disabled)] // CBMC consumes more than 10 GB
3030
#[kani::proof]
3131
#[kani::unwind(2)]
3232
async fn to_string_does_not_truncate_on_utf8_error() {
@@ -43,7 +43,7 @@ async fn to_string_does_not_truncate_on_utf8_error() {
4343
assert_eq!(s, "abc");
4444
}
4545

46-
#[cfg(disabled)] // because it timed out after 2h
46+
#[cfg(disabled)] // CBMC consumes more than 10 GB
4747
#[kani::proof]
4848
#[kani::unwind(2)]
4949
async fn to_string_does_not_truncate_on_io_error() {
@@ -62,7 +62,7 @@ async fn to_string_does_not_truncate_on_io_error() {
6262
assert_eq!(s, "abc");
6363
}
6464

65-
#[cfg(disabled)] // because it timed out after 2h
65+
#[cfg(disabled)] // CBMC consumes more than 10 GB
6666
#[kani::proof]
6767
#[kani::unwind(2)]
6868
async fn to_string_appends() {

0 commit comments

Comments
 (0)