llvm.org GIT mirror llvm / e8a957d
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194965 91177308-0d34-0410-b5e6-96231b3b80d8 Anders Waldenborg 7 years ago
2 changed file(s) with 5 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
7474
7575 ptr = lib.LLVMCreateDisasm(c_char_p(triple), c_void_p(None), c_int(0),
7676 callbacks['op_info'](0), callbacks['symbol_lookup'](0))
77 if not ptr.contents:
77 if not ptr:
7878 raise Exception('Could not obtain disassembler for triple: %s' %
7979 triple)
8080
1414 count, s = disassembler.get_instruction(sequence)
1515 self.assertEqual(count, 3)
1616 self.assertEqual(s, '\tjcxz\t-127')
17
18 def test_nonexistant_triple(self):
19 with self.assertRaisesRegexp(Exception, "Could not obtain disassembler for triple"):
20 Disassembler("nonexistant-triple-raises")
1721
1822 def test_get_instructions(self):
1923 sequence = '\x67\xe3\x81\x01\xc7' # jcxz -127; addl %eax, %edi