From 1fb5416f4ae63b9a367bd7c201da5dda741de22a Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Sun, 31 Jan 2016 13:06:42 +0800 Subject: [PATCH] unit: simplify test_tb_x86.c --- tests/unit/test_tb_x86.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/tests/unit/test_tb_x86.c b/tests/unit/test_tb_x86.c index 3abbd16e..f28d7617 100644 --- a/tests/unit/test_tb_x86.c +++ b/tests/unit/test_tb_x86.c @@ -206,8 +206,8 @@ static void hook_mem32(uc_engine *uc, //uint32_t tmp[1]; ctype = '?'; - if (type == 16) ctype = 'R'; - if (type == 17) ctype = 'W'; + if (type == UC_MEM_READ) ctype = 'R'; + if (type == UC_MEM_WRITE) ctype = 'W'; printf("hook_mem32(%c): Address: 0x%"PRIx64", Size: %d, Value:0x%"PRIx64"\n", ctype, address, size, value); // if (!uc_mem_read(uc, 0x6000003a, tmp, 4)) @@ -221,7 +221,7 @@ static void hook_mem32(uc_engine *uc, static void test_tb_x86_64_32_imul_Gv_Ev_Ib(void **state) { uc_engine *uc = *state; - uc_hook trace1, trace2, trace3, trace4; + uc_hook trace1, trace2; void *mem; #ifdef RIP_NEXT_TO_THE_SELFMODIFY_OPCODE // These values assumes just before PC = 0x60000021 @@ -278,23 +278,7 @@ static void test_tb_x86_64_32_imul_Gv_Ev_Ib(void **state) uc_assert_success(uc_hook_add(uc, &trace2, - UC_HOOK_MEM_READ, - hook_mem32, - NULL, - (uint64_t)1, - (uint64_t)0)); - - uc_assert_success(uc_hook_add(uc, - &trace3, - UC_HOOK_MEM_WRITE, - hook_mem32, - NULL, - (uint64_t)1, - (uint64_t)0)); - - uc_assert_success(uc_hook_add(uc, - &trace4, - UC_HOOK_MEM_FETCH, + UC_HOOK_MEM_READ | UC_HOOK_MEM_WRITE | UC_HOOK_MEM_FETCH, hook_mem32, NULL, (uint64_t)1,