From 27595f8224b9a527ee8d7a2a4e8b92d4114386af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ma=C3=ABl=20Madon?= <mael.madon@irit.fr>
Date: Thu, 29 Jun 2023 15:01:50 +0200
Subject: [PATCH] test: add tests to see if easy_bf and easy_bf_fast have the
 same output. Tests fail for now.

---
 test/conftest.py             |  1 +
 test/test_broker.py          | 11 +++++++++++
 test/test_schedulers_mono.py | 29 +++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+)

diff --git a/test/conftest.py b/test/conftest.py
index b80d588..d599332 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -36,6 +36,7 @@ def pytest_generate_tests(metafunc):
     if 'sched_mono' in metafunc.fixturenames:
         scheds = [
             Scheduler('easy_bf', 'easy'),
+            Scheduler('easy_bf_fast', 'easy_fast'),
             Scheduler('fcfs', 'fcfs') 
         ]
         metafunc.parametrize('sched_mono', scheds)
diff --git a/test/test_broker.py b/test/test_broker.py
index 2effe5f..5da510c 100644
--- a/test/test_broker.py
+++ b/test/test_broker.py
@@ -26,6 +26,17 @@ def test_broker_mono(platform_monoC, workload_static, sched_mono):
     if has_expected_output(test_name):
         assert_expected_output(test_name)
 
+def test_easy_bf_fast(platform_monoC, workload_static):
+    test_name_easy = f'broker-easy-{platform_monoC.name}-{workload_static.name}'
+    test_name_easy_fast = f'broker-easy_fast-{platform_monoC.name}-{workload_static.name}'
+
+    expected = 'test-out/' + test_name_easy + '/_jobs.csv'
+    obtained = 'test-out/' +  test_name_easy_fast + '/_jobs.csv'
+    assert filecmp.cmp(expected, obtained), f"\
+        Files {expected} and {obtained} should be equal but are not.\n\
+        Run `diff {expected} {obtained}` to investigate why.\n\
+        Run `cp {obtained} {expected}` to override the expected file with the obtained."
+
 
 def test_broker_multi(platform_multiC, workload_static, sched_multi):
     """Test the broker mode with multicore platform files and schedulers"""
diff --git a/test/test_schedulers_mono.py b/test/test_schedulers_mono.py
index 467fefd..d268d5b 100755
--- a/test/test_schedulers_mono.py
+++ b/test/test_schedulers_mono.py
@@ -40,3 +40,32 @@ def test_easy_bf(platform_monoC, workload_static):
     instance.to_file(robin_filename)
     ret = run_robin(robin_filename)
     assert ret.returncode == 0
+
+
+def test_easy_bf_fast(platform_monoC, workload_static):
+    """Tests if easy_bf and easy_bf_fast behave the same"""
+
+    sched = "easy_bf_fast"
+    test_name = f'{sched}-{platform_monoC.name}-{workload_static.name}'
+    output_dir, robin_filename, _ = init_instance(test_name)
+
+    batcmd = gen_batsim_cmd(platform_monoC.filename, workload_static.filename, output_dir, "")
+    instance = RobinInstance(output_dir=output_dir,
+        batcmd=batcmd,
+        schedcmd=f"batmen -v '{sched}'",
+        simulation_timeout=30, ready_timeout=5,
+        success_timeout=10, failure_timeout=0
+    )
+
+    instance.to_file(robin_filename)
+    ret = run_robin(robin_filename)
+    assert ret.returncode == 0
+
+    # Test if the output are the same than with easy_bf
+    test_easy = f'easy_bf-{platform_monoC.name}-{workload_static.name}'
+    obtained = f'test-out/{test_name}/_jobs.csv'
+    expected = f'test-out/{test_easy}/_jobs.csv'
+    assert filecmp.cmp(expected, obtained), f"\
+        Files {expected} and {obtained} should be equal but are not.\n\
+        Run `diff {expected} {obtained}` to investigate why.\n\
+        Run `cp {obtained} {expected}` to override the expected file with the obtained."
-- 
GitLab