A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
[tests] Fix two intermittent failures (#13364)
Till Schneidereit87cbd4338a55
diff --git a/cranelift/codegen/src/opts/div_const.rs b/cranelift/codegen/src/opts/div_const.rsindex a88f0c6344..f4187f75df 100644--- a/cranelift/codegen/src/opts/div_const.rs+++ b/cranelift/codegen/src/opts/div_const.rs@@ -834,8 +834,8 @@ mod tests {// numbers for `d`, and in effect interpret them so as to compute// `n / d`. Check that that equals the value of `n / d` computed// directly by the hardware. This serves to check that the magic- // number generates work properly. In total, 50,148,000 tests are- // done.+ // number generators work properly. In total, approximately+ // 50,148,000 tests are done.// Some constantsconst MIN_U32: u32 = 0;@@ -1149,7 +1149,14 @@ mod tests {d -= 1;}}- assert_eq!(n_tests_done, 50_148_000);+ // The exact count varies slightly across platforms because the advance+ // functions use f64 arithmetic that may round differently (SSE vs AVX+ // vs FMA). The important property is that we test a large number of+ // numerators across all divisor ranges.+ assert!(+ n_tests_done >= 50_000_000 && n_tests_done <= 50_200_000,+ "unexpected test count: {n_tests_done}"+ );}proptest::proptest! {diff --git a/crates/test-programs/src/bin/p2_tcp_sockopts.rs b/crates/test-programs/src/bin/p2_tcp_sockopts.rsindex 723b0c22ec..dce8ea840f 100644--- a/crates/test-programs/src/bin/p2_tcp_sockopts.rs+++ b/crates/test-programs/src/bin/p2_tcp_sockopts.rs@@ -142,10 +142,18 @@ fn test_tcp_sockopt_inheritance(net: &Network, family: IpAddressFamily) {assert_eq!(accepted_client.keep_alive_interval().unwrap(), 42 * SECOND);assert_eq!(accepted_client.keep_alive_count().unwrap(), 42);assert_eq!(accepted_client.hop_limit().unwrap(), 42);- assert_eq!(accepted_client.receive_buffer_size().unwrap(), 0x10000);- assert_eq!(accepted_client.send_buffer_size().unwrap(), 0x10000);+ // Buffer sizes: the OS may adjust the actual value (per the WASI spec:+ // "the value read back from this setting may differ from the value that+ // was set"). We only assert that they're at least what we requested.+ assert!(accepted_client.receive_buffer_size().unwrap() >= 0x10000);+ assert!(accepted_client.send_buffer_size().unwrap() >= 0x10000);}+ // Snapshot accepted socket's buffer sizes before changing the listener,+ // so we can verify the accepted socket is independent of listener changes.+ let accepted_recv_buf = accepted_client.receive_buffer_size().unwrap();+ let accepted_send_buf = accepted_client.send_buffer_size().unwrap();+// Update options on listener to something else:{listener.set_keep_alive_enabled(default_keep_alive).unwrap();@@ -157,7 +165,8 @@ fn test_tcp_sockopt_inheritance(net: &Network, family: IpAddressFamily) {listener.set_send_buffer_size(0x20000).unwrap();}- // Verify that the already accepted socket was not affected:+ // Verify that the already accepted socket was not affected by the+ // listener's option changes.{assert_eq!(accepted_client.keep_alive_enabled().unwrap(),@@ -167,8 +176,14 @@ fn test_tcp_sockopt_inheritance(net: &Network, family: IpAddressFamily) {assert_eq!(accepted_client.keep_alive_interval().unwrap(), 42 * SECOND);assert_eq!(accepted_client.keep_alive_count().unwrap(), 42);assert_eq!(accepted_client.hop_limit().unwrap(), 42);- assert_eq!(accepted_client.receive_buffer_size().unwrap(), 0x10000);- assert_eq!(accepted_client.send_buffer_size().unwrap(), 0x10000);+ assert_eq!(+ accepted_client.receive_buffer_size().unwrap(),+ accepted_recv_buf+ );+ assert_eq!(+ accepted_client.send_buffer_size().unwrap(),+ accepted_send_buf+ );}}