-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtest_bitmap.py
36 lines (27 loc) · 1007 Bytes
/
test_bitmap.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
from z3 import *
from bitmap import *
import disk
from yggdrasil.util import *
from yggdrasil.diskspec import *
from yggdrasil import test
class TestBitmapDisk(test.RefinementTest):
def create_impl(self, mach):
array = FreshDiskArray('impl',
domain=BitVecSort(SizeSort.size() - LogBlockSize))
return BitmapDisk(AsyncDisk(mach, array))
def create_spec(self, mach):
array = FreshDiskArray('spec')
return BitmapSpec(AsyncDisk(mach, array))
def equivalence(self, spec, impl, *args, **kwargs):
i = BitVec(fresh_name('i'), SizeSort.size())
return ForAll([i], spec.is_set(i) == impl.is_set(i))
@test.z3_option(AUTO_CONFIG=True)
def match_set_bit(self):
bid = BitVec(fresh_name('bid'), SizeSort.size())
yield (bid,)
@test.z3_option(AUTO_CONFIG=True)
def match_unset_bit(self):
bid = BitVec(fresh_name('bid'), SizeSort.size())
yield (bid,)
if __name__ == '__main__':
test.main()