diff --git a/pom.xml b/pom.xml
index 5160f5d..28afa01 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,6 +15,12 @@
+
+ net.sourceforge.cobertura
+ cobertura
+ 2.1.1
+ test
+
org.apache.commons
commons-math3
@@ -56,6 +62,17 @@
+
+
+
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+ 2.7
+
+
+
+
diff --git a/src/main/java/mvd/jester/App.java b/src/main/java/mvd/jester/App.java
index 0663b05..7a86f97 100644
--- a/src/main/java/mvd/jester/App.java
+++ b/src/main/java/mvd/jester/App.java
@@ -11,30 +11,18 @@ import mvd.jester.priority.RateMonotonic;
*/
public class App {
public static void main(String[] args) {
- SystemSetup.Builder builder = new SystemSetup.Builder().setNumberOfProcessors(8);
- TestEnvironment te = new TestEnvironment(builder, 40000);
+ for (int p = 4; p <= 16; p *= 2) {
+ SystemSetup.Builder builder = new SystemSetup.Builder().setNumberOfProcessors(p);
+ TestEnvironment te = new TestEnvironment(builder, 40000);
- te.registerSchedulingAlgorithm(new RateMonotonic());
- te.registerSchedulingAlgorithm(new EarliestDeadlineFirst());
+ te.registerSchedulingAlgorithm(new RateMonotonic());
+ te.registerSchedulingAlgorithm(new EarliestDeadlineFirst());
- te.registerTest(mvd.jester.tests.SchmidMottok.class);
- te.registerTest(mvd.jester.tests.MaiaBertogna.class);
- te.registerTest(mvd.jester.tests.ChwaLee.class);
+ te.registerTest(mvd.jester.tests.SchmidMottok.class);
+ te.registerTest(mvd.jester.tests.MaiaBertogna.class);
+ te.registerTest(mvd.jester.tests.ChwaLee.class);
- te.registerSimulator(mvd.jester.simulator.MaiaBertogna.class);
- te.registerSimulator(mvd.jester.simulator.SchmidMottok.class);
-
-
- te.runExperiments();
-
- // SystemSetup setup = SystemSetup.readFromFile(
- // "/home/mike/Promotion/projects/eclipse/jester/results/test_this.txt", 16);
-
- // SchmidMottok sm = new SchmidMottok(setup);
- // MaiaBertogna mb = new MaiaBertogna(setup);
- // RateMonotonic rm = new RateMonotonic();
-
- // sm.runSchedulabilityCheck(rm);
- // mb.runSchedulabilityCheck(rm);
+ te.runExperiments();
+ }
}
}
diff --git a/src/main/java/mvd/jester/ResultCollector.java b/src/main/java/mvd/jester/ResultCollector.java
index 658b41c..404145d 100644
--- a/src/main/java/mvd/jester/ResultCollector.java
+++ b/src/main/java/mvd/jester/ResultCollector.java
@@ -39,8 +39,8 @@ public class ResultCollector
}
- public void addResult(SchedulingInfo schedulingInfo) {
- this.schedulingInfos.add(schedulingInfo);
+ public boolean addResult(SchedulingInfo schedulingInfo) {
+ return this.schedulingInfos.add(schedulingInfo);
}
public Set getResults() {
diff --git a/src/main/java/mvd/jester/ResultLogger.java b/src/main/java/mvd/jester/ResultLogger.java
index a533b59..44db254 100644
--- a/src/main/java/mvd/jester/ResultLogger.java
+++ b/src/main/java/mvd/jester/ResultLogger.java
@@ -4,13 +4,17 @@ import java.io.IOException;
import java.time.LocalTime;
import java.util.Set;
import java.util.TreeSet;
+import java.util.function.Supplier;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ObjectArrays;
import com.google.common.collect.Table;
import com.google.common.collect.TreeBasedTable;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
+import mvd.jester.info.SchedulingInfo;
+import mvd.jester.info.TerminationInfo.Level;
import mvd.jester.simulator.AbstractSimulator;
import mvd.jester.tests.AbstractTest;
import mvd.jester.utils.Logger;
@@ -33,15 +37,56 @@ public class ResultLogger {
}
public void logTests(Set> results) {
- logFeasibility(results, "test");
- logTaskRatio(results, "test");
+ if (!results.isEmpty()) {
+ logFeasibility(results, "test");
+ logFeasibilityRatio(results, "test");
+ logTaskRatio(results, "test");
+ logFeasibilityLevel(results, "test");
+ }
}
public void logSimulations(Set> results) {
- logFeasibility(results, "sim");
- logTaskRatio(results, "sim");
+ if (!results.isEmpty()) {
+ logFeasibility(results, "sim");
+ logTaskRatio(results, "sim");
+ }
}
+
+ public void logFeasibilityLevel(Set> results,
+ String type) {
+ LocalTime date = LocalTime.now();
+ Logger log = new Logger("./results/feasibility_level_" + type + "_" + numberOfProcessors
+ + "_" + date.getHour() + ":" + date.getMinute() + ".txt");
+
+ Table, Double> resultTable = TreeBasedTable.create();
+ Set> resultCollectors = new TreeSet<>();
+
+ for (long util = 0; util <= numberOfProcessors * 10; util += numberOfProcessors / 4) {
+ for (ResultCollector rc : results) {
+ resultCollectors.add(rc);
+ final long local_util = util;
+
+ Supplier> schedulingResults = () -> rc.getResults().stream()
+ .filter(r -> Math.round(r.getUtilization() * 10 / (numberOfProcessors / 4))
+ * (numberOfProcessors / 4) == local_util);
+ if (schedulingResults.get().filter(r -> !r.checkTasksetFeasible()).count() > 0) {
+ double feasibleTasksets = (double) schedulingResults.get()
+ .filter(r -> r.checkLevelFail(Level.HIGH)).count()
+ / schedulingResults.get().filter(r -> !r.checkTasksetFeasible())
+ .count();
+ resultTable.put(util, rc, feasibleTasksets);
+ } else {
+ resultTable.put(util, rc, 0.);
+ }
+ }
+ }
+
+ logData(log, resultTable, resultCollectors, "Utilization");
+ }
+
+
+
public void logFeasibility(Set> results,
String type) {
LocalTime date = LocalTime.now();
@@ -51,23 +96,49 @@ public class ResultLogger {
Table, Long> resultTable = TreeBasedTable.create();
Set> resultCollectors = new TreeSet<>();
- for (ResultCollector r : results) {
- System.out.println(r.getName() + ": "
- + r.getResults().stream().filter(p -> p.checkTasksetFeasible()).count());
- }
-
- for (long util = 0; util < numberOfProcessors * 10; util++) {
+ for (long util = 0; util <= numberOfProcessors * 10; util += numberOfProcessors / 4) {
for (ResultCollector rc : results) {
resultCollectors.add(rc);
final long local_util = util;
long feasibleTasksets = rc.getResults().stream()
- .filter(r -> Math.round(r.getUtilization() * 10) == local_util)
+ .filter(r -> Math.round(r.getUtilization() * 10 / (numberOfProcessors / 4))
+ * (numberOfProcessors / 4) == local_util)
.filter(r -> r.checkTasksetFeasible()).count();
resultTable.put(util, rc, feasibleTasksets);
}
}
- logData(log, resultTable, resultCollectors);
+ logData(log, resultTable, resultCollectors, "Utilization");
+ }
+
+ public void logFeasibilityRatio(Set> results,
+ String type) {
+ LocalTime date = LocalTime.now();
+ Logger log = new Logger("./results/feasibility_ratio_" + type + "_" + numberOfProcessors
+ + "_" + date.getHour() + ":" + date.getMinute() + ".txt");
+
+ Table, Double> resultTable = TreeBasedTable.create();
+ Set> resultCollectors = new TreeSet<>();
+
+ for (long util = 0; util <= numberOfProcessors * 10; util += numberOfProcessors / 4) {
+ for (ResultCollector rc : results) {
+ resultCollectors.add(rc);
+ final long local_util = util;
+ Supplier> schedulingResults = () -> rc.getResults().stream()
+ .filter(r -> Math.round(r.getUtilization() * 10 / (numberOfProcessors / 4))
+ * (numberOfProcessors / 4) == local_util);
+ if (schedulingResults.get().count() > 0) {
+ double feasibleTasksets =
+ (double) schedulingResults.get().filter(r -> r.checkTasksetFeasible())
+ .count() / schedulingResults.get().count();
+ resultTable.put(util, rc, feasibleTasksets);
+ } else {
+ resultTable.put(util, rc, 1.);
+ }
+ }
+ }
+
+ logData(log, resultTable, resultCollectors, "Utilization");
}
public void logTaskRatio(Set> results,
@@ -79,28 +150,28 @@ public class ResultLogger {
Table, Long> resultTable = TreeBasedTable.create();
Set> resultCollectors = new TreeSet<>();
- for (long ratio = 0; ratio < 10; ratio += 1) {
+ for (long ratio = 0; ratio <= 10; ratio += 1) {
for (ResultCollector rc : results) {
resultCollectors.add(rc);
final long local_ratio = ratio;
long feasibleTasksets = rc.getResults().stream()
- .filter(r -> Math.round(r.getParallelTaskRatio() * 10) == local_ratio)
+ .filter(r -> Math.ceil(r.getParallelTaskRatio() * 10) == local_ratio)
.filter(r -> r.checkTasksetFeasible()).count();
resultTable.put(ratio, rc, feasibleTasksets);
}
}
- logData(log, resultTable, resultCollectors);
+ logData(log, resultTable, resultCollectors, "TaskRatio");
}
private void logData(Logger log,
- Table, Long> resultTable,
- Set> resultCollectors) {
+ Table, ? extends Number> resultTable,
+ Set> resultCollectors, String xDataName) {
final Appendable out = new StringBuilder();
try {
String[] resultCollectorNames = resultCollectors.stream()
.map(ResultCollector::getName).toArray(String[]::new);
- String[] header = ObjectArrays.concat("Utilization", resultCollectorNames);
+ String[] header = ObjectArrays.concat(xDataName, resultCollectorNames);
final CSVPrinter printer = CSVFormat.DEFAULT.withHeader(header).print(out);
printer.printRecords(resultTable.rowMap().entrySet().stream()
@@ -114,110 +185,4 @@ public class ResultLogger {
log.log(out);
log.finalize();
}
-
-
- // public void logFeasibility(
- // Table, Set> results, String type) {
- // LocalTime date = LocalTime.now();
- // Logger log = new Logger("./results/feasibility_" + type + "_" + numberOfProcessors + "_"
- // + date.getHour() + ":" + date.getMinute() + ".txt");
- // String firstLine = new String("Utilization");
-
- // if (!results.isEmpty()) {
- // for (ResultCollector pair : results.columnKeySet()) {
- // firstLine = firstLine + "\t" + pair.getName();
- // }
-
- // log.log(firstLine);
-
- // for (Long util : totalNumberOfTasksets.keySet()) {
- // String line = String.valueOf((double) util / 10);
- // for (ResultCollector pair : results.columnKeySet()) {
- // long feasibleTasksets = results.get(util, pair).stream()
- // .filter(s -> s.checkTasksetFeasible()).count();
- // line += "\t" + feasibleTasksets;
- // }
- // log.log(line);
- // }
- // }
-
- // log.finalize();
- // }
-
-
- // public void logFailedTardiness(
- // Table, Set> results, String type) {
- // LocalTime date = LocalTime.now();
- // Logger log = new Logger("./results/failed_tardiness_" + type + "_" + numberOfProcessors
- // + "_" + date.getHour() + ":" + date.getMinute() + ".txt");
- // String firstLine = new String("Utilization");
-
- // if (!results.isEmpty()) {
- // for (ResultCollector pair : results.columnKeySet()) {
- // firstLine = firstLine + "\t" + pair.getName();
- // }
-
- // log.log(firstLine);
-
- // for (Long kv : totalNumberOfTasksets.keySet()) {
- // String line = String.valueOf((double) kv / 10);
- // for (ResultCollector pair : results.columnKeySet()) {
- // Set simulationInfos = results.get(kv, pair);
- // List values = new ArrayList<>();
-
- // for (SchedulingInfo s : simulationInfos) {
- // Optional failedTerminationInfo =
- // s.getFailedTerminationInfo();
- // if (failedTerminationInfo.isPresent()) {
- // values.add(failedTerminationInfo.get().getLateness());
- // }
- // }
- // double meanTardiness = 0;
- // if (!values.isEmpty()) {
- // meanTardiness = Stats.meanOf(values.iterator());
- // }
- // line += "\t" + meanTardiness;
- // }
- // log.log(line);
- // }
- // }
-
- // log.finalize();
- // }
-
- // public void logTardinessStatistics(
- // Table, Set> results, String type) {
- // LocalTime date = LocalTime.now();
- // Logger log = new Logger("./results/statistics_tardiness_" + type + "_" + numberOfProcessors
- // + "_" + date.getHour() + ":" + date.getMinute() + ".txt");
- // String firstLine = new String("Utilization");
-
- // if (!results.isEmpty()) {
- // for (ResultCollector pair : results.columnKeySet()) {
- // firstLine = firstLine + "\t" + pair.getName();
- // }
-
- // log.log(firstLine);
-
- // for (Long kv : totalNumberOfTasksets.keySet()) {
- // String line = String.valueOf((double) kv / 10);
- // for (ResultCollector pair : results.columnKeySet()) {
- // Set simulationInfos = results.get(kv, pair);
- // DescriptiveStatistics stats = new DescriptiveStatistics();
-
- // for (SchedulingInfo s : simulationInfos) {
- // for (TerminationInfo t : s.getTerminationInfos()) {
- // stats.addValue(t.getLateness());
- // }
- // }
-
- // line += "\t" + stats.getMean();
- // }
- // log.log(line);
- // }
- // }
-
- // log.finalize();
- // }
-
}
diff --git a/src/main/java/mvd/jester/info/SchedulingInfo.java b/src/main/java/mvd/jester/info/SchedulingInfo.java
index adf6259..425de6f 100644
--- a/src/main/java/mvd/jester/info/SchedulingInfo.java
+++ b/src/main/java/mvd/jester/info/SchedulingInfo.java
@@ -3,9 +3,10 @@ package mvd.jester.info;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
+import mvd.jester.info.TerminationInfo.Level;
/**
- * DeadlineMissInfo
+ * SchedulingInfo
*/
public class SchedulingInfo {
@@ -44,13 +45,18 @@ public class SchedulingInfo {
terminationInfos.stream().filter(t -> t.getLateness() > 0).findFirst();
}
+ public boolean checkLevelFail(Level level) {
+ return terminationInfos.stream()
+ .anyMatch(t -> t.getLateness() > 0 && t.getTaskLevel() == level);
+ }
+
public boolean checkTasksetFeasible() {
// return terminationInfos.isEmpty();
return !terminationInfos.stream().anyMatch(t -> t.getLateness() > 0);
}
- public void addTerminationInfo(TerminationInfo terminationInfo) {
- terminationInfos.add(terminationInfo);
+ public boolean addTerminationInfo(TerminationInfo terminationInfo) {
+ return terminationInfos.add(terminationInfo);
}
/**
diff --git a/src/main/java/mvd/jester/info/TerminationInfo.java b/src/main/java/mvd/jester/info/TerminationInfo.java
index b75a906..5fbb277 100644
--- a/src/main/java/mvd/jester/info/TerminationInfo.java
+++ b/src/main/java/mvd/jester/info/TerminationInfo.java
@@ -9,14 +9,31 @@ public class TerminationInfo {
private final long deadline;
private final long responseTime;
private final long lateness;
+ private final Level taskLevel;
public TerminationInfo(long releaseTime, long deadline, long responseTime) {
this.releaseTime = releaseTime;
this.deadline = deadline;
this.responseTime = responseTime;
this.lateness = responseTime - deadline;
+ this.taskLevel = Level.LOW;
}
+ public TerminationInfo(long releaseTime, long deadline, long responseTime, Level taskLevel) {
+ this.releaseTime = releaseTime;
+ this.deadline = deadline;
+ this.responseTime = responseTime;
+ this.lateness = responseTime - deadline;
+ this.taskLevel = taskLevel;
+ }
+
+ public TerminationInfo(long deadline, long responseTime, Level taskLevel) {
+ this.releaseTime = 0;
+ this.deadline = deadline;
+ this.responseTime = responseTime;
+ this.lateness = responseTime - deadline;
+ this.taskLevel = taskLevel;
+ }
/**
* @return the deadline
@@ -45,4 +62,15 @@ public class TerminationInfo {
public long getResponseTime() {
return responseTime;
}
+
+ /**
+ * @return the taskLevel
+ */
+ public Level getTaskLevel() {
+ return taskLevel;
+ }
+
+ public enum Level {
+ HIGH, LOW
+ }
}
diff --git a/src/main/java/mvd/jester/model/SystemSetup.java b/src/main/java/mvd/jester/model/SystemSetup.java
index ea8b6c9..d33d987 100644
--- a/src/main/java/mvd/jester/model/SystemSetup.java
+++ b/src/main/java/mvd/jester/model/SystemSetup.java
@@ -180,8 +180,8 @@ public class SystemSetup {
systemSetup.tasks = generateTaskSet();
}
- public void addTask(SystemSetup systemSetup) {
- systemSetup.tasks.add(generateTask());
+ public boolean addTask(SystemSetup systemSetup) {
+ return systemSetup.tasks.add(generateTask());
}
public Builder setNumberOfProcessors(long numberOfProcessors) {
diff --git a/src/main/java/mvd/jester/priority/EarliestDeadlineFirst.java b/src/main/java/mvd/jester/priority/EarliestDeadlineFirst.java
index 4af7fa2..fd7b1bb 100644
--- a/src/main/java/mvd/jester/priority/EarliestDeadlineFirst.java
+++ b/src/main/java/mvd/jester/priority/EarliestDeadlineFirst.java
@@ -5,8 +5,8 @@ import java.util.HashSet;
import java.util.Set;
import mvd.jester.model.Task;
import mvd.jester.simulator.AbstractSimulator;
-import mvd.jester.simulator.MaiaBertogna;
-import mvd.jester.simulator.SchmidMottok;
+import mvd.jester.simulator.ParallelSynchronous;
+import mvd.jester.simulator.DynamicForkJoin;
import mvd.jester.simulator.internals.TaskContextInterface;
import mvd.jester.tests.AbstractTest;
import mvd.jester.tests.ChwaLee;
@@ -19,7 +19,7 @@ public class EarliestDeadlineFirst implements PriorityManager {
final static Set> abstractTests =
new HashSet<>(Arrays.asList(ChwaLee.class));
final static Set> abstractSimulators =
- new HashSet<>(Arrays.asList(MaiaBertogna.class, SchmidMottok.class));
+ new HashSet<>(Arrays.asList(ParallelSynchronous.class, DynamicForkJoin.class));
/**
* Compare the priority of two tasks according to the Rate Monotonic policy
diff --git a/src/main/java/mvd/jester/priority/RateMonotonic.java b/src/main/java/mvd/jester/priority/RateMonotonic.java
index b76a947..3c46ff4 100644
--- a/src/main/java/mvd/jester/priority/RateMonotonic.java
+++ b/src/main/java/mvd/jester/priority/RateMonotonic.java
@@ -13,16 +13,16 @@ public class RateMonotonic implements PriorityManager {
final static Set> abstractTests = new HashSet<>(Arrays
.asList(mvd.jester.tests.MaiaBertogna.class, mvd.jester.tests.SchmidMottok.class));
final static Set> abstractSimulators =
- new HashSet<>(Arrays.asList(mvd.jester.simulator.MaiaBertogna.class,
- mvd.jester.simulator.SchmidMottok.class));
+ new HashSet<>(Arrays.asList(mvd.jester.simulator.ParallelSynchronous.class,
+ mvd.jester.simulator.DynamicForkJoin.class));
/**
* Compare the priority of two tasks according to the Rate Monotonic policy
*
* @param t1 The first task
* @param t2 The second task
- * @return 0 if both tasks have the same priority, positive number if the first task has a
- * higher priority, negative number if the second task has a higher priority
+ * @return 0 if both tasks have the same priority, negative number if the first task has a
+ * higher priority, positive number if the second task has a higher priority
*/
@Override
public int compare(Task t1, Task t2) {
diff --git a/src/main/java/mvd/jester/simulator/AbstractSimulator.java b/src/main/java/mvd/jester/simulator/AbstractSimulator.java
index a019dae..83d1088 100644
--- a/src/main/java/mvd/jester/simulator/AbstractSimulator.java
+++ b/src/main/java/mvd/jester/simulator/AbstractSimulator.java
@@ -25,7 +25,6 @@ public abstract class AbstractSimulator implements SimulatorInterface, TypeInter
protected final SystemSetup systemSetup;
protected final Set processors;
protected TreeMultiset readyTasks;
- protected long hyperPeriod;
AbstractSimulator(SystemSetup systemSetup) {
this.systemSetup = systemSetup;
@@ -34,8 +33,6 @@ public abstract class AbstractSimulator implements SimulatorInterface, TypeInter
for (int i = 0; i < systemSetup.getNumberOfProcessors(); ++i) {
processors.add(new ProcessorContext(i));
}
- this.hyperPeriod = getHyperPeriod();
-
}
@@ -45,7 +42,7 @@ public abstract class AbstractSimulator implements SimulatorInterface, TypeInter
public SchedulingInfo runSimulation(PriorityManager priorityManager) {
SchedulingInfo schedulingInfo = new SchedulingInfo(systemSetup.getParallelTaskRatio(),
systemSetup.getUtilization());
- init(priorityManager);
+ long hyperPeriod = init(priorityManager);
for (int t = 0; t < hyperPeriod; ++t) {
if (!releaseTasks(t)) {
throw new RuntimeException("Could not release a task. This should not happen!");
@@ -66,10 +63,12 @@ public abstract class AbstractSimulator implements SimulatorInterface, TypeInter
Optional optionalTc = p.updateExecution(t);
if (optionalTc.isPresent()) {
TaskContextInterface tc = optionalTc.get();
- TerminationInfo terminationInfo =
- new TerminationInfo(tc.getReleaseTime(), tc.getDeadline(), t);
- schedulingInfo.addTerminationInfo(terminationInfo);
if (t >= tc.getDeadline()) {
+ TerminationInfo terminationInfo =
+ new TerminationInfo(tc.getReleaseTime(), tc.getDeadline(), t);
+ schedulingInfo.addTerminationInfo(terminationInfo);
+
+
EventPrinter.print("Time " + t + ": Task " + tc + " failed its deadline!");
schedulingInfo.setFailedTerminationInfo(terminationInfo);
return schedulingInfo;
@@ -83,12 +82,12 @@ public abstract class AbstractSimulator implements SimulatorInterface, TypeInter
return schedulingInfo;
}
- private void init(PriorityManager priorityManager) {
+ private long init(PriorityManager priorityManager) {
this.readyTasks = TreeMultiset.create((t1, t2) -> priorityManager.compare(t1, t2));
for (ProcessorContext p : processors) {
p.setJob(null);
}
- this.hyperPeriod = getHyperPeriod();
+ return getHyperPeriod();
}
private Set sortProcessors(Set processors) {
diff --git a/src/main/java/mvd/jester/simulator/SchmidMottok.java b/src/main/java/mvd/jester/simulator/DynamicForkJoin.java
similarity index 90%
rename from src/main/java/mvd/jester/simulator/SchmidMottok.java
rename to src/main/java/mvd/jester/simulator/DynamicForkJoin.java
index f82f047..5a96941 100644
--- a/src/main/java/mvd/jester/simulator/SchmidMottok.java
+++ b/src/main/java/mvd/jester/simulator/DynamicForkJoin.java
@@ -3,14 +3,14 @@ package mvd.jester.simulator;
import mvd.jester.model.SystemSetup;
import mvd.jester.model.Task;
-import mvd.jester.simulator.internals.schmidmottok.TaskContext;
+import mvd.jester.simulator.internals.dynamicforkjoin.TaskContext;
/**
* SchmidMottok
*/
-public class SchmidMottok extends AbstractSimulator {
+public class DynamicForkJoin extends AbstractSimulator {
- public SchmidMottok(SystemSetup systemSetup) {
+ public DynamicForkJoin(SystemSetup systemSetup) {
super(systemSetup);
}
diff --git a/src/main/java/mvd/jester/simulator/MaiaBertogna.java b/src/main/java/mvd/jester/simulator/ParallelSynchronous.java
similarity index 90%
rename from src/main/java/mvd/jester/simulator/MaiaBertogna.java
rename to src/main/java/mvd/jester/simulator/ParallelSynchronous.java
index f21fa4a..f3dcb35 100644
--- a/src/main/java/mvd/jester/simulator/MaiaBertogna.java
+++ b/src/main/java/mvd/jester/simulator/ParallelSynchronous.java
@@ -2,14 +2,14 @@ package mvd.jester.simulator;
import mvd.jester.model.SystemSetup;
import mvd.jester.model.Task;
-import mvd.jester.simulator.internals.maiabertogna.TaskContext;
+import mvd.jester.simulator.internals.parallelsynchronous.TaskContext;
/**
* MaiaBertogna
*/
-public class MaiaBertogna extends AbstractSimulator {
+public class ParallelSynchronous extends AbstractSimulator {
- public MaiaBertogna(SystemSetup systemSetup) {
+ public ParallelSynchronous(SystemSetup systemSetup) {
super(systemSetup);
}
diff --git a/src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java b/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/JobContext.java
similarity index 99%
rename from src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java
rename to src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/JobContext.java
index 4a71c5e..5b16ced 100644
--- a/src/main/java/mvd/jester/simulator/internals/schmidmottok/JobContext.java
+++ b/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/JobContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.internals.schmidmottok;
+package mvd.jester.simulator.internals.dynamicforkjoin;
import java.util.Optional;
import mvd.jester.simulator.EventPrinter;
diff --git a/src/main/java/mvd/jester/simulator/internals/schmidmottok/SegmentContext.java b/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/SegmentContext.java
similarity index 98%
rename from src/main/java/mvd/jester/simulator/internals/schmidmottok/SegmentContext.java
rename to src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/SegmentContext.java
index 884de1e..b5da48e 100644
--- a/src/main/java/mvd/jester/simulator/internals/schmidmottok/SegmentContext.java
+++ b/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/SegmentContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.internals.schmidmottok;
+package mvd.jester.simulator.internals.dynamicforkjoin;
import java.util.HashSet;
import java.util.Optional;
diff --git a/src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskContext.java b/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskContext.java
similarity index 98%
rename from src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskContext.java
rename to src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskContext.java
index 587c0cb..458f621 100644
--- a/src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskContext.java
+++ b/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.internals.schmidmottok;
+package mvd.jester.simulator.internals.dynamicforkjoin;
import java.util.ArrayList;
import java.util.Optional;
diff --git a/src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskletContext.java b/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskletContext.java
similarity index 97%
rename from src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskletContext.java
rename to src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskletContext.java
index d3c43e9..1c686a4 100644
--- a/src/main/java/mvd/jester/simulator/internals/schmidmottok/TaskletContext.java
+++ b/src/main/java/mvd/jester/simulator/internals/dynamicforkjoin/TaskletContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.internals.schmidmottok;
+package mvd.jester.simulator.internals.dynamicforkjoin;
import java.util.Optional;
diff --git a/src/main/java/mvd/jester/simulator/internals/maiabertogna/JobContext.java b/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/JobContext.java
similarity index 98%
rename from src/main/java/mvd/jester/simulator/internals/maiabertogna/JobContext.java
rename to src/main/java/mvd/jester/simulator/internals/parallelsynchronous/JobContext.java
index 05c7d54..da92104 100644
--- a/src/main/java/mvd/jester/simulator/internals/maiabertogna/JobContext.java
+++ b/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/JobContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.internals.maiabertogna;
+package mvd.jester.simulator.internals.parallelsynchronous;
import java.util.Optional;
import mvd.jester.simulator.EventPrinter;
diff --git a/src/main/java/mvd/jester/simulator/internals/maiabertogna/SegmentContext.java b/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/SegmentContext.java
similarity index 97%
rename from src/main/java/mvd/jester/simulator/internals/maiabertogna/SegmentContext.java
rename to src/main/java/mvd/jester/simulator/internals/parallelsynchronous/SegmentContext.java
index d35deda..b03d8f1 100644
--- a/src/main/java/mvd/jester/simulator/internals/maiabertogna/SegmentContext.java
+++ b/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/SegmentContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.internals.maiabertogna;
+package mvd.jester.simulator.internals.parallelsynchronous;
import java.util.HashSet;
import java.util.Optional;
diff --git a/src/main/java/mvd/jester/simulator/internals/maiabertogna/TaskContext.java b/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/TaskContext.java
similarity index 98%
rename from src/main/java/mvd/jester/simulator/internals/maiabertogna/TaskContext.java
rename to src/main/java/mvd/jester/simulator/internals/parallelsynchronous/TaskContext.java
index adfab81..a25ffb4 100644
--- a/src/main/java/mvd/jester/simulator/internals/maiabertogna/TaskContext.java
+++ b/src/main/java/mvd/jester/simulator/internals/parallelsynchronous/TaskContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.internals.maiabertogna;
+package mvd.jester.simulator.internals.parallelsynchronous;
import java.util.ArrayList;
import java.util.Optional;
@@ -20,7 +20,6 @@ public class TaskContext implements TaskContextInterface {
private int currentSegment;
private int segmentCounter;
-
public TaskContext(Task task, long releaseTime) {
this.task = task;
this.segments = new ArrayList<>();
diff --git a/src/main/java/mvd/jester/tests/AbstractTest.java b/src/main/java/mvd/jester/tests/AbstractTest.java
index d8cd647..640453a 100644
--- a/src/main/java/mvd/jester/tests/AbstractTest.java
+++ b/src/main/java/mvd/jester/tests/AbstractTest.java
@@ -2,7 +2,6 @@ package mvd.jester.tests;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import mvd.jester.TypeInterface;
import mvd.jester.info.TerminationInfo;
import mvd.jester.model.SystemSetup;
@@ -15,12 +14,10 @@ public abstract class AbstractTest implements TestInterface, TypeInterface {
protected final Map responseTimes;
protected final SystemSetup systemSetup;
- protected Set tasks;
public AbstractTest(SystemSetup systemSetup) {
this.systemSetup = systemSetup;
this.responseTimes = new HashMap<>();
- this.tasks = systemSetup.getTasks();
}
}
diff --git a/src/main/java/mvd/jester/tests/ChwaLee.java b/src/main/java/mvd/jester/tests/ChwaLee.java
index e3bb107..5f04895 100644
--- a/src/main/java/mvd/jester/tests/ChwaLee.java
+++ b/src/main/java/mvd/jester/tests/ChwaLee.java
@@ -5,9 +5,11 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import com.google.common.math.LongMath;
import mvd.jester.info.SchedulingInfo;
import mvd.jester.info.TerminationInfo;
+import mvd.jester.info.TerminationInfo.Level;
import mvd.jester.model.Segment;
import mvd.jester.model.SortedTaskSet;
import mvd.jester.model.SystemSetup;
@@ -25,19 +27,20 @@ public class ChwaLee extends AbstractTest {
@Override
public SchedulingInfo runSchedulabilityCheck(PriorityManager priorityManager) {
- tasks = new SortedTaskSet(priorityManager);
+ SortedTaskSet tasks = new SortedTaskSet(priorityManager);
tasks.addAll(systemSetup.getTasks());
responseTimes.clear();
for (Task t : tasks) {
- long responseTime = calculateResponseTime(t);
- responseTimes.put(t, new TerminationInfo(0, t.getDeadline(), responseTime));
+ Level taskLevel = tasks.headSet(t).size() <= tasks.size() / 2 ? Level.HIGH : Level.LOW;
+ long responseTime = calculateResponseTime(tasks, t);
+ responseTimes.put(t, new TerminationInfo(t.getDeadline(), responseTime, taskLevel));
}
return new SchedulingInfo(new HashSet<>(responseTimes.values()),
systemSetup.getParallelTaskRatio(), systemSetup.getUtilization());
}
- private long calculateResponseTime(Task task) {
+ private long calculateResponseTime(Set tasks, Task task) {
long minimumWcet = getMinimumWcet(task);
long deadline = task.getDeadline();
long numberOfProcessors = systemSetup.getNumberOfProcessors();
diff --git a/src/main/java/mvd/jester/tests/MaiaBertogna.java b/src/main/java/mvd/jester/tests/MaiaBertogna.java
index 0b29619..d57be1a 100644
--- a/src/main/java/mvd/jester/tests/MaiaBertogna.java
+++ b/src/main/java/mvd/jester/tests/MaiaBertogna.java
@@ -2,9 +2,11 @@ package mvd.jester.tests;
import java.math.RoundingMode;
import java.util.HashSet;
+import java.util.Set;
import com.google.common.math.LongMath;
import mvd.jester.info.SchedulingInfo;
import mvd.jester.info.TerminationInfo;
+import mvd.jester.info.TerminationInfo.Level;
import mvd.jester.model.Segment;
import mvd.jester.model.SortedTaskSet;
import mvd.jester.model.Task;
@@ -22,12 +24,13 @@ public class MaiaBertogna extends AbstractTest {
@Override
public SchedulingInfo runSchedulabilityCheck(PriorityManager priorityManager) {
- tasks = new SortedTaskSet(priorityManager);
+ SortedTaskSet tasks = new SortedTaskSet(priorityManager);
tasks.addAll(systemSetup.getTasks());
responseTimes.clear();
for (Task t : tasks) {
- long responseTime = calculateResponseTime(t);
- responseTimes.put(t, new TerminationInfo(0, t.getDeadline(), responseTime));
+ Level taskLevel = tasks.headSet(t).size() <= tasks.size() / 2 ? Level.HIGH : Level.LOW;
+ long responseTime = calculateResponseTime(tasks, t);
+ responseTimes.put(t, new TerminationInfo(t.getDeadline(), responseTime, taskLevel));
}
return new SchedulingInfo(new HashSet<>(responseTimes.values()),
@@ -39,7 +42,7 @@ public class MaiaBertogna extends AbstractTest {
return "MaiaBertogna";
}
- private long calculateResponseTime(Task task) {
+ private long calculateResponseTime(Set tasks, Task task) {
long minimumWcet = getMinimumWcet(task);
long responseTime = minimumWcet;
long previousResponseTime = 0;
diff --git a/src/main/java/mvd/jester/tests/SchmidMottok.java b/src/main/java/mvd/jester/tests/SchmidMottok.java
index edc0a1a..c4f5a86 100644
--- a/src/main/java/mvd/jester/tests/SchmidMottok.java
+++ b/src/main/java/mvd/jester/tests/SchmidMottok.java
@@ -2,9 +2,11 @@ package mvd.jester.tests;
import java.math.RoundingMode;
import java.util.HashSet;
+import java.util.Set;
import com.google.common.math.LongMath;
import mvd.jester.info.SchedulingInfo;
import mvd.jester.info.TerminationInfo;
+import mvd.jester.info.TerminationInfo.Level;
import mvd.jester.model.Segment;
import mvd.jester.model.SortedTaskSet;
import mvd.jester.model.Task;
@@ -22,12 +24,13 @@ public class SchmidMottok extends AbstractTest {
@Override
public SchedulingInfo runSchedulabilityCheck(PriorityManager priorityManager) {
- tasks = new SortedTaskSet(priorityManager);
+ SortedTaskSet tasks = new SortedTaskSet(priorityManager);
tasks.addAll(systemSetup.getTasks());
responseTimes.clear();
for (Task t : tasks) {
- long responseTime = calculateResponseTime(t);
- responseTimes.put(t, new TerminationInfo(0, t.getDeadline(), responseTime));
+ Level taskLevel = tasks.headSet(t).size() <= tasks.size() / 2 ? Level.HIGH : Level.LOW;
+ long responseTime = calculateResponseTime(tasks, t);
+ responseTimes.put(t, new TerminationInfo(t.getDeadline(), responseTime, taskLevel));
}
return new SchedulingInfo(new HashSet<>(responseTimes.values()),
@@ -39,7 +42,7 @@ public class SchmidMottok extends AbstractTest {
return "SchmidMottok";
}
- private long calculateResponseTime(Task task) {
+ private long calculateResponseTime(Set tasks, Task task) {
long minimumWcet = getMinimumWcet(task);
long responseTime = minimumWcet;
long previousResponseTime = 0;
diff --git a/src/main/java/mvd/jester/utils/Logger.java b/src/main/java/mvd/jester/utils/Logger.java
index f82b9e2..03b1672 100644
--- a/src/main/java/mvd/jester/utils/Logger.java
+++ b/src/main/java/mvd/jester/utils/Logger.java
@@ -31,10 +31,10 @@ public class Logger {
public void finalize() {
try {
if (printWriter != null) {
- printWriter.close(); // Will close bw and fw too
+ printWriter.close();
}
if (bufferedWriter != null) {
- bufferedWriter.close(); // Will close fw too
+ bufferedWriter.close();
}
if (fileWriter != null) {
fileWriter.close();
diff --git a/src/test/java/mvd/jester/TestResultCollector.java b/src/test/java/mvd/jester/TestResultCollector.java
new file mode 100644
index 0000000..5a91c76
--- /dev/null
+++ b/src/test/java/mvd/jester/TestResultCollector.java
@@ -0,0 +1,62 @@
+package mvd.jester;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.ThreadLocalRandom;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import mvd.jester.info.SchedulingInfo;
+import mvd.jester.priority.PriorityManager;
+
+/**
+ * TestResultCollector
+ */
+public class TestResultCollector {
+
+ @Test
+ @DisplayName("Test if getters and setters work correctly.")
+ void testGettersAndSetters() {
+ final PriorityManager pm = mock(PriorityManager.class);
+ final String pmName = "PriorityManagerName";
+ when(pm.getName()).thenReturn(pmName);
+
+ final TypeInterface ti = mock(TypeInterface.class);
+ final String tiName = "TypeInterfaceName";
+ when(ti.getName()).thenReturn(tiName);
+
+ final ResultCollector rc1 = new ResultCollector<>(pm, ti);
+ final ResultCollector rc2 = new ResultCollector<>(pm, ti);
+
+ assertTrue(rc1.getPriorityManager() == pm);
+ assertTrue(rc1.getAbstractValue() == ti);
+ assertTrue(rc1.getName().equals(tiName + "_" + pmName));
+ assertTrue(rc1.compareTo(rc2) == 0);
+ }
+
+ @Test
+ @DisplayName("Check if adding SchedulingInfos works correctly.")
+ void testSchedulingInfos() {
+ final TypeInterface ti = mock(TypeInterface.class);
+ final PriorityManager pm = mock(PriorityManager.class);
+
+ final ResultCollector rc = new ResultCollector<>(pm, ti);
+
+ final Set schedulingInfos = new HashSet<>();
+
+ long numberOfSchedulingInfos = ThreadLocalRandom.current().nextLong(5, 10);
+ for (int i = 0; i < numberOfSchedulingInfos; ++i) {
+ SchedulingInfo si = mock(SchedulingInfo.class);
+ schedulingInfos.add(si);
+ assertTrue(rc.addResult(si));
+ assertFalse(rc.addResult(si));
+ }
+
+ assertTrue(rc.getResults().size() == numberOfSchedulingInfos);
+ assertTrue(rc.getResults().equals(schedulingInfos));
+ assertTrue(rc.addResult(null));
+ }
+}
diff --git a/src/test/java/mvd/jester/info/TestSchedulingInfo.java b/src/test/java/mvd/jester/info/TestSchedulingInfo.java
new file mode 100644
index 0000000..f46045f
--- /dev/null
+++ b/src/test/java/mvd/jester/info/TestSchedulingInfo.java
@@ -0,0 +1,79 @@
+package mvd.jester.info;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.ThreadLocalRandom;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import mvd.jester.info.TerminationInfo.Level;
+
+/**
+ * TestTerminationInfo
+ */
+public class TestSchedulingInfo {
+
+ @Test
+ @DisplayName("Check if SchedulingInfos parameters are calculated correctly.")
+ public void testSchedulingInfo() {
+ for (int run = 0; run < 1000; ++run) {
+ Set terminationInfos = new HashSet<>();
+ int numberOfTerminationInfos = ThreadLocalRandom.current().nextInt(5, 10);
+ boolean feasibile = true;
+ boolean levelFailed = false;
+ for (int i = 0; i < numberOfTerminationInfos; ++i) {
+ long deadline = ThreadLocalRandom.current().nextLong(50, 100);
+ long responseTime = ThreadLocalRandom.current().nextLong(50, 100);
+ Level taskLevel =
+ ThreadLocalRandom.current().nextLong(0, 100) < 50 ? Level.LOW : Level.HIGH;
+ terminationInfos.add(new TerminationInfo(deadline, responseTime, taskLevel));
+
+ if (deadline < responseTime) {
+ feasibile = false;
+ if (taskLevel == Level.HIGH) {
+ levelFailed = true;
+ }
+ }
+
+ }
+
+ SchedulingInfo schedulingInfo =
+ new SchedulingInfo(terminationInfos, 2, numberOfTerminationInfos);
+
+ assertTrue(schedulingInfo.checkLevelFail(Level.HIGH) == levelFailed);
+ assertTrue(schedulingInfo.checkTasksetFeasible() == feasibile);
+ }
+ }
+
+ @Test
+ @DisplayName("Check Getters and Setters.")
+ public void testGettersAndSetters() {
+ double taskRatio = 0.23;
+ double utilization = 0.49;
+ SchedulingInfo si = new SchedulingInfo(taskRatio, utilization);
+
+ Set terminationInfos = new HashSet<>();
+ long numberOfTerminationInfos = ThreadLocalRandom.current().nextLong(5, 10);
+ for (int i = 0; i < numberOfTerminationInfos; ++i) {
+ TerminationInfo ti = mock(TerminationInfo.class);
+ terminationInfos.add(ti);
+ assertTrue(si.addTerminationInfo(ti));
+ assertFalse(si.addTerminationInfo(ti));
+ }
+
+ assertTrue(si.getParallelTaskRatio() == taskRatio);
+ assertTrue(si.getUtilization() == utilization);
+ assertTrue(si.getTerminationInfos().size() == numberOfTerminationInfos);
+ assertTrue(si.getTerminationInfos().equals(terminationInfos));
+ assertTrue(si.addTerminationInfo(null));
+ assertFalse(si.getFailedTerminationInfo().isPresent());
+
+ TerminationInfo ti = mock(TerminationInfo.class);
+ si.setFailedTerminationInfo(ti);
+ assertTrue(si.getFailedTerminationInfo().isPresent());
+ assertTrue(si.getFailedTerminationInfo().get().equals(ti));
+ }
+
+}
diff --git a/src/test/java/mvd/jester/info/TestTerminationInfo.java b/src/test/java/mvd/jester/info/TestTerminationInfo.java
new file mode 100644
index 0000000..1150dc6
--- /dev/null
+++ b/src/test/java/mvd/jester/info/TestTerminationInfo.java
@@ -0,0 +1,40 @@
+package mvd.jester.info;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import mvd.jester.info.TerminationInfo.Level;
+
+/**
+ * TestTerminationInfo
+ */
+public class TestTerminationInfo {
+
+ @Test
+ @DisplayName("Check Getters and Setters")
+ public void testGettersAndSetters() {
+ long releaseTime = 20;
+ long deadline = 40;
+ long responseTime = 30;
+ Level taskLevel = Level.LOW;
+
+ TerminationInfo ti = new TerminationInfo(releaseTime, deadline, responseTime);
+ TerminationInfo til = new TerminationInfo(deadline, responseTime, taskLevel);
+ TerminationInfo tirl = new TerminationInfo(releaseTime, deadline, responseTime, taskLevel);
+
+
+ assertTrue(ti.getDeadline() == deadline);
+ assertTrue(til.getDeadline() == deadline);
+ assertTrue(tirl.getDeadline() == deadline);
+ assertTrue(ti.getResponseTime() == responseTime);
+ assertTrue(til.getResponseTime() == responseTime);
+ assertTrue(tirl.getResponseTime() == responseTime);
+ assertTrue(ti.getReleaseTime() == releaseTime);
+ assertTrue(tirl.getReleaseTime() == releaseTime);
+ assertTrue(til.getTaskLevel() == taskLevel);
+ assertTrue(tirl.getTaskLevel() == taskLevel);
+ assertTrue(ti.getLateness() == responseTime - deadline);
+ assertTrue(til.getLateness() == responseTime - deadline);
+ assertTrue(tirl.getLateness() == responseTime - deadline);
+ }
+}
diff --git a/src/test/java/mvd/jester/model/TestSystemSetup.java b/src/test/java/mvd/jester/model/TestSystemSetup.java
index c39c803..711e90b 100644
--- a/src/test/java/mvd/jester/model/TestSystemSetup.java
+++ b/src/test/java/mvd/jester/model/TestSystemSetup.java
@@ -1,23 +1,40 @@
package mvd.jester.model;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import java.io.IOException;
+import java.util.Set;
+import java.util.concurrent.ThreadLocalRandom;
+import org.junit.Rule;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.junit.rules.TemporaryFolder;
public class TestSystemSetup {
+ @Rule
+ public TemporaryFolder tf = new TemporaryFolder();
- private static final int NUMBER_OF_SETS = 1000;
+ private static final int NUMBER_OF_RUNS = 1000;
@Test
@DisplayName("Check if randomly generated task parameters lie within the specified ranges.")
public void testRandomTaskSetGeneration() {
- for (int i = 0; i < NUMBER_OF_SETS; ++i) {
- SystemSetup taskSet = new SystemSetup.Builder().setNumberOfSegments(1, 7)
- .setNumberOfJobs(2, 10).setPeriods(100, 1000, 1000).build();
+ for (int i = 0; i < NUMBER_OF_RUNS; ++i) {
+ long numberOfProcessors = ThreadLocalRandom.current().nextLong(2, 8);
+ SystemSetup.Builder systemSetupBuilder = new SystemSetup.Builder()//
+ .setNumberOfSegments(1, 7)//
+ .setNumberOfJobs(2, 10)//
+ .setPeriods(100, 1000, 1000)//
+ .setNumberOfProcessors(numberOfProcessors);
- for (Task t : taskSet.getTasks()) {
+ SystemSetup systemSetup = systemSetupBuilder.build();
+
+ assertTrue(systemSetup.getNumberOfProcessors() == numberOfProcessors);
+
+ for (Task t : systemSetup.getTasks()) {
assertTrue(t.getPeriod() >= 100);
assertTrue(t.getPeriod() <= 1000);
assertTrue(t.getDeadline() == t.getPeriod());
@@ -35,8 +52,39 @@ public class TestSystemSetup {
assertTrue(t.getSegments().size() >= 1);
assertTrue(t.getSegments().size() <= 7);
+
}
+
+ assertTrue(systemSetupBuilder.addTask(systemSetup));
+
+ Set tasks = systemSetup.getTasks();
+ systemSetupBuilder.rebuild(systemSetup);
+ assertFalse(tasks == systemSetup.getTasks());
}
+ }
+ @Test
+ @DisplayName("Check Getters and Setters.")
+ void testGettersAndSetters() {
+ @SuppressWarnings("unchecked")
+ Set t1 = mock(Set.class);
+
+ @SuppressWarnings("unchecked")
+ Set t2 = mock(Set.class);
+
+ SystemSetup systemSetup = new SystemSetup(t1, 2);
+
+ systemSetup.setTasks(t2);
+ assertTrue(systemSetup.getTasks() == t2);
}
+
+ // @Test
+ // @DisplayName("Check if parser works correclty.")
+ // void testParser() throws IOException {
+ // SystemSetup systemSetup = new SystemSetup.Builder().setNumberOfSegments(1, 7)
+ // .setNumberOfJobs(2, 10).setPeriods(100, 1000, 1000).build();
+
+ // systemSetup.writeToFile(null);
+ // systemSetup.writeToFile(tf.getRoot().getAbsolutePath());
+ // }
}
diff --git a/src/test/java/mvd/jester/priority/TestEarliestDeadlineFirst.java b/src/test/java/mvd/jester/priority/TestEarliestDeadlineFirst.java
index dee0483..6a79a6c 100644
--- a/src/test/java/mvd/jester/priority/TestEarliestDeadlineFirst.java
+++ b/src/test/java/mvd/jester/priority/TestEarliestDeadlineFirst.java
@@ -1,11 +1,19 @@
package mvd.jester.priority;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.util.HashSet;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import mvd.jester.model.SystemSetup;
import mvd.jester.model.Task;
-import mvd.jester.simulator.internals.maiabertogna.TaskContext;
+import mvd.jester.simulator.DynamicForkJoin;
+import mvd.jester.simulator.ParallelSynchronous;
+import mvd.jester.simulator.internals.parallelsynchronous.TaskContext;
+import mvd.jester.tests.ChwaLee;
+import mvd.jester.tests.MaiaBertogna;
+import mvd.jester.tests.SchmidMottok;
/**
* TestEarliestDeadlineFirst
@@ -16,13 +24,43 @@ public class TestEarliestDeadlineFirst {
@DisplayName("Test if priority manager returns the correct priority.")
public void testPriority() {
EarliestDeadlineFirst edf = new EarliestDeadlineFirst();
- Task t1 = new Task(100, new HashSet<>());
- Task t2 = new Task(200, new HashSet<>());
- TaskContext tc1 = new TaskContext(t1, 0);
- TaskContext tc2 = new TaskContext(t2, 0);
+ Task t1 = mock(Task.class);
+ Task t2 = mock(Task.class);
+ when(t1.getDeadline()).thenReturn((long) 100);
+ when(t2.getDeadline()).thenReturn((long) 200);
+
+ TaskContext tc1 = mock(TaskContext.class);
+ TaskContext tc2 = mock(TaskContext.class);
+ when(tc1.getDeadline()).thenReturn((long) 100);
+ when(tc2.getDeadline()).thenReturn((long) 200);
assertTrue(edf.compare(t1, t2) < 0);
assertTrue(edf.compare(tc1, tc2) < 0);
+ assertTrue(edf.compare(t1, t1) == 0);
+ assertTrue(edf.compare(tc1, tc1) == 0);
+ assertTrue(edf.compare(t2, t1) > 0);
+ assertTrue(edf.compare(tc2, tc1) > 0);
}
+
+
+ @Test
+ @DisplayName("Check Getters, Tests and Simulators.")
+ void testGettersTestsAndSimulators() {
+ EarliestDeadlineFirst edf = new EarliestDeadlineFirst();
+ assertTrue(edf.hasTest(ChwaLee.class));
+ assertFalse(edf.hasTest(MaiaBertogna.class));
+ assertFalse(edf.hasTest(SchmidMottok.class));
+ assertTrue(edf.hasSimulator(ParallelSynchronous.class));
+ assertTrue(edf.hasSimulator(DynamicForkJoin.class));
+
+ assertTrue(edf.hasTest(new ChwaLee(mock(SystemSetup.class))));
+ assertFalse(edf.hasTest(new SchmidMottok(mock(SystemSetup.class))));
+ assertFalse(edf.hasTest(new MaiaBertogna(mock(SystemSetup.class))));
+ assertTrue(edf.hasSimulator(new ParallelSynchronous(mock(SystemSetup.class))));
+ assertTrue(edf.hasSimulator(new DynamicForkJoin(mock(SystemSetup.class))));
+
+ assertTrue(edf.getName().equals("EDF"));
+ }
+
}
diff --git a/src/test/java/mvd/jester/priority/TestRateMonotonic.java b/src/test/java/mvd/jester/priority/TestRateMonotonic.java
index 685039f..b445146 100644
--- a/src/test/java/mvd/jester/priority/TestRateMonotonic.java
+++ b/src/test/java/mvd/jester/priority/TestRateMonotonic.java
@@ -1,12 +1,21 @@
package mvd.jester.priority;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import java.util.HashSet;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import mvd.jester.model.Segment;
+import mvd.jester.model.SystemSetup;
import mvd.jester.model.Task;
-import mvd.jester.simulator.internals.maiabertogna.TaskContext;
+import mvd.jester.simulator.DynamicForkJoin;
+import mvd.jester.simulator.ParallelSynchronous;
+import mvd.jester.simulator.internals.parallelsynchronous.TaskContext;
+import mvd.jester.tests.ChwaLee;
+import mvd.jester.tests.MaiaBertogna;
+import mvd.jester.tests.SchmidMottok;
/**
* TestRateMonotonic
@@ -17,13 +26,41 @@ public class TestRateMonotonic {
@DisplayName("Test if priority manager returns the correct priority.")
public void testPriority() {
RateMonotonic rm = new RateMonotonic();
- Task t1 = new Task(100, new HashSet());
- Task t2 = new Task(200, new HashSet());
+ Task t1 = mock(Task.class);
+ Task t2 = mock(Task.class);
+ when(t1.getPeriod()).thenReturn((long) 100);
+ when(t2.getPeriod()).thenReturn((long) 200);
- TaskContext tc1 = new TaskContext(t1, 0);
- TaskContext tc2 = new TaskContext(t2, 0);
+ TaskContext tc1 = mock(TaskContext.class);
+ TaskContext tc2 = mock(TaskContext.class);
+ when(tc1.getTask()).thenReturn(t1);
+ when(tc2.getTask()).thenReturn(t2);
assertTrue(rm.compare(t1, t2) < 0);
assertTrue(rm.compare(tc1, tc2) < 0);
+ assertTrue(rm.compare(t1, t1) == 0);
+ assertTrue(rm.compare(tc1, tc1) == 0);
+ assertTrue(rm.compare(t2, t1) > 0);
+ assertTrue(rm.compare(tc2, tc1) > 0);
+ }
+
+
+ @Test
+ @DisplayName("Check Tests and Simulators.")
+ void testTestsAndSimulators() {
+ RateMonotonic rm = new RateMonotonic();
+ assertFalse(rm.hasTest(ChwaLee.class));
+ assertTrue(rm.hasTest(MaiaBertogna.class));
+ assertTrue(rm.hasTest(SchmidMottok.class));
+ assertTrue(rm.hasSimulator(ParallelSynchronous.class));
+ assertTrue(rm.hasSimulator(DynamicForkJoin.class));
+
+ assertFalse(rm.hasTest(new ChwaLee(mock(SystemSetup.class))));
+ assertTrue(rm.hasTest(new SchmidMottok(mock(SystemSetup.class))));
+ assertTrue(rm.hasTest(new MaiaBertogna(mock(SystemSetup.class))));
+ assertTrue(rm.hasSimulator(new ParallelSynchronous(mock(SystemSetup.class))));
+ assertTrue(rm.hasSimulator(new DynamicForkJoin(mock(SystemSetup.class))));
+
+ assertTrue(rm.getName().equals("RM"));
}
}
diff --git a/src/test/java/mvd/jester/simulator/TestProcessorContext.java b/src/test/java/mvd/jester/simulator/TestProcessorContext.java
index 0a5a00d..ae9e201 100644
--- a/src/test/java/mvd/jester/simulator/TestProcessorContext.java
+++ b/src/test/java/mvd/jester/simulator/TestProcessorContext.java
@@ -17,8 +17,8 @@ import org.junit.jupiter.api.Test;
import mvd.jester.model.Task;
import mvd.jester.simulator.internals.ProcessorContext;
import mvd.jester.simulator.internals.TaskContextInterface;
-import mvd.jester.simulator.internals.maiabertogna.JobContext;
-import mvd.jester.simulator.internals.maiabertogna.TaskContext;
+import mvd.jester.simulator.internals.parallelsynchronous.JobContext;
+import mvd.jester.simulator.internals.parallelsynchronous.TaskContext;
/**
* TestProcessorContext
diff --git a/src/test/java/mvd/jester/simulator/schmidmottok/TestJobContext.java b/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestJobContext.java
similarity index 94%
rename from src/test/java/mvd/jester/simulator/schmidmottok/TestJobContext.java
rename to src/test/java/mvd/jester/simulator/dynamicforkjoin/TestJobContext.java
index 1f3aa7c..8b97dc6 100644
--- a/src/test/java/mvd/jester/simulator/schmidmottok/TestJobContext.java
+++ b/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestJobContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.schmidmottok;
+package mvd.jester.simulator.dynamicforkjoin;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -14,10 +14,10 @@ import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import mvd.jester.model.Segment;
import mvd.jester.simulator.internals.ProcessorContext;
-import mvd.jester.simulator.internals.schmidmottok.JobContext;
-import mvd.jester.simulator.internals.schmidmottok.SegmentContext;
-import mvd.jester.simulator.internals.schmidmottok.TaskContext;
-import mvd.jester.simulator.internals.schmidmottok.TaskletContext;;
+import mvd.jester.simulator.internals.dynamicforkjoin.JobContext;
+import mvd.jester.simulator.internals.dynamicforkjoin.SegmentContext;
+import mvd.jester.simulator.internals.dynamicforkjoin.TaskContext;
+import mvd.jester.simulator.internals.dynamicforkjoin.TaskletContext;;
/**
* TestJobContext
diff --git a/src/test/java/mvd/jester/simulator/schmidmottok/TestSegmentContext.java b/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestSegmentContext.java
similarity index 94%
rename from src/test/java/mvd/jester/simulator/schmidmottok/TestSegmentContext.java
rename to src/test/java/mvd/jester/simulator/dynamicforkjoin/TestSegmentContext.java
index 3170520..dcb5c72 100644
--- a/src/test/java/mvd/jester/simulator/schmidmottok/TestSegmentContext.java
+++ b/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestSegmentContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.schmidmottok;
+package mvd.jester.simulator.dynamicforkjoin;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -11,10 +11,10 @@ import org.junit.jupiter.api.Test;
import mvd.jester.model.Segment;
import mvd.jester.simulator.internals.JobContextInterface;
import mvd.jester.simulator.internals.ProcessorContext;
-import mvd.jester.simulator.internals.schmidmottok.JobContext;
-import mvd.jester.simulator.internals.schmidmottok.SegmentContext;
-import mvd.jester.simulator.internals.schmidmottok.TaskContext;
-import mvd.jester.simulator.internals.schmidmottok.TaskletContext;
+import mvd.jester.simulator.internals.dynamicforkjoin.JobContext;
+import mvd.jester.simulator.internals.dynamicforkjoin.SegmentContext;
+import mvd.jester.simulator.internals.dynamicforkjoin.TaskContext;
+import mvd.jester.simulator.internals.dynamicforkjoin.TaskletContext;
/**
* TestSegmentContext
diff --git a/src/test/java/mvd/jester/simulator/schmidmottok/TestTaskContext.java b/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskContext.java
similarity index 97%
rename from src/test/java/mvd/jester/simulator/schmidmottok/TestTaskContext.java
rename to src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskContext.java
index badc60c..cffb7dc 100644
--- a/src/test/java/mvd/jester/simulator/schmidmottok/TestTaskContext.java
+++ b/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.schmidmottok;
+package mvd.jester.simulator.dynamicforkjoin;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -14,7 +14,7 @@ import mvd.jester.model.Task;
import mvd.jester.simulator.internals.JobContextInterface;
import mvd.jester.simulator.internals.ProcessorContext;
import mvd.jester.simulator.internals.TaskContextInterface;
-import mvd.jester.simulator.internals.schmidmottok.TaskContext;
+import mvd.jester.simulator.internals.dynamicforkjoin.TaskContext;
/**
* TestTaskContext
diff --git a/src/test/java/mvd/jester/simulator/schmidmottok/TestTaskletContext.java b/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskletContext.java
similarity index 88%
rename from src/test/java/mvd/jester/simulator/schmidmottok/TestTaskletContext.java
rename to src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskletContext.java
index 41b5205..0e34919 100644
--- a/src/test/java/mvd/jester/simulator/schmidmottok/TestTaskletContext.java
+++ b/src/test/java/mvd/jester/simulator/dynamicforkjoin/TestTaskletContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.schmidmottok;
+package mvd.jester.simulator.dynamicforkjoin;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -11,10 +11,10 @@ import java.util.concurrent.ThreadLocalRandom;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import mvd.jester.model.Segment;
-import mvd.jester.simulator.internals.schmidmottok.JobContext;
-import mvd.jester.simulator.internals.schmidmottok.SegmentContext;
-import mvd.jester.simulator.internals.schmidmottok.TaskContext;
-import mvd.jester.simulator.internals.schmidmottok.TaskletContext;
+import mvd.jester.simulator.internals.dynamicforkjoin.JobContext;
+import mvd.jester.simulator.internals.dynamicforkjoin.SegmentContext;
+import mvd.jester.simulator.internals.dynamicforkjoin.TaskContext;
+import mvd.jester.simulator.internals.dynamicforkjoin.TaskletContext;
/**
* TestTaskletContext
diff --git a/src/test/java/mvd/jester/simulator/maiabertogna/TestJobContext.java b/src/test/java/mvd/jester/simulator/parallelsynchronous/TestJobContext.java
similarity index 92%
rename from src/test/java/mvd/jester/simulator/maiabertogna/TestJobContext.java
rename to src/test/java/mvd/jester/simulator/parallelsynchronous/TestJobContext.java
index e65fc4c..e67e1a8 100644
--- a/src/test/java/mvd/jester/simulator/maiabertogna/TestJobContext.java
+++ b/src/test/java/mvd/jester/simulator/parallelsynchronous/TestJobContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.maiabertogna;
+package mvd.jester.simulator.parallelsynchronous;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -15,9 +15,9 @@ import org.junit.jupiter.api.Test;
import mvd.jester.model.Segment;
import mvd.jester.simulator.internals.ProcessorContext;
import mvd.jester.simulator.internals.TaskContextInterface;
-import mvd.jester.simulator.internals.maiabertogna.JobContext;
-import mvd.jester.simulator.internals.maiabertogna.SegmentContext;
-import mvd.jester.simulator.internals.maiabertogna.TaskContext;
+import mvd.jester.simulator.internals.parallelsynchronous.JobContext;
+import mvd.jester.simulator.internals.parallelsynchronous.SegmentContext;
+import mvd.jester.simulator.internals.parallelsynchronous.TaskContext;
/**
* TestJobContext
diff --git a/src/test/java/mvd/jester/simulator/maiabertogna/TestSegmentContext.java b/src/test/java/mvd/jester/simulator/parallelsynchronous/TestSegmentContext.java
similarity index 93%
rename from src/test/java/mvd/jester/simulator/maiabertogna/TestSegmentContext.java
rename to src/test/java/mvd/jester/simulator/parallelsynchronous/TestSegmentContext.java
index f93e707..2cce377 100644
--- a/src/test/java/mvd/jester/simulator/maiabertogna/TestSegmentContext.java
+++ b/src/test/java/mvd/jester/simulator/parallelsynchronous/TestSegmentContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.maiabertogna;
+package mvd.jester.simulator.parallelsynchronous;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -10,8 +10,8 @@ import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import mvd.jester.model.Segment;
import mvd.jester.simulator.internals.JobContextInterface;
-import mvd.jester.simulator.internals.maiabertogna.SegmentContext;
-import mvd.jester.simulator.internals.maiabertogna.TaskContext;
+import mvd.jester.simulator.internals.parallelsynchronous.SegmentContext;
+import mvd.jester.simulator.internals.parallelsynchronous.TaskContext;
import mvd.jester.simulator.internals.ProcessorContext;
/**
diff --git a/src/test/java/mvd/jester/simulator/maiabertogna/TestTaskContext.java b/src/test/java/mvd/jester/simulator/parallelsynchronous/TestTaskContext.java
similarity index 97%
rename from src/test/java/mvd/jester/simulator/maiabertogna/TestTaskContext.java
rename to src/test/java/mvd/jester/simulator/parallelsynchronous/TestTaskContext.java
index 1d04a6f..e2e75f2 100644
--- a/src/test/java/mvd/jester/simulator/maiabertogna/TestTaskContext.java
+++ b/src/test/java/mvd/jester/simulator/parallelsynchronous/TestTaskContext.java
@@ -1,4 +1,4 @@
-package mvd.jester.simulator.maiabertogna;
+package mvd.jester.simulator.parallelsynchronous;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -14,7 +14,7 @@ import mvd.jester.model.Task;
import mvd.jester.simulator.internals.JobContextInterface;
import mvd.jester.simulator.internals.ProcessorContext;
import mvd.jester.simulator.internals.TaskContextInterface;
-import mvd.jester.simulator.internals.maiabertogna.TaskContext;
+import mvd.jester.simulator.internals.parallelsynchronous.TaskContext;
/**
* TestTaskContext
diff --git a/src/test/java/mvd/jester/tests/TestMaiaBertogna.java b/src/test/java/mvd/jester/tests/TestMaiaBertogna.java
index 50bf7b5..39fa332 100644
--- a/src/test/java/mvd/jester/tests/TestMaiaBertogna.java
+++ b/src/test/java/mvd/jester/tests/TestMaiaBertogna.java
@@ -1,8 +1,12 @@
package mvd.jester.tests;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import mvd.jester.info.SchedulingInfo;
+import mvd.jester.info.TerminationInfo.Level;
import mvd.jester.model.SystemSetup;
+import mvd.jester.priority.RateMonotonic;
/**
* TestMaiaBertogna
@@ -12,7 +16,41 @@ public class TestMaiaBertogna {
@Test
@DisplayName("Check if the schedulability check returns the correct values.")
public void testRunSchedulabilityCheck() {
- SystemSetup systemSetup = SystemSetup.readFromFile("/resources/Taskset1.txt", 0);
- MaiaBertogna mb = new MaiaBertogna(systemSetup);
+ {
+ SystemSetup systemSetup =
+ SystemSetup.readFromFile("src/test/resources/Taskset1.txt", 4);
+ MaiaBertogna mb = new MaiaBertogna(systemSetup);
+
+ SchedulingInfo schedulingInfo = mb.runSchedulabilityCheck(new RateMonotonic());
+
+ assertTrue(schedulingInfo.getTerminationInfos().size() == 4);
+ assertTrue(schedulingInfo.checkLevelFail(Level.HIGH) == true);
+ assertTrue(schedulingInfo.checkTasksetFeasible() == false);
+ assertTrue(schedulingInfo.getFailedTerminationInfo().isPresent());
+ }
+ {
+ SystemSetup systemSetup =
+ SystemSetup.readFromFile("src/test/resources/Taskset1.txt", 8);
+ MaiaBertogna mb = new MaiaBertogna(systemSetup);
+
+ SchedulingInfo schedulingInfo = mb.runSchedulabilityCheck(new RateMonotonic());
+
+ assertTrue(schedulingInfo.getTerminationInfos().size() == 4);
+ assertTrue(schedulingInfo.checkLevelFail(Level.HIGH) == true);
+ assertTrue(schedulingInfo.checkTasksetFeasible() == false);
+ assertTrue(schedulingInfo.getFailedTerminationInfo().isPresent());
+ }
+ {
+ SystemSetup systemSetup =
+ SystemSetup.readFromFile("src/test/resources/Taskset1.txt", 16);
+ MaiaBertogna mb = new MaiaBertogna(systemSetup);
+
+ SchedulingInfo schedulingInfo = mb.runSchedulabilityCheck(new RateMonotonic());
+
+ assertTrue(schedulingInfo.getTerminationInfos().size() == 4);
+ assertTrue(schedulingInfo.checkLevelFail(Level.HIGH) == false);
+ assertTrue(schedulingInfo.checkTasksetFeasible() == true);
+ assertTrue(!schedulingInfo.getFailedTerminationInfo().isPresent());
+ }
}
}
diff --git a/src/test/java/mvd/jester/tests/TestSchmidMottok.java b/src/test/java/mvd/jester/tests/TestSchmidMottok.java
new file mode 100644
index 0000000..a0261a9
--- /dev/null
+++ b/src/test/java/mvd/jester/tests/TestSchmidMottok.java
@@ -0,0 +1,57 @@
+
+package mvd.jester.tests;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import mvd.jester.info.SchedulingInfo;
+import mvd.jester.info.TerminationInfo.Level;
+import mvd.jester.model.SystemSetup;
+import mvd.jester.priority.RateMonotonic;
+
+/**
+ * TestSchmidMottok
+ */
+public class TestSchmidMottok {
+
+ @Test
+ @DisplayName("Check if the schedulability check returns the correct values.")
+ public void testRunSchedulabilityCheck() {
+ {
+ SystemSetup systemSetup =
+ SystemSetup.readFromFile("src/test/resources/Taskset1.txt", 4);
+ MaiaBertogna mb = new MaiaBertogna(systemSetup);
+
+ SchedulingInfo schedulingInfo = mb.runSchedulabilityCheck(new RateMonotonic());
+
+ assertTrue(schedulingInfo.getTerminationInfos().size() == 4);
+ assertTrue(schedulingInfo.checkLevelFail(Level.HIGH) == true);
+ assertTrue(schedulingInfo.checkTasksetFeasible() == false);
+ assertTrue(schedulingInfo.getFailedTerminationInfo().isPresent());
+ }
+ {
+ SystemSetup systemSetup =
+ SystemSetup.readFromFile("src/test/resources/Taskset1.txt", 8);
+ MaiaBertogna mb = new MaiaBertogna(systemSetup);
+
+ SchedulingInfo schedulingInfo = mb.runSchedulabilityCheck(new RateMonotonic());
+
+ assertTrue(schedulingInfo.getTerminationInfos().size() == 4);
+ assertTrue(schedulingInfo.checkLevelFail(Level.HIGH) == true);
+ assertTrue(schedulingInfo.checkTasksetFeasible() == false);
+ assertTrue(schedulingInfo.getFailedTerminationInfo().isPresent());
+ }
+ {
+ SystemSetup systemSetup =
+ SystemSetup.readFromFile("src/test/resources/Taskset1.txt", 16);
+ MaiaBertogna mb = new MaiaBertogna(systemSetup);
+
+ SchedulingInfo schedulingInfo = mb.runSchedulabilityCheck(new RateMonotonic());
+
+ assertTrue(schedulingInfo.getTerminationInfos().size() == 4);
+ assertTrue(schedulingInfo.checkLevelFail(Level.HIGH) == false);
+ assertTrue(schedulingInfo.checkTasksetFeasible() == true);
+ assertTrue(!schedulingInfo.getFailedTerminationInfo().isPresent());
+ }
+ }
+}