From: Matt Corallo Date: Fri, 18 Feb 2022 15:54:56 +0000 (+0000) Subject: Add explicit compile errors when cfg=fuzzing is mis-set X-Git-Tag: v0.0.105~10^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=b0cb5583b1d2ce9e0a2aee191896df627f39242f;p=rust-lightning Add explicit compile errors when cfg=fuzzing is mis-set --- diff --git a/fuzz/src/bin/chanmon_consistency_target.rs b/fuzz/src/bin/chanmon_consistency_target.rs index c480b3d17..25fe23b58 100644 --- a/fuzz/src/bin/chanmon_consistency_target.rs +++ b/fuzz/src/bin/chanmon_consistency_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::chanmon_consistency::*; diff --git a/fuzz/src/bin/chanmon_deser_target.rs b/fuzz/src/bin/chanmon_deser_target.rs index 8b57874cf..9e9b17626 100644 --- a/fuzz/src/bin/chanmon_deser_target.rs +++ b/fuzz/src/bin/chanmon_deser_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::chanmon_deser::*; diff --git a/fuzz/src/bin/full_stack_target.rs b/fuzz/src/bin/full_stack_target.rs index 7dae65531..bebb7fdcd 100644 --- a/fuzz/src/bin/full_stack_target.rs +++ b/fuzz/src/bin/full_stack_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::full_stack::*; diff --git a/fuzz/src/bin/msg_accept_channel_target.rs b/fuzz/src/bin/msg_accept_channel_target.rs index d28895a0f..0018d09ab 100644 --- a/fuzz/src/bin/msg_accept_channel_target.rs +++ b/fuzz/src/bin/msg_accept_channel_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_accept_channel::*; diff --git a/fuzz/src/bin/msg_announcement_signatures_target.rs b/fuzz/src/bin/msg_announcement_signatures_target.rs index dcfc006eb..593908f41 100644 --- a/fuzz/src/bin/msg_announcement_signatures_target.rs +++ b/fuzz/src/bin/msg_announcement_signatures_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_announcement_signatures::*; diff --git a/fuzz/src/bin/msg_channel_announcement_target.rs b/fuzz/src/bin/msg_channel_announcement_target.rs index 0efc0b41f..f99463142 100644 --- a/fuzz/src/bin/msg_channel_announcement_target.rs +++ b/fuzz/src/bin/msg_channel_announcement_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_channel_announcement::*; diff --git a/fuzz/src/bin/msg_channel_reestablish_target.rs b/fuzz/src/bin/msg_channel_reestablish_target.rs index 0111d2b27..ba1a76d99 100644 --- a/fuzz/src/bin/msg_channel_reestablish_target.rs +++ b/fuzz/src/bin/msg_channel_reestablish_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_channel_reestablish::*; diff --git a/fuzz/src/bin/msg_channel_update_target.rs b/fuzz/src/bin/msg_channel_update_target.rs index 4bfb9860c..0198ddc00 100644 --- a/fuzz/src/bin/msg_channel_update_target.rs +++ b/fuzz/src/bin/msg_channel_update_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_channel_update::*; diff --git a/fuzz/src/bin/msg_closing_signed_target.rs b/fuzz/src/bin/msg_closing_signed_target.rs index 12dbb31cd..abd69fc95 100644 --- a/fuzz/src/bin/msg_closing_signed_target.rs +++ b/fuzz/src/bin/msg_closing_signed_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_closing_signed::*; diff --git a/fuzz/src/bin/msg_commitment_signed_target.rs b/fuzz/src/bin/msg_commitment_signed_target.rs index 407f0288c..0324301fe 100644 --- a/fuzz/src/bin/msg_commitment_signed_target.rs +++ b/fuzz/src/bin/msg_commitment_signed_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_commitment_signed::*; diff --git a/fuzz/src/bin/msg_decoded_onion_error_packet_target.rs b/fuzz/src/bin/msg_decoded_onion_error_packet_target.rs index 9f76e6967..1f99bab2b 100644 --- a/fuzz/src/bin/msg_decoded_onion_error_packet_target.rs +++ b/fuzz/src/bin/msg_decoded_onion_error_packet_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_decoded_onion_error_packet::*; diff --git a/fuzz/src/bin/msg_error_message_target.rs b/fuzz/src/bin/msg_error_message_target.rs index dc418c93d..8609bf65a 100644 --- a/fuzz/src/bin/msg_error_message_target.rs +++ b/fuzz/src/bin/msg_error_message_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_error_message::*; diff --git a/fuzz/src/bin/msg_funding_created_target.rs b/fuzz/src/bin/msg_funding_created_target.rs index 6fb87c408..51ac425d7 100644 --- a/fuzz/src/bin/msg_funding_created_target.rs +++ b/fuzz/src/bin/msg_funding_created_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_funding_created::*; diff --git a/fuzz/src/bin/msg_funding_locked_target.rs b/fuzz/src/bin/msg_funding_locked_target.rs index 7b8f21f8a..986f7f898 100644 --- a/fuzz/src/bin/msg_funding_locked_target.rs +++ b/fuzz/src/bin/msg_funding_locked_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_funding_locked::*; diff --git a/fuzz/src/bin/msg_funding_signed_target.rs b/fuzz/src/bin/msg_funding_signed_target.rs index ea05acdce..bfee1f5ae 100644 --- a/fuzz/src/bin/msg_funding_signed_target.rs +++ b/fuzz/src/bin/msg_funding_signed_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_funding_signed::*; diff --git a/fuzz/src/bin/msg_gossip_timestamp_filter_target.rs b/fuzz/src/bin/msg_gossip_timestamp_filter_target.rs index 1aba4e3fe..aa94f2001 100644 --- a/fuzz/src/bin/msg_gossip_timestamp_filter_target.rs +++ b/fuzz/src/bin/msg_gossip_timestamp_filter_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_gossip_timestamp_filter::*; diff --git a/fuzz/src/bin/msg_init_target.rs b/fuzz/src/bin/msg_init_target.rs index dd7b197a4..342ceaf3f 100644 --- a/fuzz/src/bin/msg_init_target.rs +++ b/fuzz/src/bin/msg_init_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_init::*; diff --git a/fuzz/src/bin/msg_node_announcement_target.rs b/fuzz/src/bin/msg_node_announcement_target.rs index 63b23bd66..320126337 100644 --- a/fuzz/src/bin/msg_node_announcement_target.rs +++ b/fuzz/src/bin/msg_node_announcement_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_node_announcement::*; diff --git a/fuzz/src/bin/msg_onion_hop_data_target.rs b/fuzz/src/bin/msg_onion_hop_data_target.rs index 493817c7e..ae21e9bd9 100644 --- a/fuzz/src/bin/msg_onion_hop_data_target.rs +++ b/fuzz/src/bin/msg_onion_hop_data_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_onion_hop_data::*; diff --git a/fuzz/src/bin/msg_open_channel_target.rs b/fuzz/src/bin/msg_open_channel_target.rs index d6c9de48f..cee4c0d07 100644 --- a/fuzz/src/bin/msg_open_channel_target.rs +++ b/fuzz/src/bin/msg_open_channel_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_open_channel::*; diff --git a/fuzz/src/bin/msg_ping_target.rs b/fuzz/src/bin/msg_ping_target.rs index e739cd580..19e8abe24 100644 --- a/fuzz/src/bin/msg_ping_target.rs +++ b/fuzz/src/bin/msg_ping_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_ping::*; diff --git a/fuzz/src/bin/msg_pong_target.rs b/fuzz/src/bin/msg_pong_target.rs index 73113472c..429550bd1 100644 --- a/fuzz/src/bin/msg_pong_target.rs +++ b/fuzz/src/bin/msg_pong_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_pong::*; diff --git a/fuzz/src/bin/msg_query_channel_range_target.rs b/fuzz/src/bin/msg_query_channel_range_target.rs index db22fa525..c2ce1fd5f 100644 --- a/fuzz/src/bin/msg_query_channel_range_target.rs +++ b/fuzz/src/bin/msg_query_channel_range_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_query_channel_range::*; diff --git a/fuzz/src/bin/msg_query_short_channel_ids_target.rs b/fuzz/src/bin/msg_query_short_channel_ids_target.rs index 6c470e3b1..af3d37065 100644 --- a/fuzz/src/bin/msg_query_short_channel_ids_target.rs +++ b/fuzz/src/bin/msg_query_short_channel_ids_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_query_short_channel_ids::*; diff --git a/fuzz/src/bin/msg_reply_channel_range_target.rs b/fuzz/src/bin/msg_reply_channel_range_target.rs index 68651347b..0cddbcaf8 100644 --- a/fuzz/src/bin/msg_reply_channel_range_target.rs +++ b/fuzz/src/bin/msg_reply_channel_range_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_reply_channel_range::*; diff --git a/fuzz/src/bin/msg_reply_short_channel_ids_end_target.rs b/fuzz/src/bin/msg_reply_short_channel_ids_end_target.rs index de3e9f1cc..d802299b2 100644 --- a/fuzz/src/bin/msg_reply_short_channel_ids_end_target.rs +++ b/fuzz/src/bin/msg_reply_short_channel_ids_end_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_reply_short_channel_ids_end::*; diff --git a/fuzz/src/bin/msg_revoke_and_ack_target.rs b/fuzz/src/bin/msg_revoke_and_ack_target.rs index e0f781986..d72d63cc3 100644 --- a/fuzz/src/bin/msg_revoke_and_ack_target.rs +++ b/fuzz/src/bin/msg_revoke_and_ack_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_revoke_and_ack::*; diff --git a/fuzz/src/bin/msg_shutdown_target.rs b/fuzz/src/bin/msg_shutdown_target.rs index 6220fc928..1959a8cfa 100644 --- a/fuzz/src/bin/msg_shutdown_target.rs +++ b/fuzz/src/bin/msg_shutdown_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_shutdown::*; diff --git a/fuzz/src/bin/msg_update_add_htlc_target.rs b/fuzz/src/bin/msg_update_add_htlc_target.rs index dffdb8309..47faa7b1b 100644 --- a/fuzz/src/bin/msg_update_add_htlc_target.rs +++ b/fuzz/src/bin/msg_update_add_htlc_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_update_add_htlc::*; diff --git a/fuzz/src/bin/msg_update_fail_htlc_target.rs b/fuzz/src/bin/msg_update_fail_htlc_target.rs index 2828b396a..0c47190f7 100644 --- a/fuzz/src/bin/msg_update_fail_htlc_target.rs +++ b/fuzz/src/bin/msg_update_fail_htlc_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_update_fail_htlc::*; diff --git a/fuzz/src/bin/msg_update_fail_malformed_htlc_target.rs b/fuzz/src/bin/msg_update_fail_malformed_htlc_target.rs index 8bf82a517..917fad9ce 100644 --- a/fuzz/src/bin/msg_update_fail_malformed_htlc_target.rs +++ b/fuzz/src/bin/msg_update_fail_malformed_htlc_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_update_fail_malformed_htlc::*; diff --git a/fuzz/src/bin/msg_update_fee_target.rs b/fuzz/src/bin/msg_update_fee_target.rs index e9e63f28a..f7baec58a 100644 --- a/fuzz/src/bin/msg_update_fee_target.rs +++ b/fuzz/src/bin/msg_update_fee_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_update_fee::*; diff --git a/fuzz/src/bin/msg_update_fulfill_htlc_target.rs b/fuzz/src/bin/msg_update_fulfill_htlc_target.rs index 4820b0adf..23197b38e 100644 --- a/fuzz/src/bin/msg_update_fulfill_htlc_target.rs +++ b/fuzz/src/bin/msg_update_fulfill_htlc_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::msg_targets::msg_update_fulfill_htlc::*; diff --git a/fuzz/src/bin/peer_crypt_target.rs b/fuzz/src/bin/peer_crypt_target.rs index 8f6262698..c7cbe8c2c 100644 --- a/fuzz/src/bin/peer_crypt_target.rs +++ b/fuzz/src/bin/peer_crypt_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::peer_crypt::*; diff --git a/fuzz/src/bin/router_target.rs b/fuzz/src/bin/router_target.rs index 4df8b2a00..2082f115a 100644 --- a/fuzz/src/bin/router_target.rs +++ b/fuzz/src/bin/router_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::router::*; diff --git a/fuzz/src/bin/target_template.txt b/fuzz/src/bin/target_template.txt index 7db3bc80b..7b0ec0eeb 100644 --- a/fuzz/src/bin/target_template.txt +++ b/fuzz/src/bin/target_template.txt @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::TARGET_MOD::*; diff --git a/fuzz/src/bin/zbase32_target.rs b/fuzz/src/bin/zbase32_target.rs index 0b9d62915..1553d6d2b 100644 --- a/fuzz/src/bin/zbase32_target.rs +++ b/fuzz/src/bin/zbase32_target.rs @@ -12,6 +12,9 @@ #![cfg_attr(feature = "libfuzzer_fuzz", no_main)] +#[cfg(not(fuzzing))] +compile_error!("Fuzz targets need cfg=fuzzing"); + extern crate lightning_fuzz; use lightning_fuzz::zbase32::*; diff --git a/lightning/src/lib.rs b/lightning/src/lib.rs index 132189858..2798f78ad 100644 --- a/lightning/src/lib.rs +++ b/lightning/src/lib.rs @@ -36,6 +36,9 @@ #[cfg(not(any(feature = "std", feature = "no-std")))] compile_error!("at least one of the `std` or `no-std` features must be enabled"); +#[cfg(all(fuzzing, test))] +compile_error!("Tests will always fail with cfg=fuzzing"); + #[macro_use] extern crate alloc; extern crate bitcoin;