Skip to content
Snippets Groups Projects

#250 Emptying simulation transactions during simulation

Closed #250 Emptying simulation transactions during simulation
Closed Le Van Truong requested to merge revert-883077ef into master
1 file
+ 148
1
Compare changes
  • Side-by-side
  • Inline
@@ -34,6 +34,7 @@ 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
@@ -379,7 +380,7 @@ public class HTMLParseTest extends AbstractUITest {
if(areEqual)
{
System.out.println("Two files have same content. levan");
System.out.println("Two files have same content.");
assertTrue(areEqual);
}
else
@@ -397,5 +398,151 @@ 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()));
}
}
}
}
Loading