TaskSetTest.java 1.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
package mvd.jester.model;

import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;


public class TaskSetTest {

    private static final int NUMBER_OF_SETS = 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.Generator().build();

            for (Task t : taskSet.getTasks()) {
                assertTrue(t.getPeriod() >= 100);
                assertTrue(t.getPeriod() <= 1000);
                assertTrue(t.getDeadline() == t.getPeriod());

                long maxJobWcet = t.getPeriod() / t.getSegments().size();

                for (Segment s : t.getSegments()) {
                    assertTrue(s.getJobWcet() * s.getNumberOfJobs() == s.getTaskletWcet()
                            * s.getNumberOfTasklets());
                    assertTrue(s.getJobWcet() >= 1);
                    assertTrue(s.getJobWcet() <= maxJobWcet);
                    assertTrue(s.getNumberOfJobs() >= 1);
                    assertTrue(s.getNumberOfJobs() <= 6);
                }

                assertTrue(t.getSegments().size() >= 1);
                assertTrue(t.getSegments().size() <= 5);
            }
        }

    }
}