Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
.DS_Store
.DS_Store
tests/.tmp
.pytest_cache
.vscode
__pycache__
8 changes: 8 additions & 0 deletions tests/res/inputs/ex1.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Task,BCET,WCET,Period,Deadline,Priority
T1,0,1,6,6,1
T2,3,4,60,60,7
T3,1,1,10,10,2
T4,1,2,12,12,3
T5,1,2,15,15,4
T6,1,3,20,20,5
T7,1,4,30,30,6
1 change: 1 addition & 0 deletions tests/res/inputs/ex2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file added tests/res/inputs/ex3.csv
Empty file.
8 changes: 8 additions & 0 deletions tests/res/solutions/ex1_s.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Task,WCRT,Deadline,Status
T1,1.0,6,true
T2,54.0,60,true
T3,2.0,10,true
T4,4.0,12,true
T5,6.0,15,true
T6,10.0,20,true
T7,28.0,30,true
12 changes: 12 additions & 0 deletions tests/res/solutions/ex2_s.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Task,WCRT,Deadline,Status
T1,1.0,15,true
T2,3.0,20,true
T3,6.0,25,true
T4,10.0,30,true
T5,15.0,50,true
T6,23.0,60,true
T7,37.0,75,true
T8,49.0,100,true
T9,98.0,120,true
T10,197.0,150,false
T11,580.0,300,false
10 changes: 10 additions & 0 deletions tests/res/solutions/ex3_s.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Task,WCRT,Deadline,Status
T1,3.0,40,true
T2,10.0,80,true
T3,23.0,100,true
T4,44.0,160,true
T5,66.0,200,true
T6,116.0,300,true
T7,148.0,320,true
T8,258.0,400,true
T9,296.0,480,true
62 changes: 62 additions & 0 deletions tests/test_exercises.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import os
import pandas as pd

# TODO: add import for the function


def test_exercise_1():
run_test("ex1")

def test_exercise_2():
run_test("ex2")

def test_exercise_3():
run_test("ex3")

def run_test(filename:str):
solution_file = os.path.join(get_res_path(),"solutions",f"{filename}_s.csv")

input_file = os.path.join(get_res_path(),"inputs",f"{filename}.csv")
output_file = os.path.join(get_tmp_path(),f"{filename}_s.csv")

# TODO: call the function to test

output_df = pd.read_csv(output_file)
solution_df = pd.read_csv(solution_file)

print(f"Output dataframe shape: {output_df.shape}")
print(f"Solution dataframe shape: {solution_df.shape}")
if not output_df.shape == solution_df.shape:
print("Error: dataframe shape are different")
assert(False)

print("Output dataframe:")
print(output_df)
print("==============================")

print("Solution dataframe:")
print(solution_df)
print("==============================")
assert(output_df.equals(solution_df))

def get_root():
'''
Get the project root
'''
return os.path.dirname(os.path.dirname(__file__))

def get_res_path():
'''
Get the absoulte path of the tests/res folder
'''
return os.path.join(get_root(),"tests","res")

def get_tmp_path():
'''
Get the absoulte path of the tests/.tmp folder.
If it doesn't exist it creates it
'''
tmp_path = os.path.join(get_root(), "tests", ".tmp")
if not os.path.exists(tmp_path):
os.makedirs(tmp_path)
return tmp_path
2 changes: 0 additions & 2 deletions tests/test_main.py

This file was deleted.

Loading