1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

python: Fix check for disasm creation failure

Check should be for pointer being NULL, not what it points to.

Also adds a test for this case.

Reviewed By: indygreg

Differential Revision: http://llvm-reviews.chandlerc.com/D1878

llvm-svn: 194965
This commit is contained in:
Anders Waldenborg 2013-11-17 15:40:57 +00:00
parent 9ee62020d6
commit 5adf625df0
2 changed files with 5 additions and 1 deletions

View File

@ -75,7 +75,7 @@ class Disassembler(LLVMObject):
ptr = lib.LLVMCreateDisasm(c_char_p(triple), c_void_p(None), c_int(0),
callbacks['op_info'](0), callbacks['symbol_lookup'](0))
if not ptr.contents:
if not ptr:
raise Exception('Could not obtain disassembler for triple: %s' %
triple)

View File

@ -16,6 +16,10 @@ class TestDisassembler(TestBase):
self.assertEqual(count, 3)
self.assertEqual(s, '\tjcxz\t-127')
def test_nonexistant_triple(self):
with self.assertRaisesRegexp(Exception, "Could not obtain disassembler for triple"):
Disassembler("nonexistant-triple-raises")
def test_get_instructions(self):
sequence = '\x67\xe3\x81\x01\xc7' # jcxz -127; addl %eax, %edi