A shell that runs x86_64 assembly
c
x86-64
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tests_breakpoints.c 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #include "config.h"
  2. #include <check.h>
  3. #include <errno.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <unistd.h>
  7. #include "asmsh_check.h"
  8. #include "breakpoints.h"
  9. START_TEST(brk_add)
  10. {
  11. asmsh_brk_t brks;
  12. asmsh_brk_init(&brks);
  13. ck_assert_int_eq(brks.sz, 0);
  14. ck_assert_int_eq(asmsh_brk_add(&brks, 0x42), 0);
  15. ck_assert_int_eq(brks.sz, 1);
  16. ck_assert_int_eq(brks.addrs[0], 0x42);
  17. ck_assert_int_eq(asmsh_brk_add(&brks, 0x42), 1);
  18. ck_assert_int_eq(asmsh_brk_add(&brks, 0x1312), 0);
  19. ck_assert_int_eq(brks.sz, 2);
  20. ck_assert_int_eq(brks.addrs[0], 0x42);
  21. ck_assert_int_eq(brks.addrs[1], 0x1312);
  22. }
  23. END_TEST
  24. START_TEST(brk_add_order)
  25. {
  26. asmsh_brk_t brks;
  27. asmsh_brk_init(&brks);
  28. for(int s=0;s<2;s++)
  29. {
  30. for(int i=s;i<10; i+=2)
  31. {
  32. ck_assert_int_eq(asmsh_brk_add(&brks, i), 0);
  33. }
  34. }
  35. for(int i=0;i<10;i++)
  36. {
  37. ck_assert_int_eq(brks.addrs[i], i);
  38. }
  39. }
  40. START_TEST(brk_isset)
  41. {
  42. asmsh_brk_t brks;
  43. asmsh_brk_init(&brks);
  44. ck_assert_int_eq(brks.sz, 0);
  45. ck_assert_int_eq(asmsh_brk_isset(&brks, 0x42), 0);
  46. ck_assert_int_eq(asmsh_brk_isset(&brks, 0x1312), 0);
  47. ck_assert_int_eq(asmsh_brk_add(&brks, 0x42), 0);
  48. ck_assert_int_ne(asmsh_brk_isset(&brks, 0x42), 0);
  49. ck_assert_int_eq(asmsh_brk_add(&brks, 0x1312), 0);
  50. dprintf(2,"test isset\n");
  51. ck_assert_int_ne(asmsh_brk_isset(&brks, 0x1312), 0);
  52. dprintf(2,"test isset2\n");
  53. ck_assert_int_ne(asmsh_brk_isset(&brks, 0x42), 0);
  54. }
  55. END_TEST
  56. START_TEST(brk_del)
  57. {
  58. asmsh_brk_t brks;
  59. asmsh_brk_init(&brks);
  60. ck_assert_int_eq(brks.sz, 0);
  61. ck_assert_int_eq(asmsh_brk_add(&brks, 0x42), 0);
  62. ck_assert_int_eq(asmsh_brk_add(&brks, 0x1312), 0);
  63. ck_assert_int_ne(asmsh_brk_isset(&brks, 0x42), 0);
  64. ck_assert_int_ne(asmsh_brk_isset(&brks, 0x1312), 0);
  65. ck_assert_int_eq(asmsh_brk_del(&brks, 0x42), 0);
  66. ck_assert_int_eq(asmsh_brk_isset(&brks, 0x42), 0);
  67. ck_assert_int_ne(asmsh_brk_isset(&brks, 0x1312), 0);
  68. ck_assert_int_eq(asmsh_brk_del(&brks, 0x42), 1);
  69. ck_assert_int_eq(asmsh_brk_isset(&brks, 0x42), 0);
  70. ck_assert_int_ne(asmsh_brk_isset(&brks, 0x1312), 0);
  71. ck_assert_int_eq(asmsh_brk_del(&brks, 0x1312), 0);
  72. ck_assert_int_eq(asmsh_brk_isset(&brks, 0x42), 0);
  73. ck_assert_int_eq(asmsh_brk_isset(&brks, 0x1312), 0);
  74. }
  75. END_TEST
  76. /*
  77. START_TEST(brk_)
  78. {
  79. asmsh_brk_t brks;
  80. asmsh_brk_init(&brks);
  81. }
  82. END_TEST
  83. */
  84. ASMSH_CHECK_START("Testing breakpoints lib", "Testing breakpoints manipulation")
  85. ASMSH_ADD_TEST(brk_add);
  86. ASMSH_ADD_TEST(brk_add_order);
  87. ASMSH_ADD_TEST(brk_isset);
  88. ASMSH_ADD_TEST(brk_del);
  89. ASMSH_CHECK_END