-
Notifications
You must be signed in to change notification settings - Fork 32
/
test_utils.py
37 lines (26 loc) · 1.02 KB
/
test_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Tests haystack.utils ."""
import unittest
import numpy
from haystack.reverse import utils
from haystack.reverse import context
from haystack import dump_loader
class TestBasicFunctions(unittest.TestCase):
def setUp(self):
pass
def test_closestFloorValue(self):
lst = numpy.asarray(range(0, 100, 10))
self.assertEquals(utils.closestFloorValue(41, lst), (40, 4))
self.assertEquals(utils.closestFloorValue(40, lst), (40, 4))
with self.assertRaises(ValueError):
utils.closestFloorValue(-1, lst)
memory_handler = dump_loader.load('test/src/test-ctypes3.32.dump')
finder = memory_handler.get_heap_finder()
heap = finder.get_heap_mappings()[0]
heap_addr = heap.get_marked_heap_address()
ctx = context.get_context_for_address(memory_handler, heap_addr)
lst = ctx._structures_addresses
# print ['0x%0.8x'%i for i in lst]
if __name__ == '__main__':
unittest.main(verbosity=0)