diff --git a/ttool/src/test/java/tmltranslator/HTMLParseTest.java b/ttool/src/test/java/tmltranslator/HTMLParseTest.java index 1927c9508ff3853aa67c722fc32f4b886b21a0e3..db08ae7908823d77adcf5699106de37495aa6005 100644 --- a/ttool/src/test/java/tmltranslator/HTMLParseTest.java +++ b/ttool/src/test/java/tmltranslator/HTMLParseTest.java @@ -34,7 +34,6 @@ public class HTMLParseTest extends AbstractUITest { final String [] PARSE_FPGA = {"<- idle 195 ->","<- idle 358 ->", "<- idle 204 ->", "<- idle 351 ->", "<- idle 85 ->"}; final String [] PARSE_SINGLE_CORE = {"<- idle 366 ->", "<- idle 401 ->", "<- idle 401 ->", "<- idle 401 ->", "<- idle 401 ->"}; final String [] PARSE_MULTI_CORE = { "", "", "<- idle 374 ->", "<- idle 401 ->", "<- idle 401 ->"}; - final String [] PARSE_FPGA_REMOVEALL = {"<- idle 355 ->", "<- idle 355 ->", "<- idle 355 ->"}; final static String EXPECTED_FILE_GET_ALL_TRANS = getBaseResourcesDir() + "tmltranslator/expected/expected_get_all_transactions.txt"; private String SIM_DIR; @BeforeClass @@ -398,151 +397,4 @@ public class HTMLParseTest extends AbstractUITest { } } - @Test - public void testRemoveAllTransactions() throws Exception { - for (int i = 0; i < 1; i++) { - String s = MODELS_PARSE_HTML[i]; - SIM_DIR = DIR_GEN + s + "_rmat/"; - System.out.println("executing: checking syntax " + s); - // select architecture tab - mainGUI.openProjectFromFile(new File(RESOURCES_DIR + s + ".xml")); - for(TURTLEPanel _tab : mainGUI.getTabs()) { - if(_tab instanceof TMLArchiPanel) { - for (TDiagramPanel tdp : _tab.getPanels()) { - if (tdp instanceof TMLArchiDiagramPanel) { - mainGUI.selectTab(tdp); - break; - } - } - break; - } - } - mainGUI.checkModelingSyntax(true); - TMLMapping tmap = mainGUI.gtm.getTMLMapping(); - TMLSyntaxChecking syntax = new TMLSyntaxChecking(tmap); - syntax.checkSyntax(); - assertTrue(syntax.hasErrors() == 0); - // Generate SystemC code - System.out.println("executing: sim code gen for " + s); - final IDiploSimulatorCodeGenerator tml2systc; - List<EBRDD> al = new ArrayList<EBRDD>(); - List<TEPE> alTepe = new ArrayList<TEPE>(); - tml2systc = DiploSimulatorFactory.INSTANCE.createCodeGenerator(tmap, al, alTepe); - tml2systc.setModelName(s); - String error = tml2systc.generateSystemC(false, true); - assertTrue(error == null); - - File directory = new File(SIM_DIR); - if (!directory.exists()) { - directory.mkdirs(); - } - - // Putting sim files - System.out.println("SIM executing: sim lib code copying for " + s); - ConfigurationTTool.SystemCCodeDirectory = getBaseResourcesDir() + "../../../../simulators/c++2/"; - boolean simFiles = SpecConfigTTool.checkAndCreateSystemCDir(SIM_DIR); - - System.out.println("SIM executing: sim lib code copying done with result " + simFiles); - assertTrue(simFiles); - - System.out.println("SIM Saving file in: " + SIM_DIR); - tml2systc.saveFile(SIM_DIR, "appmodel"); - - // Compile it - System.out.println("executing: compile"); - Process proc; - BufferedReader proc_in; - String str; - boolean mustRecompileAll; - Penalties penalty = new Penalties(SIM_DIR + "src_simulator"); - int changed = penalty.handlePenalties(false); - - if (changed == 1) { - mustRecompileAll = true; - } else { - mustRecompileAll = false; - } - - if (mustRecompileAll) { - System.out.println("executing: " + "make -C " + SIM_DIR + " clean"); - try { - proc = Runtime.getRuntime().exec("make -C " + SIM_DIR + " clean"); - proc_in = new BufferedReader(new InputStreamReader(proc.getInputStream())); - while ((str = proc_in.readLine()) != null) { - // TraceManager.addDev( "Sending " + str + " from " + port + " to client..." ); - System.out.println("executing: " + str); - } - } catch (Exception e) { - // probably make is not installed - System.out.println("FAILED: executing: " + "make -C " + SIM_DIR + " clean"); - return; - } - } - - System.out.println("executing: " + "make -C " + SIM_DIR); - try { - - proc = Runtime.getRuntime().exec("make -C " + SIM_DIR + ""); - proc_in = new BufferedReader(new InputStreamReader(proc.getInputStream())); - - monitorError(proc); - - while ((str = proc_in.readLine()) != null) { - // TraceManager.addDev( "Sending " + str + " from " + port + " to client..." ); - System.out.println("executing: " + str); - } - } catch (Exception e) { - // Probably make is not installed - System.out.println("FAILED: executing: " + "make -C " + SIM_DIR); - return; - } - System.out.println("SUCCESS: executing: " + "make -C " + SIM_DIR); - - // Run the simulator - String graphPath = SIM_DIR + "testgraph_" + s; - try { - - String[] params = new String[3]; - - params[0] = "./" + SIM_DIR + "run.x"; - params[1] = "-cmd"; - params[2] = "26 1;1 6 100; 26 1;22 100; 1 6 100; 7 1 " + graphPath +".html"; - proc = Runtime.getRuntime().exec(params); - //proc = Runtime.getRuntime().exec("./" + SIM_DIR + "run.x -explo -gname testgraph_" + s); - proc_in = new BufferedReader(new InputStreamReader(proc.getInputStream())); - - monitorError(proc); - PrintStream out = new PrintStream(new FileOutputStream(graphPath + ".txt")); - while ((str = proc_in.readLine()) != null) { - // TraceManager.addDev( "Sending " + str + " from " + port + " to client..." ); - System.out.println("executing: " + str); - if(str.contains("Info transaction:")){ - out.append(str + "\n"); - } - } - } catch (Exception e) { - // Probably make is not installed - System.out.println("FAILED: executing simulation"); - return; - } - - // Compare results with expected ones - // Must load the graph - File file = new File(graphPath + ".txt"); - assertTrue(file.length() == 0); - Document htmlFile = null; - try { - htmlFile = Jsoup.parse(new File(graphPath + ".html"), "ISO-8859-1"); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } // right - Elements div = htmlFile.select("td.not"); - for (int j = 0; j < 3; j++) { - System.out.println("executing " + s + ": " + div.get(j).text()); - assertTrue(PARSE_FPGA_REMOVEALL[j].equals(div.get(j).text())); - } - } - } - } diff --git a/ttool/src/test/java/tmltranslator/RemoveAllTransactionsTests.java b/ttool/src/test/java/tmltranslator/RemoveAllTransactionsTests.java new file mode 100644 index 0000000000000000000000000000000000000000..80846864b3f075763d2f852c82c25411b2b27bb9 --- /dev/null +++ b/ttool/src/test/java/tmltranslator/RemoveAllTransactionsTests.java @@ -0,0 +1,198 @@ +package tmltranslator; + +import common.ConfigurationTTool; +import common.SpecConfigTTool; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.select.Elements; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import req.ebrdd.EBRDD; +import tepe.TEPE; +import tmltranslator.tomappingsystemc2.DiploSimulatorFactory; +import tmltranslator.tomappingsystemc2.IDiploSimulatorCodeGenerator; +import tmltranslator.tomappingsystemc2.Penalties; +import ui.AbstractUITest; +import ui.TDiagramPanel; +import ui.TMLArchiPanel; +import ui.TURTLEPanel; +import ui.tmldd.TMLArchiDiagramPanel; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertTrue; + +public class RemoveAllTransactionsTests extends AbstractUITest { + final String DIR_GEN = "test_diplo_simulator/"; + final String [] MODELS_PARSE_HTML = {"parseFPGA_HTML", "parseCPU1_HTML","parseCPU2_HTML"}; + final String [] PARSE_FPGA_REMOVEALL = {"<- idle 355 ->", "<- idle 355 ->", "<- idle 355 ->"}; + private String SIM_DIR; + @BeforeClass + public static void setUpBeforeClass() throws Exception { + RESOURCES_DIR = getBaseResourcesDir() + "/tmltranslator/simulator/"; + + } + public RemoveAllTransactionsTests() { + super(); + //mainGUI.openProjectFromFile(new File(RESOURCES_DIR)); + } + + @Before + public void setUp() throws Exception { + SIM_DIR = getBaseResourcesDir() + "../../../../simulators/c++2/"; + } + @Test + public void testRemoveAllTransactions() throws Exception { + for (int i = 0; i < 1; i++) { + String s = MODELS_PARSE_HTML[i]; + SIM_DIR = DIR_GEN + s + "_rmat/"; + System.out.println("executing: checking syntax " + s); + // select architecture tab + mainGUI.openProjectFromFile(new File(RESOURCES_DIR + s + ".xml")); + for(TURTLEPanel _tab : mainGUI.getTabs()) { + if(_tab instanceof TMLArchiPanel) { + for (TDiagramPanel tdp : _tab.getPanels()) { + if (tdp instanceof TMLArchiDiagramPanel) { + mainGUI.selectTab(tdp); + break; + } + } + break; + } + } + mainGUI.checkModelingSyntax(true); + TMLMapping tmap = mainGUI.gtm.getTMLMapping(); + TMLSyntaxChecking syntax = new TMLSyntaxChecking(tmap); + syntax.checkSyntax(); + assertTrue(syntax.hasErrors() == 0); + // Generate SystemC code + System.out.println("executing: sim code gen for " + s); + final IDiploSimulatorCodeGenerator tml2systc; + List<EBRDD> al = new ArrayList<EBRDD>(); + List<TEPE> alTepe = new ArrayList<TEPE>(); + tml2systc = DiploSimulatorFactory.INSTANCE.createCodeGenerator(tmap, al, alTepe); + tml2systc.setModelName(s); + String error = tml2systc.generateSystemC(false, true); + assertTrue(error == null); + + File directory = new File(SIM_DIR); + if (!directory.exists()) { + directory.mkdirs(); + } + + // Putting sim files + System.out.println("SIM executing: sim lib code copying for " + s); + ConfigurationTTool.SystemCCodeDirectory = getBaseResourcesDir() + "../../../../simulators/c++2/"; + boolean simFiles = SpecConfigTTool.checkAndCreateSystemCDir(SIM_DIR); + + System.out.println("SIM executing: sim lib code copying done with result " + simFiles); + assertTrue(simFiles); + + System.out.println("SIM Saving file in: " + SIM_DIR); + tml2systc.saveFile(SIM_DIR, "appmodel"); + + // Compile it + System.out.println("executing: compile"); + Process proc; + BufferedReader proc_in; + String str; + boolean mustRecompileAll; + Penalties penalty = new Penalties(SIM_DIR + "src_simulator"); + int changed = penalty.handlePenalties(false); + + if (changed == 1) { + mustRecompileAll = true; + } else { + mustRecompileAll = false; + } + + if (mustRecompileAll) { + System.out.println("executing: " + "make -C " + SIM_DIR + " clean"); + try { + proc = Runtime.getRuntime().exec("make -C " + SIM_DIR + " clean"); + proc_in = new BufferedReader(new InputStreamReader(proc.getInputStream())); + while ((str = proc_in.readLine()) != null) { + // TraceManager.addDev( "Sending " + str + " from " + port + " to client..." ); + System.out.println("executing: " + str); + } + } catch (Exception e) { + // probably make is not installed + System.out.println("FAILED: executing: " + "make -C " + SIM_DIR + " clean"); + return; + } + } + + System.out.println("executing: " + "make -C " + SIM_DIR); + try { + + proc = Runtime.getRuntime().exec("make -C " + SIM_DIR + ""); + proc_in = new BufferedReader(new InputStreamReader(proc.getInputStream())); + + monitorError(proc); + + while ((str = proc_in.readLine()) != null) { + // TraceManager.addDev( "Sending " + str + " from " + port + " to client..." ); + System.out.println("executing: " + str); + } + } catch (Exception e) { + // Probably make is not installed + System.out.println("FAILED: executing: " + "make -C " + SIM_DIR); + return; + } + System.out.println("SUCCESS: executing: " + "make -C " + SIM_DIR); + + // Run the simulator + String graphPath = SIM_DIR + "testgraph_" + s; + try { + + String[] params = new String[3]; + + params[0] = "./" + SIM_DIR + "run.x"; + params[1] = "-cmd"; + //first remove all transactions when the transacList is empty to see it crash or not + // second, run 100 time units and then remove all transactions again + //list 100 recent transactions on TransacList to check it is empty or not + //run again next 100 time units + // save trace file and check the transactions displayed on the trace. + params[2] = "26 1;1 6 100; 26 1;22 100; 1 6 100; 7 1 " + graphPath +".html"; + proc = Runtime.getRuntime().exec(params); + //proc = Runtime.getRuntime().exec("./" + SIM_DIR + "run.x -explo -gname testgraph_" + s); + proc_in = new BufferedReader(new InputStreamReader(proc.getInputStream())); + + monitorError(proc); + PrintStream out = new PrintStream(new FileOutputStream(graphPath + ".txt")); + while ((str = proc_in.readLine()) != null) { + // TraceManager.addDev( "Sending " + str + " from " + port + " to client..." ); + System.out.println("executing: " + str); + if(str.contains("Info transaction:")){ + out.append(str + "\n"); + } + } + } catch (Exception e) { + // Probably make is not installed + System.out.println("FAILED: executing simulation"); + return; + } + + // Compare results with expected ones + // Must load the graph + File file = new File(graphPath + ".txt"); + assertTrue(file.length() == 0); + Document htmlFile = null; + try { + htmlFile = Jsoup.parse(new File(graphPath + ".html"), "ISO-8859-1"); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } // right + Elements div = htmlFile.select("td.not"); + for (int j = 0; j < 3; j++) { + System.out.println("executing " + s + ": " + div.get(j).text()); + assertTrue(PARSE_FPGA_REMOVEALL[j].equals(div.get(j).text())); + } + } + } +}