Commit 12cb1c2b authored by apvrille's avatar apvrille

Resolving bug on dsez3 button

parent 56f6d1c6
......@@ -25,6 +25,7 @@
<root url="jar://$PROJECT_DIR$/libs/batik-util.jar!/" />
<root url="jar://$PROJECT_DIR$/libs/batik-xml.jar!/" />
<root url="jar://$PROJECT_DIR$/libs/jautomata-core.jar!/" />
<root url="jar://$PROJECT_DIR$/libs/com.microsoft.z3.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$PROJECT_DIR$/libs/commons-io-2.5-javadoc.jar!/" />
......
......@@ -7,6 +7,7 @@ TAR = tar
GZIP = gzip
GRADLE_NO_TEST = -x test
GRADLE_OPTIONS = --parallel
#GRADLE_OPTIONS =
GRADLE = $(shell which gradle)
GRADLE_VERSION_NEEDED = 3.3
ERROR_MSG = printf "$(COLOR)\nBuild with gradle failed. Falling back to regular javac command...\n$(RESET)"
......
......@@ -323,7 +323,9 @@ public class JToolBarMainTurtle extends JToolBar implements ActionListener
//TraceManager.addDev("Show avatar options with b = " + b);
dse.setVisible(!b);
dseZ3.setVisible(!b);
if (dseZ3 != null) {
dseZ3.setVisible(!b);
}
avatarSimu.setVisible(b);
avatarFVUPPAAL.setVisible(b);
......@@ -401,7 +403,9 @@ public class JToolBarMainTurtle extends JToolBar implements ActionListener
//TraceManager.addDev("Show diplodocus options with b = " + b);
dse.setVisible(b);
dseZ3.setVisible(b);
if (dseZ3 != null) {
dseZ3.setVisible(b);
}
avatarSimu.setVisible(!b);
avatarFVUPPAAL.setVisible(!b);
avatarFVStaticAnalysis.setVisible(!b);
......
......@@ -405,6 +405,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per
//} catch (Exception e) { ErrorGUI.exit(ErrorGUI.GUI);}
// Creating main container
frame = new JFrame("TTool");
frame.addWindowListener(this);
......@@ -503,6 +504,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per
// statusBar
status = createStatusBar();
// Mouse handler
mouseHandler = new MouseHandler(status);
......@@ -515,6 +517,7 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener, Per
// Panels
panelForTab = new JPanel();
panelForTab.setLayout(new BorderLayout());
//panelForTree = new JPanel(); panelForTree.setLayout(new BorderLayout());
// Tree
dtree = new JDiagramTree(this);
......
......@@ -165,11 +165,11 @@ public class TToolCLI implements InterpreterOutputInterface {
cli.print("Loading script:" + getInputFile(args));
// Load script file
File f = new File(getInputFile(args));
if (!FileUtils.checkFileForOpen(f)) {
if (!myutil.FileUtils.checkFileForOpen(f)) {
cli.printError("File " + f.getAbsolutePath() + " could not be opened.");
cli.exit(-1);
}
script = FileUtils.loadFileData(f);
script = myutil.FileUtils.loadFileData(f);
}
}
......
......@@ -55,3 +55,7 @@ jar {
}
mainClassName = 'Main'
test {
testLogging.showStandardStreams = true
}
package tmltranslator.dsez3engine;
import com.microsoft.z3.*;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import tmltranslator.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import myutil.TraceManager;
import static org.junit.Assert.*;
public class InputInstanceTest {
public TMLArchitecture tmla;
public TMLModeling tmlm;
public InputInstance inputInstance;
public OptimizationModel optimizationModel;
@Before
public void setUpTest() {
tmla = setUpTMLArchitecture();
tmlm = setUpTMLModeling();
inputInstance = new InputInstance(tmla, tmlm);
optimizationModel = new OptimizationModel(inputInstance);
}
private TMLModeling setUpTMLModeling() {
tmlm = new TMLModeling();
TMLTask taskA = new TMLTask("task__A", null, null);
TMLTask taskB = new TMLTask("task__B", null, null);
TMLTask taskD = new TMLTask("task__D", null, null);
TMLTask taskE = new TMLTask("task__E", null, null);
//filling activity diagrams of tasks
//taskA
TMLActivityElementWithAction firstA = new TMLExecI("execiA", null);
firstA.setAction("150");
taskA.getActivityDiagram().setFirst(firstA);
TMLActivityElement AwB = new TMLWriteChannel("AwB", null);
taskA.getActivityDiagram().addLinkElement(firstA, AwB);
taskA.getActivityDiagram().addElement(AwB);
TMLActivityElement AwD = new TMLWriteChannel("AwD", null);
taskA.getActivityDiagram().addLinkElement(AwB, AwD);
taskA.getActivityDiagram().addElement(AwD);
//taskB
TMLActivityElement firstB = new TMLReadChannel("BrA", null);
taskB.getActivityDiagram().setFirst(firstB);
TMLActivityElementWithAction execiB = new TMLExecI("execiB", null);
execiB.setAction("100");
taskB.getActivityDiagram().addLinkElement(firstB, execiB);
taskB.getActivityDiagram().addElement(execiB);
TMLActivityElement BwE = new TMLWriteChannel("BwE", null);
taskB.getActivityDiagram().addLinkElement(execiB, BwE);
taskB.getActivityDiagram().addElement(BwE);
//taskD
TMLActivityElement firstD = new TMLReadChannel("DrA", null);
taskD.getActivityDiagram().setFirst(firstD);
TMLActivityElementWithAction execiD = new TMLExecI("execiD", null);
execiD.setAction("100");
taskD.getActivityDiagram().addLinkElement(firstD, execiD);
taskD.getActivityDiagram().addElement(execiD);
TMLActivityElement DwE = new TMLWriteChannel("DwE", null);
taskD.getActivityDiagram().addLinkElement(execiD, DwE);
taskD.getActivityDiagram().addElement(DwE);
//taskE
TMLActivityElement firstE = new TMLReadChannel("ErB", null);
taskE.getActivityDiagram().setFirst(firstE);
TMLActivityElement ErD = new TMLReadChannel("ErD", null);
taskE.getActivityDiagram().addLinkElement(firstE, ErD);
taskE.getActivityDiagram().addElement(ErD);
TMLActivityElementWithAction execiE = new TMLExecI("execiE", null);
execiE.setAction("50");
taskE.getActivityDiagram().addLinkElement(ErD, execiE);
taskE.getActivityDiagram().addElement(execiE);
taskA.addOperation("generic");
taskB.addOperation("fft");
taskD.addOperation("fft");
taskE.addOperation("generic");
//creating channels
TMLChannel ab = new TMLChannel("ab", null);
TMLChannel ad = new TMLChannel("ad", null);
TMLChannel be = new TMLChannel("be", null);
TMLChannel de = new TMLChannel("de", null);
taskA.addWriteTMLChannel(ab);
taskA.addWriteTMLChannel(ad);
taskB.addReadTMLChannel(ab);
taskB.addWriteTMLChannel(be);
taskD.addReadTMLChannel(ad);
taskD.addWriteTMLChannel(de);
taskE.addReadTMLChannel(be);
taskE.addReadTMLChannel(de);
ab.setTasks(taskA, taskB);
ad.setTasks(taskA, taskD);
be.setTasks(taskB, taskE);
de.setTasks(taskD, taskE);
ab.setNumberOfSamples(2);
ad.setNumberOfSamples(2);
be.setNumberOfSamples(5);
de.setNumberOfSamples(5);
tmlm.addTask(taskA);
tmlm.addTask(taskB);
tmlm.addTask(taskD);
tmlm.addTask(taskE);
tmlm.addChannel(ab);
tmlm.addChannel(ad);
tmlm.addChannel(be);
tmlm.addChannel(de);
return tmlm;
}
private TMLArchitecture setUpTMLArchitecture() {
HwExecutionNode mainCPU = new HwCPU("MainCPU");
HwMemory mainMem = new HwMemory("mainMem");
HwExecutionNode dsp = new HwCPU("dsp");
HwMemory dspMem = new HwMemory("dspMem");
HwBus bus0 = new HwBus("bus0");
HwBus bus1 = new HwBus("bus1");
HwLink maincpu_bus0 = new HwLink("maincpu_bus0");
HwLink bus0_cpumem = new HwLink("bus0_cpumem");
HwLink dsp_bus1 = new HwLink("dsp_bus1");
HwLink bus1_dspmem = new HwLink("bus1_dspmem");
mainCPU.execiTime = 2;
dsp.execiTime = 1;
mainCPU.addOperationType("generic");
mainCPU.addOperationType("fft");
mainMem.memorySize = 200;
dsp.addOperationType("fft");
dspMem.memorySize = 100;
maincpu_bus0.hwnode = mainCPU;
maincpu_bus0.bus = bus0;
bus0_cpumem.bus = bus0;
bus0_cpumem.hwnode = mainMem;
dsp_bus1.hwnode = dsp;
dsp_bus1.bus = bus1;
bus1_dspmem.bus = bus1;
bus1_dspmem.hwnode = dspMem;
tmla = new TMLArchitecture();
tmla.addHwNode(mainCPU);
tmla.addHwNode(dsp);
tmla.addHwNode(mainMem);
tmla.addHwNode(dspMem);
tmla.addHwNode(bus0);
tmla.addHwNode(bus1);
tmla.addHwLink(maincpu_bus0);
tmla.addHwLink(bus0_cpumem);
tmla.addHwLink(dsp_bus1);
tmla.addHwLink(bus1_dspmem);
return tmla;
}
@Test
public void findOptimizedMapping() {
try {
// These examples need model generation turned on.
HashMap<String, String> cfg = new HashMap<String, String>();
cfg.put("model", "true");
Context ctx = new Context(cfg);
optimizationModel.findOptimizedMapping(ctx);
Log.close();
if (Log.isOpen())
TraceManager.addDev("Log is still open!");
} catch (Z3Exception ex) {
TraceManager.addDev("Z3 Managed Exception: " + ex.getMessage());
TraceManager.addDev("Stack trace: ");
ex.printStackTrace(
System.out);
} catch (OptimizationModel.TestFailedException ex) {
TraceManager.addDev("TEST CASE FAILED: " + ex.getMessage());
TraceManager.addDev("Stack trace: ");
ex.printStackTrace(System.out);
} catch (Exception ex) {
TraceManager.addDev("Unknown Exception: " + ex.getMessage());
TraceManager.addDev("Stack trace: ");
ex.printStackTrace(System.out);
}
assertEquals(1, optimizationModel.getOptimizedSolutionX().get("X[task__A][MainCPU] = ").intValue());
assertEquals(0, optimizationModel.getOptimizedSolutionX().get("X[task__A][dsp] = ").intValue());
assertEquals(0, optimizationModel.getOptimizedSolutionX().get("X[task__B][MainCPU] = ").intValue());
assertEquals(1, optimizationModel.getOptimizedSolutionX().get("X[task__B][dsp] = ").intValue());
assertEquals(0, optimizationModel.getOptimizedSolutionX().get("X[task__D][MainCPU] = ").intValue());
assertEquals(1, optimizationModel.getOptimizedSolutionX().get("X[task__D][dsp] = ").intValue());
assertEquals(1, optimizationModel.getOptimizedSolutionX().get("X[task__E][MainCPU] = ").intValue());
assertEquals(0, optimizationModel.getOptimizedSolutionX().get("X[task__E][dsp] = ").intValue());
assertEquals(0, optimizationModel.getOptimizedSolutionStart().get("start[task__A] = ").intValue());
assertEquals(300, optimizationModel.getOptimizedSolutionStart().get("start[task__B] = ").intValue());
assertEquals(400, optimizationModel.getOptimizedSolutionStart().get("start[task__D] = ").intValue());
assertEquals(500, optimizationModel.getOptimizedSolutionStart().get("start[task__E] = ").intValue());
}
@Test
public void findFeasibleMapping() {
try {
// These examples need model generation turned on.
HashMap<String, String> cfg = new HashMap<String, String>();
cfg.put("model", "true");
Context ctx = new Context(cfg);
optimizationModel.findFeasibleMapping(ctx);
Log.close();
if (Log.isOpen())
TraceManager.addDev("Log is still open!");
} catch (Z3Exception ex) {
TraceManager.addDev("Z3 Managed Exception: " + ex.getMessage());
TraceManager.addDev("Stack trace: ");
ex.printStackTrace(
System.out);
} catch (OptimizationModel.TestFailedException ex) {
TraceManager.addDev("TEST CASE FAILED: " + ex.getMessage());
TraceManager.addDev("Stack trace: ");
ex.printStackTrace(System.out);
} catch (Exception ex) {
TraceManager.addDev("Unknown Exception: " + ex.getMessage());
TraceManager.addDev("Stack trace: ");
ex.printStackTrace(System.out);
}
}
@Test
public void getFeasibleCPUs() {
Boolean test = false;
List <HwExecutionNode> expectedList = new ArrayList<>();
expectedList.add(inputInstance.getArchitecture().getHwCPUByName("MainCPU"));
expectedList.add(inputInstance.getArchitecture().getHwCPUByName("dsp"));
TMLTask tempTask = (TMLTask) inputInstance.getModeling().getTasks().get(2);
List<HwExecutionNode> actualList = new ArrayList<>();
for (int i = 0; i < inputInstance.getFeasibleCPUs(tempTask).size(); i++) {
actualList.add(inputInstance.getFeasibleCPUs(tempTask).get(i));
}
assertEquals(actualList.size(), expectedList.size());
for (HwExecutionNode hwExecutionNode : actualList){
assertTrue(expectedList.contains(hwExecutionNode));
}
}
@Test
public void getBufferIn() {
List<TMLTask> tempTasks = new ArrayList<>();
for (int i = 0; i < inputInstance.getModeling().getTasks().size(); i++) {
tempTasks.add((TMLTask) inputInstance.getModeling().getTasks().get(i));
}
assertEquals(inputInstance.getBufferIn( tempTasks.get(0)), 0);
assertEquals(inputInstance.getBufferIn( tempTasks.get(1)), 2);
assertEquals(inputInstance.getBufferIn( tempTasks.get(2)), 2);
assertEquals(inputInstance.getBufferIn(tempTasks.get(3)), 10);
}
@Test
public void getBufferOut() {
List<TMLTask> tempTasks = new ArrayList<>();
for (int i = 0; i < inputInstance.getModeling().getTasks().size(); i++) {
tempTasks.add((TMLTask) inputInstance.getModeling().getTasks().get(i));
}
assertEquals(inputInstance.getBufferOut( tempTasks.get(0)), 4);
assertEquals(inputInstance.getBufferOut( tempTasks.get(1)), 5);
assertEquals(inputInstance.getBufferOut( tempTasks.get(2)), 5);
assertEquals(inputInstance.getBufferOut( tempTasks.get(3)), 0);
}
@Test
public void getLocalMemoryOfHwExecutionNode() {
HwNode output1 = inputInstance.getArchitecture().getHwMemoryByName("mainMem");
HwNode output2 = inputInstance.getArchitecture().getHwMemoryByName("dspMem");
assertTrue("comparing between the expected local memory for main_CPU and the memory found", inputInstance.getLocalMemoryOfHwExecutionNode(inputInstance.getArchitecture().getHwNodeByName("MainCPU")) == output1);
assertTrue("comparing between the expected local memory for DSP and the memory found", inputInstance.getLocalMemoryOfHwExecutionNode(inputInstance.getArchitecture().getHwNodeByName("dsp")) == output2);
}
@Test
public void getWCET() {
//a temporary list of the tasks
List<TMLTask> tempTasks = new ArrayList<>();
for (int i = 0; i < inputInstance.getModeling().getTasks().size(); i++) {
tempTasks.add((TMLTask) inputInstance.getModeling().getTasks().get(i));
}
int expectedWcetA_CPU = 300;
int expectedWcetA_dsp = 150;
assertEquals("comparing between the expected WCET of task A on main_CPU and the computed value", expectedWcetA_CPU, inputInstance.getWCET(tempTasks.get(0), (HwExecutionNode) inputInstance.getArchitecture().getHwNodeByName("MainCPU")));
assertEquals("comparing between the expected WCET of task A on DSP and the computed value", expectedWcetA_dsp, inputInstance.getWCET(tempTasks.get(0), (HwExecutionNode) inputInstance.getArchitecture().getHwNodeByName("dsp")));
}
@Test
public void getFinalTask() {
assertEquals("checking the last task", inputInstance.getModeling().getTMLTaskByName("task__E"), inputInstance.getFinalTask(inputInstance.getModeling()));
}
}
\ No newline at end of file
......@@ -6,21 +6,30 @@ import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.logging.Logger;
import myutil.PluginManager;
import test.AbstractTest;
public abstract class AbstractUITest extends AbstractTest {
protected final MainGUI mainGUI;
protected MainGUI mainGUI = null;
protected AbstractUITest() {
// DB: Not needed for tests (causes NPE)
//IconManager.loadImg();
mainGUI = new MainGUI(false,false, false, false, false, false, false, false, false, false, true, false, false);
mainGUI.build();
PluginManager.pluginManager = new PluginManager();
System.out.println("Creating main Window");
mainGUI = new MainGUI(false, false, false, false, false, false, false, false, false, false, true, false, false);
System.out.println("Main Window new done");
mainGUI.build();
System.out.println("Main Window build done");
PluginManager.pluginManager = new PluginManager();
System.out.println("Main Window created");
}
protected void openModel( final String fileName ) {
......
......@@ -42,6 +42,7 @@ public class TestAvatarDesignPanelTranslator extends AbstractUITest {
public TestAvatarDesignPanelTranslator() {
super();
System.out.println("Test before super");
}
private AvatarSpecification translateDiagramToAvatar( final String diagramName )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment