File tree 4 files changed +22
-4
lines changed
4 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 38
38
toolchain : ${{ matrix.toolchain }}
39
39
- uses : Swatinem/rust-cache@v2
40
40
- run : cargo test
41
- # Make sure enabling the std and custom features don't break anything
42
- - run : cargo test --features=std,custom
41
+ # Ensure enabling features works, and run feature-specific tests.
42
+ - run : cargo test --features=std,custom,rdrand
43
43
- run : cargo test --features=linux_disable_fallback
44
44
- if : ${{ matrix.toolchain == 'nightly' }}
45
45
run : cargo test --benches
Original file line number Diff line number Diff line change @@ -224,6 +224,13 @@ mod util;
224
224
mod custom;
225
225
#[ cfg( feature = "std" ) ]
226
226
mod error_impls;
227
+ // If the rdrand feature is enabled, always bring in the rdrand module, so
228
+ // that the RDRAND implementation can be tested.
229
+ #[ cfg( all(
230
+ any( target_env = "sgx" , feature = "rdrand" ) ,
231
+ any( target_arch = "x86_64" , target_arch = "x86" ) ,
232
+ ) ) ]
233
+ mod rdrand;
227
234
228
235
pub use crate :: error:: Error ;
229
236
@@ -330,10 +337,10 @@ cfg_if! {
330
337
} else if #[ cfg( windows) ] {
331
338
#[ path = "windows.rs" ] mod imp;
332
339
} else if #[ cfg( all( target_arch = "x86_64" , target_env = "sgx" ) ) ] {
333
- # [ path = " rdrand.rs" ] mod imp;
340
+ use rdrand as imp;
334
341
} else if #[ cfg( all( feature = "rdrand" ,
335
342
any( target_arch = "x86_64" , target_arch = "x86" ) ) ) ] {
336
- # [ path = " rdrand.rs" ] mod imp;
343
+ use rdrand as imp;
337
344
} else if #[ cfg( all( feature = "js" ,
338
345
any( target_arch = "wasm32" , target_arch = "wasm64" ) ,
339
346
target_os = "unknown" ) ) ] {
Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ fn is_rdrand_good() -> bool {
93
93
unsafe { self_test ( ) }
94
94
}
95
95
96
+ #[ allow( dead_code) ]
96
97
pub fn getrandom_inner ( dest : & mut [ MaybeUninit < u8 > ] ) -> Result < ( ) , Error > {
97
98
static RDRAND_GOOD : LazyBool = LazyBool :: new ( ) ;
98
99
if !RDRAND_GOOD . unsync_init ( is_rdrand_good) {
@@ -121,3 +122,8 @@ unsafe fn rdrand_exact(dest: &mut [MaybeUninit<u8>]) -> Option<()> {
121
122
}
122
123
Some ( ( ) )
123
124
}
125
+
126
+ #[ cfg( test) ]
127
+ mod tests {
128
+ crate :: tests:: define_tests!( super :: getrandom_inner) ;
129
+ }
Original file line number Diff line number Diff line change @@ -174,3 +174,8 @@ impl<F: FnMut()> Drop for DropGuard<F> {
174
174
self . 0 ( )
175
175
}
176
176
}
177
+
178
+ #[ cfg( test) ]
179
+ mod tests {
180
+ crate :: tests:: define_tests!( super :: getrandom_inner) ;
181
+ }
You can’t perform that action at this time.
0 commit comments