@@ -230,77 +230,28 @@ pub fn common_signals() -> Vec<Signal> {
230
230
#[ cfg( test) ]
231
231
/// Tester for executor
232
232
pub mod test {
233
- use core:: marker:: PhantomData ;
234
-
235
- use libafl_bolts:: { AsSlice , Error } ;
236
-
233
+ use super :: nop:: NopExecutor ;
237
234
use crate :: {
238
235
events:: NopEventManager ,
239
236
executors:: { Executor , ExitKind } ,
240
237
fuzzer:: NopFuzzer ,
241
- inputs:: { BytesInput , HasTargetBytes } ,
242
- state:: { HasExecutions , NopState } ,
238
+ inputs:: BytesInput ,
239
+ state:: NopState ,
243
240
} ;
244
241
245
- /// A simple executor that does nothing.
246
- /// If intput len is 0, `run_target` will return Err
247
- #[ derive( Debug ) ]
248
- pub struct NopExecutor < S > {
249
- phantom : PhantomData < S > ,
250
- }
251
-
252
- impl < S > NopExecutor < S > {
253
- /// Creates a new [`NopExecutor`]
254
- #[ must_use]
255
- pub fn new ( ) -> Self {
256
- Self {
257
- phantom : PhantomData ,
258
- }
259
- }
260
- }
261
-
262
- impl < S > Default for NopExecutor < S > {
263
- fn default ( ) -> Self {
264
- Self :: new ( )
265
- }
266
- }
267
-
268
- impl < EM , I , S , Z > Executor < EM , I , S , Z > for NopExecutor < S >
269
- where
270
- S : HasExecutions ,
271
- I : HasTargetBytes ,
272
- {
273
- fn run_target (
274
- & mut self ,
275
- _fuzzer : & mut Z ,
276
- state : & mut S ,
277
- _mgr : & mut EM ,
278
- input : & I ,
279
- ) -> Result < ExitKind , Error > {
280
- * state. executions_mut ( ) += 1 ;
281
-
282
- if input. target_bytes ( ) . as_slice ( ) . is_empty ( ) {
283
- Err ( Error :: empty ( "Input Empty" ) )
284
- } else {
285
- Ok ( ExitKind :: Ok )
286
- }
287
- }
288
- }
289
-
290
242
#[ test]
291
243
fn nop_executor ( ) {
292
244
let empty_input = BytesInput :: new ( vec ! [ ] ) ;
293
- let nonempty_input = BytesInput :: new ( vec ! [ 1u8 ] ) ;
294
- let mut executor = NopExecutor :: new ( ) ;
245
+ let mut executor = NopExecutor :: ok ( ) ;
295
246
let mut fuzzer = NopFuzzer :: new ( ) ;
296
247
let mut mgr: NopEventManager = NopEventManager :: new ( ) ;
297
248
let mut state: NopState < BytesInput > = NopState :: new ( ) ;
298
249
299
- executor
300
- . run_target ( & mut fuzzer , & mut state , & mut mgr , & empty_input )
301
- . unwrap_err ( ) ;
302
- executor
303
- . run_target ( & mut fuzzer , & mut state , & mut mgr , & nonempty_input )
304
- . unwrap ( ) ;
250
+ assert_eq ! (
251
+ executor
252
+ . run_target ( & mut fuzzer , & mut state , & mut mgr , & empty_input )
253
+ . unwrap ( ) ,
254
+ ExitKind :: Ok
255
+ ) ;
305
256
}
306
257
}
0 commit comments