make multicore optional

This commit is contained in:
Alwin Berger 2022-02-27 22:16:55 +01:00
parent a6294af2c3
commit 5d08f3a9d7

View File

@ -302,7 +302,7 @@ fn fuzz(
}); });
//====== Child Function //====== Child Function
let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr, _core_id| { let mut run_client = |state: Option<StdState<_, _, _, _, _>>, mut mgr, _core_id| -> std::result::Result<(), libafl::Error> {
//====== Set up Emu and termination-point //====== Set up Emu and termination-point
let emu = Emulator::new(&args, &env); let emu = Emulator::new(&args, &env);
@ -467,6 +467,7 @@ fn fuzz(
#[cfg(unix)] #[cfg(unix)]
let file_null = File::open("/dev/null")?; let file_null = File::open("/dev/null")?;
#[cfg(unix)] #[cfg(unix)]
#[cfg(feature = "multicore")]
{ {
let null_fd = file_null.as_raw_fd(); let null_fd = file_null.as_raw_fd();
dup2(null_fd, io::stdout().as_raw_fd())?; dup2(null_fd, io::stdout().as_raw_fd())?;
@ -482,20 +483,32 @@ fn fuzz(
}; };
match Launcher::builder() // Multicore Variant
.shmem_provider(shmem_provider) #[cfg(feature = "multicore")]
.configuration(EventConfig::AlwaysUnique)
.monitor(monitor)
.run_client(&mut run_client)
.cores(&Cores::from_cmdline("all").unwrap())
// .broker_port(1337)
// .remote_broker_addr(remote_broker_addr)
//.stdout_file(Some("/dev/null"))
.build()
.launch()
{ {
Ok(_) | Err(Error::ShuttingDown) => (), match Launcher::builder()
Err(e) => panic!("{:?}", e), .shmem_provider(shmem_provider)
}; .configuration(EventConfig::AlwaysUnique)
Ok(()) .monitor(monitor)
.run_client(&mut run_client)
.cores(&Cores::from_cmdline("all").unwrap())
// .broker_port(1337)
// .remote_broker_addr(remote_broker_addr)
//.stdout_file(Some("/dev/null"))
.build()
.launch()
{
Ok(_) | Err(Error::ShuttingDown) => (),
Err(e) => panic!("{:?}", e),
};
Ok(())
}
// Simple Variant
#[cfg(not(feature = "multicore"))]
{
let stats = SimpleStats::new(|s| println!("{}", s));
let mgr = SimpleEventManager::new(stats);
run_client(None, mgr, 0)
}
} }