1 // This file is auto-generated by gen_target.sh based on target_template.txt
2 // To modify it, modify target_template.txt and run gen_target.sh instead.
4 #![cfg_attr(feature = "libfuzzer_fuzz", no_main)]
6 extern crate lightning_fuzz;
7 use lightning_fuzz::msg_targets::msg_closing_signed::*;
12 #[cfg(feature = "afl")]
13 #[macro_use] extern crate afl;
14 #[cfg(feature = "afl")]
17 msg_closing_signed_run(data.as_ptr(), data.len());
21 #[cfg(feature = "honggfuzz")]
22 #[macro_use] extern crate honggfuzz;
23 #[cfg(feature = "honggfuzz")]
27 msg_closing_signed_run(data.as_ptr(), data.len());
32 #[cfg(feature = "libfuzzer_fuzz")]
33 #[macro_use] extern crate libfuzzer_sys;
34 #[cfg(feature = "libfuzzer_fuzz")]
35 fuzz_target!(|data: &[u8]| {
36 msg_closing_signed_run(data.as_ptr(), data.len());
39 #[cfg(feature = "stdin_fuzz")]
41 let mut data = Vec::with_capacity(8192);
42 std::io::stdin().read_to_end(&mut data).unwrap();
43 msg_closing_signed_run(data.as_ptr(), data.len());
48 use lightning_fuzz::utils::test_logger::StringBuffer;
50 use std::sync::{atomic, Arc};
52 let data: Vec<u8> = vec![0];
53 msg_closing_signed_run(data.as_ptr(), data.len());
55 let mut threads = Vec::new();
56 let threads_running = Arc::new(atomic::AtomicUsize::new(0));
57 if let Ok(tests) = fs::read_dir("test_cases/msg_closing_signed") {
59 let mut data: Vec<u8> = Vec::new();
60 let path = test.unwrap().path();
61 fs::File::open(&path).unwrap().read_to_end(&mut data).unwrap();
62 threads_running.fetch_add(1, atomic::Ordering::AcqRel);
64 let thread_count_ref = Arc::clone(&threads_running);
65 let main_thread_ref = std::thread::current();
66 threads.push((path.file_name().unwrap().to_str().unwrap().to_string(),
67 std::thread::spawn(move || {
68 let string_logger = StringBuffer::new();
70 let panic_logger = string_logger.clone();
71 let res = if ::std::panic::catch_unwind(move || {
72 msg_closing_signed_test(&data, panic_logger);
74 Some(string_logger.into_string())
76 thread_count_ref.fetch_sub(1, atomic::Ordering::AcqRel);
77 main_thread_ref.unpark();
81 while threads_running.load(atomic::Ordering::Acquire) > 32 {
86 for (test, thread) in threads.drain(..) {
87 if let Some(output) = thread.join().unwrap() {
88 println!("Output of {}:\n{}", test, output);