-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathtest_types_task.py
More file actions
40 lines (32 loc) · 1.34 KB
/
test_types_task.py
File metadata and controls
40 lines (32 loc) · 1.34 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
# -*- coding: utf-8 -*-
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
import unittest
import gdb
import crash.types.task as tasks
class TestTasks(unittest.TestCase):
def setUp(self):
self.task_struct_type = gdb.lookup_type('struct task_struct')
def test_thread_group_leader_iteration(self):
count = 0
for leader in tasks.for_each_thread_group_leader():
self.assertTrue(type(leader) is gdb.Value)
self.assertTrue(leader.type == self.task_struct_type)
self.assertTrue(int(leader['exit_signal']) >= 0)
count += 1
self.assertTrue(count > 0)
def test_thread_group_iteration(self):
count = 0
for leader in tasks.for_each_thread_group_leader():
for thread in tasks.for_each_thread_in_group(leader):
self.assertTrue(type(thread) is gdb.Value)
self.assertTrue(thread.type == self.task_struct_type)
self.assertTrue(int(thread['exit_signal']) < 0)
count += 1
self.assertTrue(count > 0)
def test_iterate_all_tasks(self):
count = 0
for task in tasks.for_each_all_tasks():
self.assertTrue(type(task) is gdb.Value)
self.assertTrue(task.type == self.task_struct_type)
count += 1
self.assertTrue(count > 0)