WorksButNotTested 728b1216bb
Librasan (#3023)
* 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>
2025-03-10 17:27:55 +01:00

40 lines
899 B
Rust

#[cfg(test)]
#[cfg(all(feature = "hooks", feature = "linux", not(feature = "libc")))]
mod tests {
use core::{ffi::c_void, ptr::null_mut};
use asan::hooks::{expect_panic, size_t, write::linux::write};
#[test]
fn test_read_invalid_args() {
let fd = 0;
let buf = null_mut();
let count = 10;
expect_panic();
unsafe { write(fd, buf, count) };
unreachable!();
}
#[test]
fn test_read_valid_args() {
let fd = -1;
let buf = null_mut();
let count = 0;
let ret = unsafe { write(fd, buf, count) };
assert!(ret < 0);
}
#[test]
fn test_read_valid_args_with_buffer() {
let fd = -1;
let mut buf = [0u8; 10];
let count = buf.len() as size_t;
let ret = unsafe { write(fd, buf.as_mut_ptr() as *mut c_void, count) };
assert!(ret < 0);
}
}