File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -224,6 +224,13 @@ mod util;
224224mod custom;
225225#[ cfg( feature = "std" ) ]
226226mod 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;
227234
228235pub use crate :: error:: Error ;
229236
@@ -330,10 +337,10 @@ cfg_if! {
330337 } else if #[ cfg( windows) ] {
331338 #[ path = "windows.rs" ] mod imp;
332339 } else if #[ cfg( all( target_arch = "x86_64" , target_env = "sgx" ) ) ] {
333- # [ path = " rdrand.rs" ] mod imp;
340+ use rdrand as imp;
334341 } else if #[ cfg( all( feature = "rdrand" ,
335342 any( target_arch = "x86_64" , target_arch = "x86" ) ) ) ] {
336- # [ path = " rdrand.rs" ] mod imp;
343+ use rdrand as imp;
337344 } else if #[ cfg( all( feature = "js" ,
338345 any( target_arch = "wasm32" , target_arch = "wasm64" ) ,
339346 target_os = "unknown" ) ) ] {
Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ fn is_rdrand_good() -> bool {
9393 unsafe { self_test ( ) }
9494}
9595
96+ #[ allow( dead_code) ]
9697pub fn getrandom_inner ( dest : & mut [ MaybeUninit < u8 > ] ) -> Result < ( ) , Error > {
9798 static RDRAND_GOOD : LazyBool = LazyBool :: new ( ) ;
9899 if !RDRAND_GOOD . unsync_init ( is_rdrand_good) {
@@ -121,3 +122,8 @@ unsafe fn rdrand_exact(dest: &mut [MaybeUninit<u8>]) -> Option<()> {
121122 }
122123 Some ( ( ) )
123124}
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> {
174174 self . 0 ( )
175175 }
176176}
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