-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sarah Mount
committed
Aug 12, 2016
1 parent
fd480fb
commit 1b7bb0e
Showing
7 changed files
with
94 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from diff_trace import parse_pydgin_inst, parse_esim_inst, compare_instructions | ||
|
||
|
||
def test_parse_pydgin_inst(): | ||
got0 = parse_pydgin_inst(' 0 00002ce8 bcond32 0 AN=False') | ||
expected0 = { 'AN':False, 'pc':0, | ||
'line':' 0 00002ce8 bcond32 0 AN=False' } | ||
assert expected0 == got0 | ||
|
||
got1 = parse_pydgin_inst(' b0 020040fc ldstrpmd32 13 ::' | ||
' RD.RF[0 ] = 000002f8 :: :: WR.MEM[000002f8] = ' | ||
'00000000 :: WR.RF[0 ] = 00000300') | ||
expected1 = { 'mem':[(760, 0)], 'pc':176, 'reg':[768], | ||
'line':(' b0 020040fc ldstrpmd32 13 :: ' | ||
'RD.RF[0 ] = 000002f8 :: :: WR.MEM[000002f8] = ' | ||
'00000000 :: WR.RF[0 ] = 00000300') } | ||
assert expected1 == got1 | ||
|
||
|
||
def test_parse_esim_inst(): | ||
out0 = parse_esim_inst('0x000000 b.l ' | ||
'0x0000000000000058 - pc <- 0x58 - nbit <- 0x0') | ||
expected0 = { 'pc':0, 'AN':False, | ||
'line':('0x000000 b.l ' | ||
'0x0000000000000058 - pc <- 0x58 - nbit <- 0x0') } | ||
assert expected0 == out0 | ||
out1 = parse_esim_inst('0x0000b0 --- _epiphany_star strd r2,[r0],+0x1 -' | ||
' memaddr <- 0x2f8, memory <- 0x0, memaddr <- 0x2fc,' | ||
' memory <- 0x0, registers <- 0x300') | ||
expected1 = { 'mem':[(760, 0), (764, 0)], 'pc':176, 'reg':[768], | ||
'line':'0x0000b0 --- _epiphany_star strd r2,[r0],+0x1 -' | ||
' memaddr <- 0x2f8, memory <- 0x0, memaddr <- 0x2fc,' | ||
' memory <- 0x0, registers <- 0x300' } | ||
assert expected1 == out1 | ||
|
||
|
||
def test_compare_instructions(): | ||
e_inst0 = { 'pc':0, 'AN':False, | ||
'line': '0x000000 b.l 0x0000000000000058' | ||
' - pc <- 0x58 - nbit <- 0x0' } | ||
e_inst1 = { 'mem':[(760, 0), (764, 0)], 'pc':176, 'reg': [768], | ||
'line': '0x0000b0 --- _epiphany_star strd r2,[r0],+0x1 -' | ||
' memaddr <- 0x2f8, memory <- 0x0, memaddr <- 0x2fc, ' | ||
'memory <- 0x0, registers <- 0x300' } | ||
py_inst0 = { 'pc': 0, 'AN': False, | ||
'line': ' 0 00002ce8 bcond32 0 AN=False' } | ||
py_inst1 = { 'mem': [(760, 0), (764, 0)], 'pc': 176, 'reg': [768], | ||
'line': ' b0 020040fc ldstrpmd32 13 :: RD.RF[0 ]' | ||
' = 000002f8 :: :: WR.MEM[000002f8] = 00000000 :: WR.RF[0 ] =' | ||
' 00000300' } | ||
assert compare_instructions(py_inst0, e_inst0) is None | ||
assert compare_instructions(py_inst0, e_inst1) | ||
expected0 = 'Program counters differ. Revelation: 0x0, e-sim: 0xb0' | ||
expected1 = 'Program counters differ. Revelation: 0xb0, e-sim: 0x0' | ||
assert expected0 == compare_instructions(py_inst0, e_inst1) | ||
assert expected1 == compare_instructions(py_inst1, e_inst0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from get_instructions_used import parse_esim_inst | ||
|
||
def test_parse_esim_inst(): | ||
got0 = parse_esim_inst('0x000000 b.l ' | ||
'0x0000000000000058 - pc <- 0x58 - nbit <- 0x0') | ||
expected0 = { 'pc':0, 'AN':False, 'instruction':'b.l', | ||
'line': '0x000000 b.l ' | ||
'0x0000000000000058 - pc <- 0x58 - nbit <- 0x0' } | ||
assert expected0 == got0 | ||
got1 = parse_esim_inst('0x0000b0 --- _epiphany_star strd r2,[r0],+0x1' | ||
' - memaddr <- 0x2f8, memory <- 0x0, memaddr <- ' | ||
'0x2fc, memory <- 0x0, registers <- 0x300') | ||
expected1 = { 'instruction':'strd', 'mem':[(760, 0), (764, 0)], 'pc':176, | ||
'reg':[768], | ||
'line':'0x0000b0 --- _epiphany_star strd r2,[r0],+0x1 - ' | ||
'memaddr <- 0x2f8, memory <- 0x0, memaddr <- 0x2fc, memory ' | ||
'<- 0x0, registers <- 0x300' } | ||
assert expected1 == got1 |