-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathtest_objfile_callbacks.py
More file actions
45 lines (35 loc) · 1.23 KB
/
test_objfile_callbacks.py
File metadata and controls
45 lines (35 loc) · 1.23 KB
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
38
39
40
41
42
43
44
45
# -*- coding: utf-8 -*-
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
import unittest
import gdb
from crash.util import safe_get_symbol_value
from crash.infra.callback import ObjfileEventCallback
class TestCallback(unittest.TestCase):
def setUp(self):
gdb.execute("file")
def tearDown(self):
gdb.execute("file")
def load_file(self):
gdb.execute("file tests/test-util")
def test_registering(self):
class test_class(ObjfileEventCallback):
def __init__(self):
self.called = False
self.checked = False
super(test_class, self).__init__()
self.connect_callback()
def check_ready(self):
self.checked = True
return safe_get_symbol_value('main')
def callback(self, result):
self.called = True
self.result = result
x = test_class()
self.assertFalse(x.called)
self.assertFalse(x.completed)
self.assertFalse(x.checked)
self.load_file()
self.assertTrue(x.checked)
self.assertTrue(x.called)
self.assertTrue(x.completed)
self.assertTrue(isinstance(x.result, gdb.Value))