mirror of
https://github.com/RRZE-HPC/OSACA.git
synced 2025-12-16 00:50:06 +01:00
more tests
This commit is contained in:
@@ -29,13 +29,15 @@ def add_entry_to_db(arch: str, entry):
|
||||
if 'name' not in entry:
|
||||
raise ValueError('No name for instruction specified. No import possible')
|
||||
if 'operands' not in entry:
|
||||
entry['operands'] = None
|
||||
entry['operands'] = []
|
||||
if 'throughput' not in entry:
|
||||
entry['throughput'] = None
|
||||
if 'latency' not in entry:
|
||||
entry['latency'] = None
|
||||
if 'port_pressure' not in entry:
|
||||
entry['port_pressure'] = None
|
||||
if 'uops' not in entry:
|
||||
entry['uops'] = None
|
||||
data['instruction_forms'].append(entry)
|
||||
__dump_data_to_yaml(filepath, data)
|
||||
|
||||
@@ -67,13 +69,15 @@ def add_entries_to_db(arch: str, entries: list) -> None:
|
||||
entries.remove(entry)
|
||||
continue
|
||||
if 'operands' not in entry:
|
||||
entry['operands'] = None
|
||||
entry['operands'] = []
|
||||
if 'throughput' not in entry:
|
||||
entry['throughput'] = None
|
||||
if 'latency' not in entry:
|
||||
entry['latency'] = None
|
||||
if 'port_pressure' not in entry:
|
||||
entry['port_pressure'] = None
|
||||
if 'uops' not in entry:
|
||||
entry['uops'] = None
|
||||
data['instruction_forms'].append(entry)
|
||||
__dump_data_to_yaml(filepath, data)
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class TestDBInterface(unittest.TestCase):
|
||||
|
||||
self.entry_csx['port_pressure'] = [1.25, 0, 1.25, 0.5, 0.5, 0.5, 0.5, 0, 1.25, 1.25, 0]
|
||||
self.entry_vulcan['port_pressure'] = [2.5, 2.5, 0, 0, 0.5, 0.5]
|
||||
del(self.entry_vulcan['operands'][1]['name'])
|
||||
del self.entry_vulcan['operands'][1]['name']
|
||||
self.entry_vulcan['operands'][1]['prefix'] = 'x'
|
||||
self.entry_zen1['port_pressure'] = [1, 1, 1, 1, 0, 1, 0, 0, 0, 0.5, 1, 0.5, 1]
|
||||
|
||||
@@ -39,12 +39,13 @@ class TestDBInterface(unittest.TestCase):
|
||||
def tearDownClass(self):
|
||||
if sys.exc_info() == (None, None, None):
|
||||
# Test successful, remove DB entries
|
||||
for arch in ['csx', 'vulcan', 'zen1']:
|
||||
test_archs = {'csx': 22, 'vulcan': 24, 'zen1': 22}
|
||||
for arch in test_archs:
|
||||
lines = []
|
||||
with open(os.path.expanduser('~/.osaca/data/' + arch + '.yml'), 'r') as f:
|
||||
lines = f.readlines()
|
||||
with open(os.path.expanduser('~/.osaca/data/' + arch + '.yml'), 'w') as f:
|
||||
f.writelines([line for line in lines[:-24]])
|
||||
f.writelines([line for line in lines[:-1 * test_archs[arch]]])
|
||||
|
||||
###########
|
||||
# Tests
|
||||
@@ -57,7 +58,7 @@ class TestDBInterface(unittest.TestCase):
|
||||
|
||||
add_entry_to_db('csx', self.entry_csx)
|
||||
add_entry_to_db('vulcan', self.entry_vulcan)
|
||||
add_entry_to_db('zen1', self.entry_zen1)
|
||||
add_entry_to_db('zen1', {'name': 'empty_operation'})
|
||||
|
||||
num_entries_csx = len(MachineModel('csx')['instruction_forms']) - num_entries_csx
|
||||
num_entries_vulcan = len(MachineModel('vulcan')['instruction_forms']) - num_entries_vulcan
|
||||
@@ -67,6 +68,12 @@ class TestDBInterface(unittest.TestCase):
|
||||
self.assertEqual(num_entries_vulcan, 1)
|
||||
self.assertEqual(num_entries_zen1, 1)
|
||||
|
||||
def test_invalid_add(self):
|
||||
entry = {}
|
||||
with self.assertRaises(ValueError):
|
||||
add_entry_to_db('csx', entry)
|
||||
add_entries_to_db('csx', [entry])
|
||||
|
||||
def test_add_multiple_entries(self):
|
||||
num_entries_csx = len(MachineModel('csx')['instruction_forms'])
|
||||
num_entries_vulcan = len(MachineModel('vulcan')['instruction_forms'])
|
||||
@@ -81,6 +88,8 @@ class TestDBInterface(unittest.TestCase):
|
||||
entries_vulcan.append(copy.deepcopy(self.entry_vulcan))
|
||||
entries_zen1.append(copy.deepcopy(self.entry_zen1))
|
||||
|
||||
entries_csx[1] = {'name': entries_csx[1]['name']}
|
||||
|
||||
add_entries_to_db('csx', entries_csx)
|
||||
add_entries_to_db('vulcan', entries_vulcan)
|
||||
add_entries_to_db('zen1', entries_zen1)
|
||||
|
||||
@@ -60,6 +60,8 @@ class TestFrontend(unittest.TestCase):
|
||||
Frontend()
|
||||
with self.assertRaises(ValueError):
|
||||
Frontend(arch='csx', path_to_yaml=os.path.join(self.MODULE_DATA_DIR, 'csx.yml'))
|
||||
with self.assertRaises(ValueError):
|
||||
Frontend(path_to_yaml=os.path.join(self.MODULE_DATA_DIR, 'THE_MACHINE.yml'))
|
||||
with self.assertRaises(ValueError):
|
||||
Frontend(arch='THE_MACHINE')
|
||||
Frontend(arch='zen1')
|
||||
|
||||
Reference in New Issue
Block a user