Skip to content

Commit 11a2733

Browse files
authored
Move fuzzer logging to debug (#6881)
Signed-off-by: Mikhail Kot <mikhail@spiraldb.com>
1 parent bf6303d commit 11a2733

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

fuzz/fuzz_targets/array_ops.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,32 @@
44
#![no_main]
55
#![allow(clippy::unwrap_used, clippy::result_large_err)]
66

7+
use std::str::FromStr;
8+
79
use libfuzzer_sys::Corpus;
810
use libfuzzer_sys::fuzz_target;
11+
use tracing::level_filters::LevelFilter;
912
use vortex_error::vortex_panic;
1013
use vortex_fuzz::FuzzArrayAction;
1114
use vortex_fuzz::run_fuzz_action;
1215

1316
fuzz_target!(
1417
init: {
15-
tracing_subscriber::fmt::init();
18+
let fmt = tracing_subscriber::fmt::format()
19+
.with_ansi(false) // Colour output is messed up in raw logs
20+
.without_time() // We run fuzzer in CI which prepends timestamps
21+
.compact();
22+
let level = std::env::var("RUST_LOG").map(
23+
|v| LevelFilter::from_str(v.as_str()).unwrap()).unwrap_or(LevelFilter::INFO);
24+
tracing_subscriber::fmt()
25+
.event_format(fmt)
26+
.with_max_level(level)
27+
.init();
1628
},
1729
|fuzz_action: FuzzArrayAction| -> Corpus {
1830
match run_fuzz_action(fuzz_action) {
1931
Ok(true) => Corpus::Keep,
2032
Ok(false) => Corpus::Reject,
21-
Err(e) => {
22-
vortex_panic!("{e}");
23-
}
33+
Err(e) => vortex_panic!("{e}"),
2434
}
2535
});

fuzz/src/array/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use strum::EnumIter;
3737
use strum::IntoEnumIterator;
3838
pub(crate) use sum::*;
3939
pub(crate) use take::*;
40-
use tracing::info;
40+
use tracing::debug;
4141
use vortex_array::ArrayRef;
4242
use vortex_array::DynArray;
4343
use vortex_array::IntoArray;
@@ -561,14 +561,14 @@ pub fn run_fuzz_action(fuzz_action: FuzzArrayAction) -> crate::error::VortexFuzz
561561
let FuzzArrayAction { array, actions } = fuzz_action;
562562
let mut current_array = array.to_array();
563563

564-
info!(
564+
debug!(
565565
"Initial array:\nTree:\n{}Values:\n{:#}",
566566
current_array.display_tree(),
567567
current_array.display_values()
568568
);
569569

570570
for (i, (action, expected)) in actions.into_iter().enumerate() {
571-
info!(id = i, action = ?action);
571+
debug!(id = i, action = ?action);
572572
match action {
573573
Action::Compress(strategy) => {
574574
let canonical = current_array

vortex-array/src/display/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ impl Display for dyn DynArray + '_ {
330330
}
331331
}
332332

333+
const DISPLAY_LIMIT: usize = 16;
333334
impl dyn DynArray + '_ {
334335
/// Display logical values of the array
335336
///
@@ -479,10 +480,11 @@ impl dyn DynArray + '_ {
479480
write!(f, "{}", if f.alternate() { "[\n" } else { "[" })?;
480481
let sep = if *omit_comma_after_space { "," } else { ", " };
481482
let sep = if f.alternate() { ",\n" } else { sep };
483+
let limit = std::cmp::min(self.len(), f.precision().unwrap_or(DISPLAY_LIMIT));
482484
write!(
483485
f,
484486
"{}",
485-
(0..self.len())
487+
(0..limit)
486488
.map(|i| self
487489
.scalar_at(i)
488490
.map_or_else(|e| format!("<error: {e}>"), |s| s.to_string()))

0 commit comments

Comments
 (0)