diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4ba01e80..5363968f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -61,6 +61,10 @@ jobs: RUSTFLAGS: -Dwarnings --cfg getrandom_test_linux_fallback RUSTDOCFLAGS: -Dwarnings --cfg getrandom_test_linux_fallback run: cargo test --features=std + - env: + RUSTFLAGS: -Dwarnings --cfg getrandom_test_linux_without_fallback + RUSTDOCFLAGS: -Dwarnings --cfg getrandom_test_linux_without_fallback + run: cargo test --features=std - env: RUSTFLAGS: -Dwarnings --cfg getrandom_backend="rdrand" RUSTDOCFLAGS: -Dwarnings --cfg getrandom_backend="rdrand" diff --git a/Cargo.toml b/Cargo.toml index 2942d31e..2441555b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,6 +84,7 @@ check-cfg = [ 'cfg(getrandom_backend, values("custom", "rdrand", "rndr", "linux_getrandom", "wasm_js"))', 'cfg(getrandom_msan)', 'cfg(getrandom_test_linux_fallback)', + 'cfg(getrandom_test_linux_without_fallback)', 'cfg(getrandom_test_netbsd_fallback)', ] diff --git a/src/backends/linux_android_with_fallback.rs b/src/backends/linux_android_with_fallback.rs index 379237c6..2ad8f0a4 100644 --- a/src/backends/linux_android_with_fallback.rs +++ b/src/backends/linux_android_with_fallback.rs @@ -60,6 +60,11 @@ fn init() -> NonNull { None => NOT_AVAILABLE, }; + #[cfg(getrandom_test_linux_without_fallback)] + if res_ptr == NOT_AVAILABLE { + panic!("Fallback is triggered with enabled `getrandom_test_linux_without_fallback`") + } + GETRANDOM_FN.store(res_ptr.as_ptr(), Ordering::Release); res_ptr }