pub fn segfault() -> ! {
let null = crate::null_mut::<u8>();
*null = 42;
let max = crate::not_alloc::<u8>();
*max = 69;
unreachable!("Sorry, your platform is too strong.")
}
#[cfg(test)]
mod tests {
#[test]
fn test_segfault() {
use std::process::Command;
let output = Command::new("cargo")
.arg("run")
.arg("segfault")
.output()
.unwrap();
if output.status.success()
|| std::str::from_utf8(&output.stderr)
.unwrap()
.contains("Sorry, your platform is too strong.")
{
panic!("Segfault failed to segfault");
}
}
}