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

36 lines
879 B
Rust

#[cfg(test)]
#[cfg(all(feature = "linux", feature = "dlmalloc"))]
mod tests {
use std::{
alloc::{GlobalAlloc, Layout},
sync::Mutex,
};
use asan::{allocator::backend::dlmalloc::DlmallocBackend, mmap::linux::LinuxMmap};
use spin::Lazy;
static INIT_ONCE: Lazy<Mutex<()>> = Lazy::new(|| {
{
env_logger::init();
};
Mutex::new(())
});
const PAGE_SIZE: usize = 4096;
fn allocator() -> DlmallocBackend<LinuxMmap> {
drop(INIT_ONCE.lock().unwrap());
DlmallocBackend::<LinuxMmap>::new(PAGE_SIZE)
}
#[test]
fn test_allocate() {
let allocator = allocator();
let layout = Layout::from_size_align(16, 8).unwrap();
let buf = unsafe { allocator.alloc(layout) };
assert!(!buf.is_null());
unsafe { allocator.dealloc(buf, layout) };
}
}