
* Fixes to main * Add librasan * Party like it's 2024 * Fix snapshot module to work with guest asan * Fix guest_asan module * Fixes to runner * Fix linking issues using a REL * Fix qemu_launcher * Change modify_mapping to a method * Fix gasan_test * Remove debug from Justfile * Optimize release build of librasan * Set ulimit for qasan and gasan tests * Tidy up symbol renaming * Add missing symbols for PPC * Change to support rustix 1.0.0 * Canonicalize the CUSTOM_ASAN_PATH * Review changes * Restructure backends * release_max_level_info * More review changes * Clippy fixes * Changes to reduce the burden on the CI * Fix macos clippy --------- Co-authored-by: Your Name <you@example.com>
46 lines
1.2 KiB
Rust
46 lines
1.2 KiB
Rust
#[cfg(test)]
|
|
#[cfg(feature = "hooks")]
|
|
mod tests {
|
|
use core::{ffi::c_void, ptr::null_mut};
|
|
|
|
use asan::{expect_panic, hooks::memset::memset};
|
|
|
|
#[test]
|
|
fn test_memset_zero_length() {
|
|
unsafe { memset(null_mut(), 0, 0) };
|
|
}
|
|
|
|
#[test]
|
|
fn test_memset_null_s() {
|
|
expect_panic();
|
|
unsafe { memset(null_mut(), 0, 10) };
|
|
unreachable!();
|
|
}
|
|
|
|
#[test]
|
|
fn test_memset_zero_buffer() {
|
|
let data = [0xffu8; 10];
|
|
unsafe { memset(data.as_ptr() as *mut c_void, 0, data.len()) };
|
|
data.iter().for_each(|x| assert_eq!(*x, 0));
|
|
}
|
|
|
|
#[test]
|
|
fn test_memset_nonzero_buffer() {
|
|
let data = [0u8; 10];
|
|
unsafe { memset(data.as_ptr() as *mut c_void, 0xff, data.len()) };
|
|
data.iter().for_each(|x| assert_eq!(*x, 0xff));
|
|
}
|
|
|
|
#[test]
|
|
fn test_memset_partial_zero_buffer() {
|
|
let data = [0xffu8; 10];
|
|
unsafe { memset(data.as_ptr().add(2) as *mut c_void, 0x88, data.len() - 4) };
|
|
data.iter()
|
|
.skip(2)
|
|
.take(6)
|
|
.for_each(|x| assert_eq!(*x, 0x88));
|
|
data.iter().take(2).for_each(|x| assert_eq!(*x, 0xff));
|
|
data.iter().skip(8).for_each(|x| assert_eq!(*x, 0xff));
|
|
}
|
|
}
|