diff --git a/src/test/java/mvd/jester/priority/TestRateMonotonic.java b/src/test/java/mvd/jester/priority/TestRateMonotonic.java index b445146..216d888 100644 --- a/src/test/java/mvd/jester/priority/TestRateMonotonic.java +++ b/src/test/java/mvd/jester/priority/TestRateMonotonic.java @@ -4,10 +4,8 @@ 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.DynamicForkJoin; diff --git a/src/test/java/mvd/jester/tests/TestChwaLee.java b/src/test/java/mvd/jester/tests/TestChwaLee.java new file mode 100644 index 0000000..5be6a9f --- /dev/null +++ b/src/test/java/mvd/jester/tests/TestChwaLee.java @@ -0,0 +1,56 @@ +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.EarliestDeadlineFirst; + +/** + * TestChwaLee + */ +public class TestChwaLee { + + @Test + @DisplayName("Check if the schedulability check returns the correct values.") + public void testRunSchedulabilityCheck() { + { + SystemSetup systemSetup = + SystemSetup.readFromFile("src/test/resources/Taskset1.txt", 4); + ChwaLee cl = new ChwaLee(systemSetup); + + SchedulingInfo schedulingInfo = cl.runSchedulabilityCheck(new EarliestDeadlineFirst()); + + 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); + ChwaLee cl = new ChwaLee(systemSetup); + + SchedulingInfo schedulingInfo = cl.runSchedulabilityCheck(new EarliestDeadlineFirst()); + + 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); + ChwaLee cl = new ChwaLee(systemSetup); + + SchedulingInfo schedulingInfo = cl.runSchedulabilityCheck(new EarliestDeadlineFirst()); + + assertTrue(schedulingInfo.getTerminationInfos().size() == 4); + assertTrue(schedulingInfo.checkLevelFail(Level.HIGH) == true); + assertTrue(schedulingInfo.checkTasksetFeasible() == false); + assertTrue(schedulingInfo.getFailedTerminationInfo().isPresent()); + } + } +} diff --git a/src/test/java/mvd/jester/tests/TestSchmidMottok.java b/src/test/java/mvd/jester/tests/TestSchmidMottok.java index a0261a9..ba2e712 100644 --- a/src/test/java/mvd/jester/tests/TestSchmidMottok.java +++ b/src/test/java/mvd/jester/tests/TestSchmidMottok.java @@ -20,9 +20,9 @@ public class TestSchmidMottok { { SystemSetup systemSetup = SystemSetup.readFromFile("src/test/resources/Taskset1.txt", 4); - MaiaBertogna mb = new MaiaBertogna(systemSetup); + SchmidMottok sm = new SchmidMottok(systemSetup); - SchedulingInfo schedulingInfo = mb.runSchedulabilityCheck(new RateMonotonic()); + SchedulingInfo schedulingInfo = sm.runSchedulabilityCheck(new RateMonotonic()); assertTrue(schedulingInfo.getTerminationInfos().size() == 4); assertTrue(schedulingInfo.checkLevelFail(Level.HIGH) == true); @@ -32,9 +32,9 @@ public class TestSchmidMottok { { SystemSetup systemSetup = SystemSetup.readFromFile("src/test/resources/Taskset1.txt", 8); - MaiaBertogna mb = new MaiaBertogna(systemSetup); + SchmidMottok sm = new SchmidMottok(systemSetup); - SchedulingInfo schedulingInfo = mb.runSchedulabilityCheck(new RateMonotonic()); + SchedulingInfo schedulingInfo = sm.runSchedulabilityCheck(new RateMonotonic()); assertTrue(schedulingInfo.getTerminationInfos().size() == 4); assertTrue(schedulingInfo.checkLevelFail(Level.HIGH) == true); @@ -44,9 +44,9 @@ public class TestSchmidMottok { { SystemSetup systemSetup = SystemSetup.readFromFile("src/test/resources/Taskset1.txt", 16); - MaiaBertogna mb = new MaiaBertogna(systemSetup); + SchmidMottok sm = new SchmidMottok(systemSetup); - SchedulingInfo schedulingInfo = mb.runSchedulabilityCheck(new RateMonotonic()); + SchedulingInfo schedulingInfo = sm.runSchedulabilityCheck(new RateMonotonic()); assertTrue(schedulingInfo.getTerminationInfos().size() == 4); assertTrue(schedulingInfo.checkLevelFail(Level.HIGH) == false); diff --git a/src/test/java/mvd/jester/utils/TestLogger.java b/src/test/java/mvd/jester/utils/TestLogger.java new file mode 100644 index 0000000..f72d5e8 --- /dev/null +++ b/src/test/java/mvd/jester/utils/TestLogger.java @@ -0,0 +1,45 @@ +package mvd.jester.utils; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import com.google.common.io.Files; +import org.junit.Rule; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.junit.rules.TemporaryFolder; + + +/** + * TestLogger + */ +public class TestLogger { + + @TempDir + File tempDir; + + @Test + @DisplayName("CHeck Logger") + void testLogger() throws IOException { + String fileName = tempDir.getAbsolutePath() + "/test.txt"; + Logger logger = new Logger(fileName); + Logger failedLogger = new Logger(fileName); + + Appendable out = new StringBuilder(); + + out.append("abc"); + out.append("efg"); + + logger.log(out); + + logger.finalize(); + failedLogger.finalize(); + + + + } +}