def test_add_line(self): sdbgen = SDBGen(':memory:') sdbgen.add_line(0x051FECB4, LineTypes.CODE, 'li r25,0', '\x3B\x20\x00\x00') sdbgen.add_line(0x051FECB8, LineTypes.CODE, 'addi r24, r1, 0x40+var_28', '\x3B\x01\x00\x18') sdbgen.close()
def test_add_function(self): sdbgen = SDBGen(':memory:') sdbgen.add_line(0x051FECB4, LineTypes.CODE,'li r25,0','\x3B\x20\x00\x00') sdbgen.add_line(0x051FECB8, LineTypes.CODE, 'addi r24, r1, 0x40+var_28','\x3B\x01\x00\x18') sdbgen.add_function(0x051fecb4,'my_func',[0x051fecb4,0x051fecb8]) sdbgen.fill_lines_fts() sdbgen.close()
def test_add_xref(self): sdbgen = SDBGen(':memory:') sdbgen.add_line(0x051FECB4, LineTypes.CODE,'li r25,0','\x3B\x20\x00\x00') sdbgen.add_line(0x051FECB8, LineTypes.CODE, 'addi r24, r1, 0x40+var_28','\x3B\x01\x00\x18') sdbgen.add_xref(XrefTypes.CODE_FLOW,0x051fecb4,0x051fecb8) sdbgen.fill_lines_fts() sdbgen.close()
def test_fill_lines_fts(self): sdbgen = SDBGen(':memory:') sdbgen.begin_transaction() sdbgen.add_line(0x051FECB4, LineTypes.CODE, 'li r25,0', '\x3B\x20\x00\x00') sdbgen.add_line(0x051FECB8, LineTypes.CODE, 'addi r24, r1, 0x40+var_28', '\x3B\x01\x00\x18') sdbgen.commit_transaction() sdbgen.fill_lines_fts() sdbgen.close()
def fill_sdb(sdb_path): """ Fill the database with some example rows. """ sdbgen = SDBGen(sdb_path) sdbgen.add_line(0x051FECB4, LineTypes.CODE, 'li r25,0', '\x3B\x20\x00\x00') sdbgen.add_line(0x051FECB8, LineTypes.CODE, 'addi r24, r1, 0x40+var_28', '\x3B\x01\x00\x18') sdbgen.add_line(0x051FECBC, LineTypes.CODE, 'bctrl', '\x4e\x80\x04\x21') sdbgen.add_line(0x051FECC0, LineTypes.CODE, 'li r4,-1', '\x38\x80\xff\xff') sdbgen.add_line(0x051FECC4, LineTypes.CODE, 'li r5,-1', '\x38\xA0\xff\xff') sdbgen.add_line(0xFF000000, LineTypes.CODE, 'empty', '') sdbgen.add_xref(XrefTypes.CODE_FLOW, 0x051fecb4, 0x051fecb8) sdbgen.add_function(0x051fecb4, 'my_func', [0x051fecb4, 0x051fecb8]) sdbgen.fill_lines_fts() sdbgen.close()
def setUp(self): # Create a temporary directory: self.my_dir = tempfile.mkdtemp() my_sdb_path = os.path.join(self.my_dir, 'mydb.sdb') # Fill in sdb: sdbgen = SDBGen(my_sdb_path) sdbgen.add_line(0x051FECB4, LineTypes.CODE, 'Hello there', '\x3B\x20\x00\x00') sdbgen.add_line(0x051FECB8, LineTypes.CODE, 'I am a line', '\x3B\x20\x00\x00') sdbgen.add_line(0x051FECBC, LineTypes.CODE, 'I am another line', '\x3B\x20\x00\x00') sdbgen.add_line(0x051FECC0, LineTypes.CODE, 'I am the next line', '\x3B\x20\x00\x00') sdbgen.fill_lines_fts() sdbgen.close() self.sdb = SearchDB(my_sdb_path)
def test_add_line_none_data(self): sdbgen = SDBGen(':memory:') sdbgen.add_line(0x051FECB4, LineTypes.CODE, 'db ?', '') sdbgen.close()
def test_basic_init(self): sdbgen = SDBGen(':memory:') sdbgen.close()