From 9ec0f7558fad7f6e58007555488a7cc98eb56827 Mon Sep 17 00:00:00 2001 From: mio Date: Fri, 11 Apr 2025 11:58:42 +0800 Subject: [PATCH] Add unit tests for mips --- tests/unit/test_mips.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/unit/test_mips.c b/tests/unit/test_mips.c index 61394abd..eef925da 100644 --- a/tests/unit/test_mips.c +++ b/tests/unit/test_mips.c @@ -200,6 +200,30 @@ static void test_mips_mips_fpr(void) OK(uc_close(uc)); } +static void test_mips_simple_coredump_2134(void) +{ + uc_engine *uc; + // ks.asm("li $t1, 0x42f6e979;mtc1 $t1, $f1") + const char code[] = "\x25\xc8\x80\x03\x25\x78\xe0\x03\x09\xf8\x20\x03\x10\x00\x18\x24"; + uc_common_setup(&uc, UC_ARCH_MIPS, UC_MODE_MIPS32, code, sizeof(code) - 1); + + OK(uc_emu_start(uc, code_start, code_start + sizeof(code) - 1, 0, 0)); + + OK(uc_close(uc)); +} + +static void test_mips_simple_coredump_2137(void) +{ + uc_engine *uc; + // ks.asm("li $t1, 0x42f6e979;mtc1 $t1, $f1") + const char code[] = "\x1c\x00\x40\x54\xe8\x00\xc4\xaf"; + uc_common_setup(&uc, UC_ARCH_MIPS, UC_MODE_MIPS32, code, sizeof(code) - 1); + + OK(uc_emu_start(uc, code_start, code_start + sizeof(code) - 1, 0, 0)); + + OK(uc_close(uc)); +} + TEST_LIST = { {"test_mips_stop_at_branch", test_mips_stop_at_branch}, {"test_mips_stop_at_delay_slot", test_mips_stop_at_delay_slot}, @@ -210,4 +234,6 @@ TEST_LIST = { {"test_mips_mips_fpr", test_mips_mips_fpr}, {"test_mips_stop_delay_slot_from_qiling", test_mips_stop_delay_slot_from_qiling}, + {"test_mips_simple_coredump_2134", test_mips_simple_coredump_2134}, + {"test_mips_simple_coredump_2137", test_mips_simple_coredump_2137}, {NULL, NULL}}; \ No newline at end of file