Skip to content

Commit

Permalink
#1121: Fix unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanSalwan committed Apr 19, 2022
1 parent 37e2756 commit a245cd0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/libtriton/arch/irBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ namespace triton {
if (this->buildSemantics(inst) == false) {
return false;
}
if (inst.isControlFlow() && --count) {
count--;
if (inst.isControlFlow() && count) {
throw triton::exceptions::IrBuilder("IrBuilder::buildSemantics(): Do not add instructions in a block after a branch instruction.");
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/libtriton/bindings/python/objects/pyBasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
#include <iostream>


/* setup doctest context
>>> from __future__ import print_function
>>> from triton import *
>>> ctx = TritonContext(ARCH.X86_64)
*/

/*! \page py_BasicBlock_page BasicBlock
\brief [**python api**] All information about the BasicBlock Python object.
Expand Down
24 changes: 12 additions & 12 deletions src/testers/unittests/test_disass.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,12 @@ def test_inst3(self):
]
raw = b"".join(code)
self.ctx.setConcreteMemoryAreaValue(0x1000, raw)
insts = self.ctx.disassembly(0x1000)
self.assertEqual(str(insts), '[0x1000: movabs rcx, 0x1122334455667788, '
'0x100a: inc rcx, '
'0x100d: mov rax, rcx, '
'0x1010: leave, '
'0x1011: ret]')
block = self.ctx.disassembly(0x1000)
self.assertEqual(str(block.getInstructions()), '[0x1000: movabs rcx, 0x1122334455667788, '
'0x100a: inc rcx, '
'0x100d: mov rax, rcx, '
'0x1010: leave, '
'0x1011: ret]')

def test_inst4(self):
code = [
Expand All @@ -315,12 +315,12 @@ def test_inst4(self):
]
raw = b"".join(code)
self.ctx.setConcreteMemoryAreaValue(0x1000, raw)
insts = self.ctx.disassembly(0x1000)
self.assertEqual(str(insts), '[0x1000: movabs rcx, 0x1122334455667788, '
'0x100a: inc rcx, '
'0x100d: mov rax, rcx, '
'0x1010: leave, '
'0x1011: jmp rax]')
block = self.ctx.disassembly(0x1000)
self.assertEqual(str(block.getInstructions()), '[0x1000: movabs rcx, 0x1122334455667788, '
'0x100a: inc rcx, '
'0x100d: mov rax, rcx, '
'0x1010: leave, '
'0x1011: jmp rax]')

def test_inst5(self):
code = [
Expand Down

0 comments on commit a245cd0

Please sign in to comment.