MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / test_binary_saving_database

Function test_binary_saving_database

rust/tests/binary_view.rs:47–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45
46#[test]
47fn test_binary_saving_database() {
48 let _session = Session::new().expect("Failed to initialize session");
49 let out_dir = env!("OUT_DIR").parse::<PathBuf>().unwrap();
50 let view = binaryninja::load(out_dir.join("atox.obj")).expect("Failed to create view");
51 // Update a symbol to verify modification
52 let entry_function = view
53 .entry_point_function()
54 .expect("Failed to get entry point function");
55 let new_entry_func_symbol =
56 SymbolBuilder::new(SymbolType::Function, "test", entry_function.start()).create();
57 view.define_user_symbol(&new_entry_func_symbol);
58 // Verify that we modified the binary
59 assert_eq!(entry_function.symbol().raw_name().as_str(), "test");
60 // Save the modified database.
61 assert!(view.file().create_database(out_dir.join("atox.obj.bndb")));
62 // Verify that the file exists and is modified.
63 let new_view =
64 binaryninja::load(out_dir.join("atox.obj.bndb")).expect("Failed to load new view");
65 let new_entry_function = new_view
66 .entry_point_function()
67 .expect("Failed to get entry point function");
68 assert_eq!(new_entry_function.symbol().raw_name().as_str(), "test");
69}

Callers

nothing calls this directly

Calls 6

joinMethod · 0.80
entry_point_functionMethod · 0.80
loadFunction · 0.50
createMethod · 0.45
startMethod · 0.45
define_user_symbolMethod · 0.45

Tested by

no test coverage detected