
* 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>
50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
#[cfg(test)]
|
|
#[cfg(feature = "hooks")]
|
|
mod tests {
|
|
use core::ptr::{null, null_mut};
|
|
|
|
use asan::{expect_panic, hooks::wcscpy::wcscpy, wchar_t};
|
|
use widestring::widecstr;
|
|
|
|
#[test]
|
|
fn test_wcscpy_null_s() {
|
|
expect_panic();
|
|
let data = [0u16; 10];
|
|
unsafe { wcscpy(null_mut(), data.as_ptr() as *const wchar_t) };
|
|
unreachable!();
|
|
}
|
|
|
|
#[test]
|
|
fn test_wcscpy_null_s2() {
|
|
expect_panic();
|
|
let data = [0u16; 10];
|
|
unsafe { wcscpy(data.as_ptr() as *mut wchar_t, null()) };
|
|
unreachable!();
|
|
}
|
|
|
|
#[test]
|
|
fn test_wcscpy_zero_length_both() {
|
|
let data = [0u16; 10];
|
|
let ret = unsafe {
|
|
wcscpy(
|
|
data.as_ptr() as *mut wchar_t,
|
|
data.as_ptr() as *const wchar_t,
|
|
)
|
|
};
|
|
assert_eq!(ret, data.as_ptr() as *mut wchar_t);
|
|
}
|
|
|
|
#[test]
|
|
fn test_wcscpy_copies() {
|
|
let mut vec = widecstr!("abcdefghij").as_slice().to_vec();
|
|
let s = vec.as_mut_slice();
|
|
let ct = widecstr!("klmnop");
|
|
let ret = unsafe { wcscpy(s.as_ptr() as *mut wchar_t, ct.as_ptr() as *const wchar_t) };
|
|
assert_eq!(ret, s.as_ptr() as *mut wchar_t);
|
|
ct.as_slice()
|
|
.iter()
|
|
.zip(s.iter())
|
|
.for_each(|(x, y)| assert_eq!(*x, *y));
|
|
}
|
|
}
|