#include "config.h" #include #include #include #include #include #include "asmsh_check.h" #include "breakpoints.h" START_TEST(brk_add) { asmsh_brk_t brks; asmsh_brk_init(&brks); ck_assert_int_eq(brks.sz, 0); ck_assert_int_eq(asmsh_brk_add(&brks, 0x42), 0); ck_assert_int_eq(brks.sz, 1); ck_assert_int_eq(brks.addrs[0], 0x42); ck_assert_int_eq(asmsh_brk_add(&brks, 0x42), 1); ck_assert_int_eq(asmsh_brk_add(&brks, 0x1312), 0); ck_assert_int_eq(brks.sz, 2); ck_assert_int_eq(brks.addrs[0], 0x42); ck_assert_int_eq(brks.addrs[1], 0x1312); } END_TEST START_TEST(brk_add_order) { asmsh_brk_t brks; asmsh_brk_init(&brks); for(int s=0;s<2;s++) { for(int i=s;i<10; i+=2) { ck_assert_int_eq(asmsh_brk_add(&brks, i), 0); } } for(int i=0;i<10;i++) { ck_assert_int_eq(brks.addrs[i], i); } } START_TEST(brk_isset) { asmsh_brk_t brks; asmsh_brk_init(&brks); ck_assert_int_eq(brks.sz, 0); ck_assert_int_eq(asmsh_brk_isset(&brks, 0x42), 0); ck_assert_int_eq(asmsh_brk_isset(&brks, 0x1312), 0); ck_assert_int_eq(asmsh_brk_add(&brks, 0x42), 0); ck_assert_int_ne(asmsh_brk_isset(&brks, 0x42), 0); ck_assert_int_eq(asmsh_brk_add(&brks, 0x1312), 0); dprintf(2,"test isset\n"); ck_assert_int_ne(asmsh_brk_isset(&brks, 0x1312), 0); dprintf(2,"test isset2\n"); ck_assert_int_ne(asmsh_brk_isset(&brks, 0x42), 0); } END_TEST START_TEST(brk_del) { asmsh_brk_t brks; asmsh_brk_init(&brks); ck_assert_int_eq(brks.sz, 0); ck_assert_int_eq(asmsh_brk_add(&brks, 0x42), 0); ck_assert_int_eq(asmsh_brk_add(&brks, 0x1312), 0); ck_assert_int_ne(asmsh_brk_isset(&brks, 0x42), 0); ck_assert_int_ne(asmsh_brk_isset(&brks, 0x1312), 0); ck_assert_int_eq(asmsh_brk_del(&brks, 0x42), 0); ck_assert_int_eq(asmsh_brk_isset(&brks, 0x42), 0); ck_assert_int_ne(asmsh_brk_isset(&brks, 0x1312), 0); ck_assert_int_eq(asmsh_brk_del(&brks, 0x42), 1); ck_assert_int_eq(asmsh_brk_isset(&brks, 0x42), 0); ck_assert_int_ne(asmsh_brk_isset(&brks, 0x1312), 0); ck_assert_int_eq(asmsh_brk_del(&brks, 0x1312), 0); ck_assert_int_eq(asmsh_brk_isset(&brks, 0x42), 0); ck_assert_int_eq(asmsh_brk_isset(&brks, 0x1312), 0); } END_TEST /* START_TEST(brk_) { asmsh_brk_t brks; asmsh_brk_init(&brks); } END_TEST */ ASMSH_CHECK_START("Testing breakpoints lib", "Testing breakpoints manipulation") ASMSH_ADD_TEST(brk_add); ASMSH_ADD_TEST(brk_add_order); ASMSH_ADD_TEST(brk_isset); ASMSH_ADD_TEST(brk_del); ASMSH_CHECK_END