mirror of
https://github.com/RRZE-HPC/OSACA.git
synced 2026-01-06 19:20:07 +01:00
added tests
This commit is contained in:
@@ -328,9 +328,8 @@ def _scrape_from_felixcloutier(mnemonic):
|
|||||||
return (suspicious, ' '.join(operands))
|
return (suspicious, ' '.join(operands))
|
||||||
|
|
||||||
|
|
||||||
def _get_src_dst_from_table(table):
|
def _get_src_dst_from_table(table, num_operands=2):
|
||||||
"""Prettify bs4 table object to string for user"""
|
"""Prettify bs4 table object to string for user"""
|
||||||
NUM_OPERANDS = 2
|
|
||||||
# Parse table
|
# Parse table
|
||||||
header = [''.join(x.string.lower().split()) for x in table.find('tr').findAll('td')]
|
header = [''.join(x.string.lower().split()) for x in table.find('tr').findAll('td')]
|
||||||
data = table.findAll('tr')[1:]
|
data = table.findAll('tr')[1:]
|
||||||
@@ -342,10 +341,10 @@ def _get_src_dst_from_table(table):
|
|||||||
data_dict[i][header[j]] = col.string
|
data_dict[i][header[j]] = col.string
|
||||||
# Get only the instruction forms with 2 operands
|
# Get only the instruction forms with 2 operands
|
||||||
num_ops = [_get_number_of_operands(row) for _, row in data_dict.items()]
|
num_ops = [_get_number_of_operands(row) for _, row in data_dict.items()]
|
||||||
if NUM_OPERANDS in num_ops:
|
if num_operands in num_ops:
|
||||||
row = data_dict[num_ops.index(NUM_OPERANDS)]
|
row = data_dict[num_ops.index(num_operands)]
|
||||||
reads_writes = []
|
reads_writes = []
|
||||||
for i in range(1, NUM_OPERANDS + 1):
|
for i in range(1, num_operands + 1):
|
||||||
m = re.search(r'(\([^\(\)]+\))', row['operand{}'.format(i)])
|
m = re.search(r'(\([^\(\)]+\))', row['operand{}'.format(i)])
|
||||||
if not m:
|
if not m:
|
||||||
# no parentheses (probably immediate operand), assume READ
|
# no parentheses (probably immediate operand), assume READ
|
||||||
|
|||||||
@@ -124,6 +124,18 @@ class TestDBInterface(unittest.TestCase):
|
|||||||
with self.assertRaises(AssertionError):
|
with self.assertRaises(AssertionError):
|
||||||
dbi.import_benchmark_output('csx', 'ibench', 'invalid_file')
|
dbi.import_benchmark_output('csx', 'ibench', 'invalid_file')
|
||||||
|
|
||||||
|
def test_online_scraping(self):
|
||||||
|
# addpd -- suspicious instruction, normal URL
|
||||||
|
instr_1 = ['addpd', (True, '(r) (r,w)')]
|
||||||
|
self.assertEqual(dbi._scrape_from_felixcloutier(instr_1[0]), instr_1[1])
|
||||||
|
# movpd -- not suspicious,
|
||||||
|
instr_2 = ['movapd', (False, '(r) (w)')]
|
||||||
|
self.assertEqual(dbi._scrape_from_felixcloutier(instr_2[0]), instr_2[1])
|
||||||
|
# vfmadd132pd -- only in combined view with 213/231.
|
||||||
|
# No 2-operand version, therefore, empty string
|
||||||
|
instr_3 = ['vfmadd132pd', (True, '')]
|
||||||
|
self.assertEqual(dbi._scrape_from_felixcloutier(instr_3[0]), instr_3[1])
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# Helper functions
|
# Helper functions
|
||||||
##################
|
##################
|
||||||
|
|||||||
Reference in New Issue
Block a user