123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- #include "config.h"
-
- #include <check.h>
- #include <errno.h>
- #include <stdio.h>
- #include <string.h>
- #include <unistd.h>
-
- #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
|