@@ -93,6 +93,7 @@ pub trait SmfInstance {
93
93
> ;
94
94
fn disable ( & self , temporary : bool ) -> Result < ( ) , crucible_smf:: ScfError > ;
95
95
fn enable ( & self , temporary : bool ) -> Result < ( ) , crucible_smf:: ScfError > ;
96
+ #[ cfg( test) ]
96
97
fn enabled ( & self ) -> bool ;
97
98
98
99
fn get_pg (
@@ -146,6 +147,7 @@ impl<'a> SmfInstance for RealSmfInstance<'a> {
146
147
self . inst . enable ( temporary)
147
148
}
148
149
150
+ #[ cfg( test) ]
149
151
fn enabled ( & self ) -> bool {
150
152
unimplemented ! ( ) ;
151
153
}
@@ -355,28 +357,29 @@ impl<'a> SmfTransaction for RealSmfTransaction<'a> {
355
357
}
356
358
357
359
#[ derive( Debug ) ]
360
+ #[ cfg( test) ]
358
361
pub struct MockSmf {
359
362
scope : String ,
360
363
361
364
// Instance name -> Mock instance entry
362
365
config : Mutex < HashMap < String , MockSmfInstance > > ,
363
366
}
364
367
368
+ #[ cfg( test) ]
365
369
impl MockSmf {
366
- #[ cfg( test) ]
367
370
pub fn new ( scope : String ) -> MockSmf {
368
371
MockSmf {
369
372
scope,
370
373
config : Mutex :: new ( HashMap :: new ( ) ) ,
371
374
}
372
375
}
373
376
374
- #[ cfg( test) ]
375
377
pub fn config_is_empty ( & self ) -> bool {
376
378
self . config . lock ( ) . unwrap ( ) . is_empty ( )
377
379
}
378
380
}
379
381
382
+ #[ cfg( test) ]
380
383
impl PartialEq for MockSmf {
381
384
fn eq ( & self , other : & Self ) -> bool {
382
385
let lhs = self . config . lock ( ) . unwrap ( ) ;
@@ -386,6 +389,7 @@ impl PartialEq for MockSmf {
386
389
}
387
390
}
388
391
392
+ #[ cfg( test) ]
389
393
impl SmfInterface for MockSmf {
390
394
fn instances (
391
395
& self ,
@@ -435,7 +439,6 @@ impl SmfInterface for MockSmf {
435
439
/// datafile, disabled stuff remains in the current SMF interface and will
436
440
/// cause PartialEq comparison to fail. Prune that here so that comparison
437
441
/// can be done.
438
- #[ cfg( test) ]
439
442
fn prune ( & self ) {
440
443
let mut config = self . config . lock ( ) . unwrap ( ) ;
441
444
let pairs: Vec < ( String , MockSmfInstance ) > = config. drain ( ) . collect ( ) ;
@@ -542,6 +545,7 @@ impl SmfInstance for MockSmfInstance {
542
545
Ok ( ( ) )
543
546
}
544
547
548
+ #[ cfg( test) ]
545
549
fn enabled ( & self ) -> bool {
546
550
self . inner . lock ( ) . unwrap ( ) . enabled
547
551
}
0 commit comments