cargo fmt

This commit is contained in:
elipeter 2026-05-21 14:35:42 -05:00
parent bec7bbf96c
commit 3a35cd6c8f
294 changed files with 6809 additions and 3911 deletions

View file

@ -70,9 +70,12 @@ impl CShape {
let kind = spec.entry_kind.tag();
let has_main_argv = (source.contains("int main(") || source.contains("int main ("))
&& (source.contains("argc") || source.contains("char *argv")
|| source.contains("char* argv") || source.contains("char **argv"));
let has_libfuzzer = source.contains("LLVMFuzzerTestOneInput") || entry == "LLVMFuzzerTestOneInput";
&& (source.contains("argc")
|| source.contains("char *argv")
|| source.contains("char* argv")
|| source.contains("char **argv"));
let has_libfuzzer =
source.contains("LLVMFuzzerTestOneInput") || entry == "LLVMFuzzerTestOneInput";
if has_libfuzzer {
return Self::LibfuzzerEntry;
@ -96,7 +99,10 @@ pub fn detect_shape(spec: &HarnessSpec) -> CShape {
}
fn read_entry_source(entry_file: &str) -> String {
let candidates = [PathBuf::from(entry_file), PathBuf::from(".").join(entry_file)];
let candidates = [
PathBuf::from(entry_file),
PathBuf::from(".").join(entry_file),
];
for path in &candidates {
if let Ok(s) = std::fs::read_to_string(path) {
return s;
@ -735,9 +741,21 @@ mod tests {
#[test]
fn entry_kinds_supported_is_non_empty() {
assert!(!CEmitter.entry_kinds_supported().is_empty());
assert!(CEmitter.entry_kinds_supported().contains(&EntryKindTag::Function));
assert!(CEmitter.entry_kinds_supported().contains(&EntryKindTag::CliSubcommand));
assert!(CEmitter.entry_kinds_supported().contains(&EntryKindTag::LibraryApi));
assert!(
CEmitter
.entry_kinds_supported()
.contains(&EntryKindTag::Function)
);
assert!(
CEmitter
.entry_kinds_supported()
.contains(&EntryKindTag::CliSubcommand)
);
assert!(
CEmitter
.entry_kinds_supported()
.contains(&EntryKindTag::LibraryApi)
);
}
#[test]
@ -806,14 +824,20 @@ mod tests {
!h.source.contains("char *new_argv[8]"),
"fixed-size stack array must be gone — Argv(n>=6) used to overrun",
);
assert!(h.source.contains("char **new_argv = (char**)calloc(3, sizeof(char*))"));
assert!(
h.source
.contains("char **new_argv = (char**)calloc(3, sizeof(char*))")
);
assert!(h.source.contains("free(new_argv);"));
let mut spec6 = make_spec(PayloadSlot::Argv(6));
spec6.entry_kind = EntryKind::CliSubcommand;
spec6.entry_name = "nyx_entry_main".into();
let h6 = emit(&spec6).unwrap();
assert!(h6.source.contains("char **new_argv = (char**)calloc(9, sizeof(char*))"));
assert!(
h6.source
.contains("char **new_argv = (char**)calloc(9, sizeof(char*))")
);
assert!(h6.source.contains("free(new_argv);"));
}
@ -880,7 +904,10 @@ mod tests {
// The install must come after `nyx_payload()` returns and before the
// entry invocation — otherwise a crash inside payload decode would
// be misattributed to the sink (would defeat Phase 08(b)).
let install_pos = h.source.find("__nyx_install_crash_guard(\"run\");").unwrap();
let install_pos = h
.source
.find("__nyx_install_crash_guard(\"run\");")
.unwrap();
let payload_pos = h.source.find("char *payload = nyx_payload();").unwrap();
let invoke_pos = h.source.find("run(payload, strlen(payload));").unwrap();
assert!(
@ -927,7 +954,8 @@ mod tests {
spec.entry_name = "main".into();
let h = emit(&spec).unwrap();
assert!(
h.source.contains("__nyx_install_crash_guard(\"__nyx_entry_main\");"),
h.source
.contains("__nyx_install_crash_guard(\"__nyx_entry_main\");"),
"install_crash_guard must use the post-rename symbol when entry_name == 'main'",
);
}
@ -938,14 +966,21 @@ mod tests {
spec.entry_kind = EntryKind::LibraryApi;
spec.entry_name = "LLVMFuzzerTestOneInput".into();
let h = emit(&spec).unwrap();
assert!(h.source.contains("LLVMFuzzerTestOneInput((const uint8_t *)payload, strlen(payload))"));
assert!(
h.source
.contains("LLVMFuzzerTestOneInput((const uint8_t *)payload, strlen(payload))")
);
}
#[test]
fn emit_makefile_in_extra_files() {
let spec = make_spec(PayloadSlot::Param(0));
let h = emit(&spec).unwrap();
let mk = h.extra_files.iter().find(|(n, _)| n == "Makefile").expect("Makefile must be staged");
let mk = h
.extra_files
.iter()
.find(|(n, _)| n == "Makefile")
.expect("Makefile must be staged");
assert!(mk.1.contains("nyx_harness: main.c entry.c"));
}
@ -965,7 +1000,8 @@ mod tests {
"probe_shim banner missing from chain step source",
);
assert!(
step.source.contains("static void __nyx_install_crash_guard("),
step.source
.contains("static void __nyx_install_crash_guard("),
"install_crash_guard missing from chain step source",
);
let shim_pos = step