1#[allow(
23 unused_imports,
24 clippy::wildcard_imports,
25 reason = "Standard workspace module prelude"
26)]
27use crate::utilities::*;
28
29use anyhow::Context;
30use std::path::Path;
31
32pub fn instruction_sets(path: &Path) -> Result<ToolResult> {
33 let data = std::fs::read(path)
34 .with_context(|| format!("Failed to read file: {}", path.display()))?;
35 let sets = crate::extract_instruction_sets(&data)?;
36 let mut output = sets.join("\n");
37 if !output.is_empty() {
38 output.push('\n');
39 }
40 Ok(ToolResult::immediate_ok(output.into_bytes()))
41}
42
43#[cfg(test)]
44#[allow(
45 clippy::panic,
46 clippy::expect_used,
47 clippy::unwrap_used,
48 clippy::unwrap_in_result,
49 clippy::panic_in_result_fn,
50 clippy::indexing_slicing,
51 clippy::arithmetic_side_effects,
52 reason = "Standard repository test boilerplate"
53)]
54mod tests {
55 use super::*;
56
57 #[crate::ctb_test]
58 fn test_x86_instruction_sets_command() {
59 let temp_dir = tempfile::tempdir().unwrap();
60 let sample_file = temp_dir.path().join("dummy.bin");
61 std::fs::write(&sample_file, b"not a binary").unwrap();
62
63 assert!(super::instruction_sets(&sample_file).is_err());
64 }
65}