57 lines
1.7 KiB
Rust
57 lines
1.7 KiB
Rust
//! Crash regression for a single large V8 allocation. The child contains native V8 aborts.
|
|
use sausage::cred::{
|
|
script::{Limits, Script},
|
|
v8::V8,
|
|
};
|
|
|
|
#[test]
|
|
fn removes_bootstrap_capabilities_and_clocks() {
|
|
let result = V8.evaluate(
|
|
"export default () => [typeof WebAssembly,typeof SharedArrayBuffer,typeof Atomics,typeof __infra,typeof Intl,typeof queueMicrotask]",
|
|
"null", None, Limits { max_time_ms: Some(1000), ..Limits::default() },
|
|
).unwrap();
|
|
assert_eq!(
|
|
result,
|
|
"[\"undefined\",\"undefined\",\"undefined\",\"undefined\",\"undefined\",\"undefined\"]"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn flat_string_child() {
|
|
if std::env::var_os("T28_FLAT_STRING_CHILD").is_none() {
|
|
return;
|
|
}
|
|
let bits = std::env::var("T28_FLAT_STRING_BITS").unwrap_or_else(|_| "28".into());
|
|
assert!(matches!(bits.as_str(), "27" | "28"));
|
|
let result = V8.evaluate(
|
|
&format!("export default () => 'x'.repeat(2**{bits}).indexOf('y')"),
|
|
"null",
|
|
None,
|
|
Limits {
|
|
max_time_ms: Some(1000),
|
|
..Limits::default()
|
|
},
|
|
);
|
|
assert!(
|
|
result.is_err(),
|
|
"the flat string bypassed the configured heap budget"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn flat_string_does_not_abort() {
|
|
for bits in ["27", "28"] {
|
|
let output = std::process::Command::new(std::env::current_exe().unwrap())
|
|
.args(["--exact", "flat_string_child", "--nocapture"])
|
|
.env("T28_FLAT_STRING_CHILD", "1")
|
|
.env("T28_FLAT_STRING_BITS", bits)
|
|
.output()
|
|
.unwrap();
|
|
assert!(
|
|
output.status.success(),
|
|
"the script worker aborted or failed at 2**{bits} bytes: {}",
|
|
output.status
|
|
);
|
|
}
|
|
}
|