From 0066c7215ed802ee46cbc1129e6b045c4a2bafef Mon Sep 17 00:00:00 2001
From: Oscar Gustafsson <oscar.gustafsson@gmail.com>
Date: Mon, 23 Jan 2023 11:08:03 +0100
Subject: [PATCH] Add test for memory variable list

---
 test/conftest.py           |  1 +
 test/fixtures/schedule.py  | 17 +++++++++++++++++
 test/test_schedule.py      | 31 +++++++++++++++++++++++++++++++
 test/test_scheduler_gui.py |  1 +
 4 files changed, 50 insertions(+)
 create mode 100644 test/fixtures/schedule.py

diff --git a/test/conftest.py b/test/conftest.py
index 637da5fa..d416911b 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -1,5 +1,6 @@
 from test.fixtures.operation_tree import *
 from test.fixtures.port import *
+from test.fixtures.schedule import *
 from test.fixtures.signal import signal, signals
 from test.fixtures.signal_flow_graph import *
 
diff --git a/test/fixtures/schedule.py b/test/fixtures/schedule.py
new file mode 100644
index 00000000..eb94c96d
--- /dev/null
+++ b/test/fixtures/schedule.py
@@ -0,0 +1,17 @@
+import pytest
+
+from test.fixtures.signal_flow_graph import precedence_sfg_delays
+
+from b_asic.core_operations import Addition, ConstantMultiplication
+from b_asic.schedule import Schedule
+
+
+@pytest.fixture
+def secondorder_iir_schedule(precedence_sfg_delays):
+    precedence_sfg_delays.set_latency_of_type(Addition.type_name(), 4)
+    precedence_sfg_delays.set_latency_of_type(
+        ConstantMultiplication.type_name(), 3
+    )
+
+    schedule = Schedule(precedence_sfg_delays, scheduling_alg="ASAP")
+    return schedule
diff --git a/test/test_schedule.py b/test/test_schedule.py
index dadef84c..b4a1ffa3 100644
--- a/test/test_schedule.py
+++ b/test/test_schedule.py
@@ -58,6 +58,31 @@ class TestInit:
         }
         assert schedule.schedule_time == 21
 
+    def test_complicated_single_outputs_normal_latency_from_fixture(
+        self, secondorder_iir_schedule
+    ):
+        start_times_names = {
+            secondorder_iir_schedule.sfg.find_by_id(op_id).name: start_time
+            for op_id, start_time in secondorder_iir_schedule._start_times.items()
+        }
+
+        assert start_times_names == {
+            "IN1": 0,
+            "C0": 0,
+            "B1": 0,
+            "B2": 0,
+            "ADD2": 3,
+            "ADD1": 7,
+            "Q1": 11,
+            "A0": 14,
+            "A1": 0,
+            "A2": 0,
+            "ADD3": 3,
+            "ADD4": 17,
+            "OUT1": 21,
+        }
+        assert secondorder_iir_schedule.schedule_time == 21
+
     def test_complicated_single_outputs_complex_latencies(
         self, precedence_sfg_delays
     ):
@@ -436,3 +461,9 @@ class TestTimeResolution:
 
         assert 2 * old_schedule_time == schedule.schedule_time
         assert schedule.get_possible_time_resolution_decrements() == [1, 2]
+
+
+class TestProcesses:
+    def test__get_memory_variables_list(self, secondorder_iir_schedule):
+        mvl = secondorder_iir_schedule._get_memory_variables_list()
+        assert len(mvl) == 12
diff --git a/test/test_scheduler_gui.py b/test/test_scheduler_gui.py
index ebfdad70..9dc4abce 100644
--- a/test/test_scheduler_gui.py
+++ b/test/test_scheduler_gui.py
@@ -2,6 +2,7 @@ import pytest
 
 from b_asic.core_operations import Addition, ConstantMultiplication
 from b_asic.schedule import Schedule
+
 try:
     import b_asic.scheduler_gui as GUI
 except ImportError:
-- 
GitLab