From 3ef485a256bce837800f03d490f253ac18d98a32 Mon Sep 17 00:00:00 2001 From: Aryaman Sharma <72215253+TheLazron@users.noreply.github.com> Date: Fri, 19 Apr 2024 05:02:43 +0530 Subject: [PATCH] Added tests for --asm search (#2114) * added tests for asm search command * formatting changes --- tests/gdb-tests/tests/test_command_search.py | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/gdb-tests/tests/test_command_search.py b/tests/gdb-tests/tests/test_command_search.py index 74d612319..6427a87b5 100644 --- a/tests/gdb-tests/tests/test_command_search.py +++ b/tests/gdb-tests/tests/test_command_search.py @@ -182,3 +182,37 @@ def test_command_search_rwx(start_binary): result_count += 1 assert result_count == 0 + + +def test_command_search_asm(start_binary): + """ + Tests searching for asm instructions + """ + start_binary(SEARCH_BINARY) + + gdb.execute("break break_here") + gdb.execute("run") + + result_str = gdb.execute('search --asm "add rax, rdx" search_memory', to_string=True) + result_count = 0 + for line in result_str.split("\n"): + if line.startswith("search_memory"): + result_count += 1 + assert result_count == 2 + + +def test_command_set_breakpoint_search_asm(start_binary): + """ + Tests setting breakpoints on found asm instructions + """ + start_binary(SEARCH_BINARY) + + gdb.execute("break break_here") + gdb.execute("run") + + result_str = gdb.execute('search --asmbp "add rax, rdx" search_memory', to_string=True) + result_count = 0 + for line in result_str.split("\n"): + if line.startswith("Breakpoint"): + result_count += 1 + assert result_count == 2