Skip to content

Commit

Permalink
refactor: simplify derives, rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
morrisonlevi committed May 31, 2024
1 parent cdf9dcc commit dc8a9df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
20 changes: 10 additions & 10 deletions profiling/src/internal/profile/fuzz_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bolero_generator::{TypeGeneratorWithParams, ValueGenerator};
use std::collections::{HashMap, HashSet};
use std::time::SystemTime;

#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, bolero_generator::TypeGenerator)]
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, TypeGenerator)]
pub struct Function {
/// Name of the function, in human-readable form if available.
pub name: Box<str>,
Expand All @@ -37,7 +37,7 @@ impl<'a> From<&'a Function> for api::Function<'a> {
}
}

#[derive(Clone, Debug, Default, bolero_generator::TypeGenerator)]
#[derive(Clone, Debug, Default, TypeGenerator)]
pub struct Label {
pub key: Box<str>,

Expand Down Expand Up @@ -66,7 +66,7 @@ impl<'a> From<&'a Label> for api::Label<'a> {
}
}

#[derive(Clone, Debug, Eq, PartialEq, bolero_generator::TypeGenerator)]
#[derive(Clone, Debug, Eq, PartialEq, TypeGenerator)]
pub struct Line {
/// The corresponding profile.Function for this line.
pub function: Function,
Expand All @@ -84,7 +84,7 @@ impl<'a> From<&'a Line> for api::Line<'a> {
}
}

#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, bolero_generator::TypeGenerator)]
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, TypeGenerator)]
pub struct Location {
pub mapping: Mapping,
pub function: Function,
Expand All @@ -109,7 +109,7 @@ impl<'a> From<&'a Location> for api::Location<'a> {
}
}

#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, bolero_generator::TypeGenerator)]
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, TypeGenerator)]
pub struct Mapping {
/// Address at which the binary (or DLL) is loaded into memory.
pub memory_start: u64,
Expand Down Expand Up @@ -188,7 +188,7 @@ impl std::hash::Hash for Label {
self.key.hash(state)
}
}
impl bolero_generator::TypeGenerator for Sample {
impl TypeGenerator for Sample {
fn generate<D: bolero_generator::Driver>(driver: &mut D) -> Option<Self> {
let locations = Vec::<Location>::gen_with().generate(driver)?;
let values = Vec::<i64>::gen_with().generate(driver)?;
Expand Down Expand Up @@ -362,7 +362,7 @@ fn assert_samples_eq(
}
}

fn add_sample<'a>(
fn fuzz_add_sample<'a>(
timestamp: &Option<Timestamp>,
sample: &'a Sample,
expected_sample_types: &[owned_types::ValueType],
Expand Down Expand Up @@ -393,7 +393,7 @@ fn add_sample<'a>(

/// Fuzzes adding a bunch of samples to the profile.
#[test]
fn fuzz_add_sample() {
fn test_fuzz_add_sample() {
bolero::check!()
.with_generator((
Vec::<owned_types::ValueType>::gen(),
Expand All @@ -409,7 +409,7 @@ fn fuzz_add_sample() {
let mut samples_without_timestamps: HashMap<(&Vec<Location>, &Vec<Label>), Vec<i64>> =
HashMap::new();
for (timestamp, sample) in samples {
add_sample(
fuzz_add_sample(
timestamp,
sample,
expected_sample_types,
Expand Down Expand Up @@ -567,7 +567,7 @@ fn fuzz_api_function_calls() {
for operation in operations {
match operation {
Operation::AddSample(timestamp, sample) => {
add_sample(
fuzz_add_sample(
timestamp,
sample,
sample_types,
Expand Down
1 change: 0 additions & 1 deletion profiling/src/internal/profile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@ impl Profile {
#[cfg(test)]
mod api_tests {
use super::*;
use std::collections::HashMap;

#[test]
fn interning() {
Expand Down

0 comments on commit dc8a9df

Please sign in to comment.