-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathtest_types_bitmap.py
More file actions
76 lines (53 loc) · 2.11 KB
/
test_types_bitmap.py
File metadata and controls
76 lines (53 loc) · 2.11 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- coding: utf-8 -*-
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
import unittest
import gdb
import crash.types.bitmap as bitmaps
class TestBitmap(unittest.TestCase):
def test_for_each_set_bit(self):
sym = gdb.lookup_symbol('cpu_online_mask', None)[0]
if sym is None:
sym = gdb.lookup_symbol('__cpu_online_mask', None)[0]
self.assertTrue(sym is not None)
bitmap = sym.value()['bits']
count = 0
for bit in bitmaps.for_each_set_bit(bitmap):
self.assertTrue(type(bit) is int)
count += 1
self.assertTrue(count > 0)
def test_find_first_set_bit(self):
sym = gdb.lookup_symbol('cpu_online_mask', None)[0]
if sym is None:
sym = gdb.lookup_symbol('__cpu_online_mask', None)[0]
self.assertTrue(sym is not None)
bitmap = sym.value()['bits']
count = 0
bit = bitmaps.find_first_set_bit(bitmap)
self.assertTrue(type(bit) is int)
def test_find_next_set_bit(self):
sym = gdb.lookup_symbol('cpu_online_mask', None)[0]
if sym is None:
sym = gdb.lookup_symbol('__cpu_online_mask', None)[0]
self.assertTrue(sym is not None)
bitmap = sym.value()['bits']
count = 0
bit = bitmaps.find_next_set_bit(bitmap, 1)
self.assertTrue(type(bit) is int)
def test_find_first_zero_bit(self):
sym = gdb.lookup_symbol('cpu_online_mask', None)[0]
if sym is None:
sym = gdb.lookup_symbol('__cpu_online_mask', None)[0]
self.assertTrue(sym is not None)
bitmap = sym.value()['bits']
count = 0
bit = bitmaps.find_first_zero_bit(bitmap)
self.assertTrue(type(bit) is int)
def test_find_next_zero_bit(self):
sym = gdb.lookup_symbol('cpu_online_mask', None)[0]
if sym is None:
sym = gdb.lookup_symbol('__cpu_online_mask', None)[0]
self.assertTrue(sym is not None)
bitmap = sym.value()['bits']
count = 0
bit = bitmaps.find_next_zero_bit(bitmap, 10)
self.assertTrue(type(bit) is int)