Skip to content

Commit

Permalink
capi: Add blaze_cache_src_process conversion test
Browse files Browse the repository at this point in the history
Add a test exercising the conversion from blaze_cache_src_process to
cache::Process.

Signed-off-by: Daniel Müller <deso@posteo.net>
  • Loading branch information
d-e-s-o committed Feb 11, 2025
1 parent 4f9b893 commit 0ee63be
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions capi/src/symbolize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct blaze_cache_src_process {
pub cache_vmas: bool,
/// Unused member available for future expansion. Must be initialized
/// to zero.
pub reserved: [u8; 15],
pub reserved: [u8; 11],
}

impl Default for blaze_cache_src_process {
Expand All @@ -78,7 +78,7 @@ impl Default for blaze_cache_src_process {
type_size: mem::size_of::<Self>(),
pid: 0,
cache_vmas: false,
reserved: [0; 15],
reserved: [0; 11],
}
}
}
Expand Down Expand Up @@ -1437,6 +1437,20 @@ mod tests {
);
}

/// Check that we can convert a [`blaze_cache_src_process`] into a
/// [`cache::Process`].
#[tag(miri)]
#[test]
fn cache_process_conversion() {
let process = blaze_cache_src_process {
pid: 42,
cache_vmas: false,
..Default::default()
};
let process = cache::Process::from(process);
assert_eq!(process.pid, Pid::from(42))
}

/// Test the Rust to C symbol conversion.
#[tag(miri)]
#[test]
Expand Down Expand Up @@ -1933,6 +1947,7 @@ mod tests {
..Default::default()
};
let () = unsafe { blaze_symbolize_cache_process(symbolizer, &cache) };
assert_eq!(blaze_err_last(), blaze_err::BLAZE_ERR_OK);

let src = blaze_symbolize_src_process {
pid: 0,
Expand Down

0 comments on commit 0ee63be

Please sign in to comment.