diff --git a/tests/test_db_interface.py b/tests/test_db_interface.py index c2ed6eb..2764d06 100755 --- a/tests/test_db_interface.py +++ b/tests/test_db_interface.py @@ -115,6 +115,16 @@ class TestDBInterface(unittest.TestCase): for _, e in entries.items(): self.assertIsNotNone(e['throughput']) self.assertIsNotNone(e['latency']) + # remove empty line => no import since broken format + del input_data[3] + entries = dbi._get_asmbench_output(input_data, 'aarch64') + self.assertEqual(len(entries), 0) + with self.assertRaises(ValueError): + dbi.import_benchmark_output( + 'csx', 'invalid_bench_type', self._find_file('asmbench_import_x86.dat') + ) + with self.assertRaises(AssertionError): + dbi.import_benchmark_output('csx', 'ibench', 'invalid_file') ################## # Helper functions diff --git a/tests/test_semantics.py b/tests/test_semantics.py index eb3b13a..a702979 100755 --- a/tests/test_semantics.py +++ b/tests/test_semantics.py @@ -5,6 +5,7 @@ Unit tests for Semantic Analysis import os import unittest +from copy import deepcopy from subprocess import call import networkx as nx @@ -106,6 +107,26 @@ class TestSemanticTools(unittest.TestCase): self.assertIsInstance(instruction_form['port_pressure'], list) self.assertEqual(len(instruction_form['port_pressure']), port_num) + def test_optimal_throughput_assignment(self): + # x86 + kernel_fixed = deepcopy(self.kernel_x86) + self.semantics_csx.add_semantics(kernel_fixed) + kernel_optimal = deepcopy(kernel_fixed) + self.semantics_csx.assign_optimal_throughput(kernel_optimal) + tp_fixed = self.semantics_csx.get_throughput_sum(kernel_fixed) + tp_optimal = self.semantics_csx.get_throughput_sum(kernel_optimal) + self.assertNotEqual(tp_fixed, tp_optimal) + self.assertTrue(max(tp_optimal) <= max(tp_fixed)) + # arm + kernel_fixed = deepcopy(self.kernel_AArch64) + self.semantics_tx2.add_semantics(kernel_fixed) + kernel_optimal = deepcopy(kernel_fixed) + self.semantics_tx2.assign_optimal_throughput(kernel_optimal) + tp_fixed = self.semantics_tx2.get_throughput_sum(kernel_fixed) + tp_optimal = self.semantics_tx2.get_throughput_sum(kernel_optimal) + self.assertNotEqual(tp_fixed, tp_optimal) + self.assertTrue(max(tp_optimal) <= max(tp_fixed)) + def test_kernelDG_x86(self): # # 4