Files
ghidra-cli/tests/diff_tests.rs
T
Alexander KiselevandClaude Opus 4.6 ae2d882f26 fix: add --project/--program to BatchArgs and fix arg order in tests
BatchArgs was missing --project and --program fields, so batch commands
couldn't specify which project to use. Also fixed argument ordering in
all test files to place --project/--program after the subcommand name,
matching clap's per-subcommand argument parsing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 13:19:16 -08:00

62 lines
1.5 KiB
Rust

//! Tests for diff operations.
use assert_cmd::Command;
use predicates::prelude::*;
use serial_test::serial;
#[macro_use]
mod common;
use common::{ensure_test_project, DaemonTestHarness};
const TEST_PROJECT: &str = "diff-test";
const TEST_PROGRAM: &str = "sample_binary";
#[test]
#[serial]
fn test_diff_programs() {
require_ghidra!();
ensure_test_project(TEST_PROJECT, TEST_PROGRAM);
let harness =
DaemonTestHarness::new(TEST_PROJECT, TEST_PROGRAM).expect("Failed to start daemon");
// diff programs compares two programs by name (no --program flag needed)
Command::cargo_bin("ghidra")
.unwrap()
.arg("diff")
.arg("programs")
.arg(TEST_PROGRAM)
.arg(TEST_PROGRAM)
.arg("--project")
.arg(TEST_PROJECT)
.assert()
.success();
drop(harness);
}
#[test]
#[serial]
fn test_diff_functions() {
require_ghidra!();
ensure_test_project(TEST_PROJECT, TEST_PROGRAM);
let harness =
DaemonTestHarness::new(TEST_PROJECT, TEST_PROGRAM).expect("Failed to start daemon");
// diff functions requires two function names/addresses
// Using _start (entry point) for both since we just want to verify command works
Command::cargo_bin("ghidra")
.unwrap()
.arg("diff")
.arg("functions")
.arg("_start")
.arg("_start")
.arg("--project")
.arg(TEST_PROJECT)
.assert()
.success();
drop(harness);
}