diff --git a/simulators/c++2/src_simulator/app/TMLTask.cpp b/simulators/c++2/src_simulator/app/TMLTask.cpp index 18444abdbeeae55068e8b7eee740e878172db334..92196ad7620e8829bf694872473dfa9ac382e5d2 100755 --- a/simulators/c++2/src_simulator/app/TMLTask.cpp +++ b/simulators/c++2/src_simulator/app/TMLTask.cpp @@ -527,6 +527,12 @@ std::string TMLTask::determineHTMLCellClass( std::map<TMLTask*, std::string> &t return taskColors[ task ]; } +void TMLTask::removeTrans(int numberOfTrans) { + if (numberOfTrans == 1) { + _transactList.clear(); + } +} + void TMLTask::schedule2HTML(std::ofstream& myfile) const { // myfile << "<h2><span>Scheduling for device: "<< _name << "</span></h2>" << std::endl; myfile << SCHED_HTML_DIV << SCHED_HTML_BOARD; diff --git a/simulators/c++2/src_simulator/app/TMLTask.h b/simulators/c++2/src_simulator/app/TMLTask.h index ddfe1f25e5febd1f79554f56c0a35512e9936986..50b69ab00464f35956a77adde9da910024626273 100755 --- a/simulators/c++2/src_simulator/app/TMLTask.h +++ b/simulators/c++2/src_simulator/app/TMLTask.h @@ -148,6 +148,7 @@ public: \param iTrans Pointer to the transaction */ void addTransaction(TMLTransaction* iTrans); + void removeTrans(int numberOfTrans); virtual std::ostream& writeObject(std::ostream& s); virtual std::istream& readObject(std::istream& s); virtual void streamBenchmarks(std::ostream& s) const; diff --git a/simulators/c++2/src_simulator/arch/Bus.cpp b/simulators/c++2/src_simulator/arch/Bus.cpp index 0f15dbbde18aba5139b7c058a8798cac6555c0ed..bf77be113fb884c08bc293e089f5fd291659aa0b 100644 --- a/simulators/c++2/src_simulator/arch/Bus.cpp +++ b/simulators/c++2/src_simulator/arch/Bus.cpp @@ -256,6 +256,12 @@ int Bus::allTrans2XMLByTask(std::ostringstream& glob, std::string taskName) cons return total; } +void Bus::removeTrans(int numberOfTrans) { + if (numberOfTrans == 1) { + _transactList.clear(); + } +} + void Bus::latencies2XML(std::ostringstream& glob, unsigned int id1, unsigned int id2) { for(TransactionList::const_iterator i=_transactList.begin(); i != _transactList.end(); ++i){ diff --git a/simulators/c++2/src_simulator/arch/Bus.h b/simulators/c++2/src_simulator/arch/Bus.h index 1ca6d086114f0f9a2aa1e76881eec78af5b66a7a..0470c2a53c1ce09eed7ed6823e4857182343619f 100644 --- a/simulators/c++2/src_simulator/arch/Bus.h +++ b/simulators/c++2/src_simulator/arch/Bus.h @@ -106,7 +106,8 @@ public: \param glob refers to the output stream */ int allTrans2XML(std::ostringstream& glob, int maxNbOfTrans) const; - int allTrans2XMLByTask(std::ostringstream& glob, std::string taskName) const; + int allTrans2XMLByTask(std::ostringstream& glob, std::string taskName) const; + void removeTrans(int numberOfTrans); void latencies2XML(std::ostringstream& glob, unsigned int id1, unsigned int id2); /** \param myfile Reference to the ofstream object representing the output file diff --git a/simulators/c++2/src_simulator/arch/FPGA.cpp b/simulators/c++2/src_simulator/arch/FPGA.cpp index 70f8086e9c3bde04dea0d596723eed8edc523c38..452cb560affb8f59ae4a1f78ab10c91d3c3f66ac 100644 --- a/simulators/c++2/src_simulator/arch/FPGA.cpp +++ b/simulators/c++2/src_simulator/arch/FPGA.cpp @@ -434,6 +434,12 @@ int FPGA::allTrans2XMLByTask(std::ostringstream& glob, std::string taskName) con return total; } +void FPGA::removeTrans(int numberOfTrans) { + if (numberOfTrans == 1) { + _transactList.clear(); + } +} + void FPGA::latencies2XML(std::ostringstream& glob, unsigned int id1, unsigned int id2) { for(TransactionList::const_iterator i=_transactList.begin(); i != _transactList.end(); ++i){ if ((*i)->getCommand() !=NULL){ diff --git a/simulators/c++2/src_simulator/arch/FPGA.h b/simulators/c++2/src_simulator/arch/FPGA.h index bcd7802c6e88d1750b3d1bada88cd900668d733c..dfa7554750d8e916da3f6b3b1ea6144755d83c3d 100644 --- a/simulators/c++2/src_simulator/arch/FPGA.h +++ b/simulators/c++2/src_simulator/arch/FPGA.h @@ -133,6 +133,7 @@ public: ///inline unsigned int getTransNumber() { return _transNumber;} inline unsigned int getID () { return _ID;} void HW2HTML(std::ofstream& myfile) ; + void removeTrans(int numberOfTrans); void schedule2HTML(std::ofstream& myfile) ; inline const TaskList& getTaskList() const{return _taskList;} inline void setHtmlCurrTask(TMLTask *t) { _htmlCurrTask=t;} diff --git a/simulators/c++2/src_simulator/arch/MultiCoreCPU.cpp b/simulators/c++2/src_simulator/arch/MultiCoreCPU.cpp index 8f85e7b42a0ac22f37a171a87c82817f54cccb9c..5900990a954c76c370c3a44947b9cad6caf1cafa 100644 --- a/simulators/c++2/src_simulator/arch/MultiCoreCPU.cpp +++ b/simulators/c++2/src_simulator/arch/MultiCoreCPU.cpp @@ -615,6 +615,12 @@ int MultiCoreCPU::allTrans2XMLByTask(std::ostringstream& glob, std::string taskN return total; } +void MultiCoreCPU::removeTrans(int numberOfTrans) { + if (numberOfTrans == 1) { + _transactList.clear(); + } +} + void MultiCoreCPU::latencies2XML(std::ostringstream& glob, unsigned int id1, unsigned int id2) { diff --git a/simulators/c++2/src_simulator/arch/MultiCoreCPU.h b/simulators/c++2/src_simulator/arch/MultiCoreCPU.h index 12e29f40435261ce2b8795a9e4016a458fbb8218..a3a1b8c2836e0d9190c2a72cb16e780c5f084e7a 100644 --- a/simulators/c++2/src_simulator/arch/MultiCoreCPU.h +++ b/simulators/c++2/src_simulator/arch/MultiCoreCPU.h @@ -116,7 +116,8 @@ public: \param glob refers to the output stream */ int allTrans2XML(std::ostringstream& glob, int maxNbOfTrans) const; - int allTrans2XMLByTask(std::ostringstream& glob, std::string taskName) const; + int allTrans2XMLByTask(std::ostringstream& glob, std::string taskName) const; + void removeTrans(int numberOfTrans); void latencies2XML(std::ostringstream& glob, unsigned int id1, unsigned int id2); virtual void streamBenchmarks(std::ostream& s) const; virtual void reset(); diff --git a/simulators/c++2/src_simulator/arch/SchedulableDevice.h b/simulators/c++2/src_simulator/arch/SchedulableDevice.h index 68e3181e8ca94d1481bc4d1872765fe5954ff08c..ca1742df39ffd6bb24a8c6a179b136134adbc16a 100644 --- a/simulators/c++2/src_simulator/arch/SchedulableDevice.h +++ b/simulators/c++2/src_simulator/arch/SchedulableDevice.h @@ -98,6 +98,7 @@ public: virtual int allTrans2XML(std::ostringstream& glob, int maxNbOfTrans) const =0; virtual int allTrans2XMLByTask(std::ostringstream& glob, std::string taskName) const =0; virtual void latencies2XML(std::ostringstream& glob, unsigned int id1, unsigned int id2)=0; + virtual void removeTrans(int numberOfTrans)=0; virtual std::string toString() const =0; virtual std::istream& readObject(std::istream &is); virtual std::ostream& writeObject(std::ostream &os); diff --git a/simulators/c++2/src_simulator/arch/SingleCoreCPU.cpp b/simulators/c++2/src_simulator/arch/SingleCoreCPU.cpp index 31297a19d3235d18fac24824aaabe0258404477b..40c75dba536a61a7ac52a9979782cc1c8abb2468 100644 --- a/simulators/c++2/src_simulator/arch/SingleCoreCPU.cpp +++ b/simulators/c++2/src_simulator/arch/SingleCoreCPU.cpp @@ -480,6 +480,12 @@ int SingleCoreCPU::allTrans2XMLByTask(std::ostringstream& glob, std::string task return total; } +void SingleCoreCPU::removeTrans(int numberOfTrans) { + if (numberOfTrans == 1) { + _transactList.clear(); + } +} + void SingleCoreCPU::latencies2XML(std::ostringstream& glob, unsigned int id1, unsigned int id2) { for(TransactionList::const_iterator i=_transactList.begin(); i != _transactList.end(); ++i){ if ((*i)->getCommand() !=NULL){ diff --git a/simulators/c++2/src_simulator/arch/SingleCoreCPU.h b/simulators/c++2/src_simulator/arch/SingleCoreCPU.h index 2ca77399c664dbdc324b2b6ccfbfda5c34c3ad39..d92f2097eb1b373046f603832665d54e1d626ee1 100644 --- a/simulators/c++2/src_simulator/arch/SingleCoreCPU.h +++ b/simulators/c++2/src_simulator/arch/SingleCoreCPU.h @@ -118,7 +118,8 @@ public: \param glob refers to the output stream */ int allTrans2XML(std::ostringstream& glob, int maxNbOfTrans) const; - int allTrans2XMLByTask(std::ostringstream& glob, std::string taskName) const; + int allTrans2XMLByTask(std::ostringstream& glob, std::string taskName) const; + void removeTrans(int numberOfTrans); void latencies2XML(std::ostringstream& glob, unsigned int id1, unsigned int id2); void schedule2XML(std::ostringstream& glob,std::ofstream& myfile) const; diff --git a/simulators/c++2/src_simulator/sim/Simulator.cpp b/simulators/c++2/src_simulator/sim/Simulator.cpp index 72bf121a3ae3229af972c7a156693e6c50f91ff9..138974efc0077d2cd2a76f30eb378e1e49db7ea3 100644 --- a/simulators/c++2/src_simulator/sim/Simulator.cpp +++ b/simulators/c++2/src_simulator/sim/Simulator.cpp @@ -428,6 +428,30 @@ int Simulator::allTrans2XMLByTask(std::ostringstream& glob, std::string taskName return total; } +void Simulator::removeOldTransaction(int numberOfTrans) { + for(CPUList::const_iterator i=_simComp->getCPUList().begin(); i != _simComp->getCPUList().end(); ++i) { + for(TaskList::const_iterator j = (*i)->getTaskList().begin(); j != (*i)->getTaskList().end(); ++j) { + (*j)->removeTrans(numberOfTrans); + } + } + for(FPGAList::const_iterator i=_simComp->getFPGAList().begin(); i != _simComp->getFPGAList().end(); ++i) { + for(TaskList::const_iterator j = (*i)->getTaskList().begin(); j != (*i)->getTaskList().end(); ++j) { + (*j)->removeTrans(numberOfTrans); + } + } + for(CPUList::const_iterator i=_simComp->getCPUList().begin(); i != _simComp->getCPUList().end(); ++i) { + (*i)->removeTrans(numberOfTrans); + } + + for(BusList::const_iterator j=_simComp->getBusList().begin(); j != _simComp->getBusList().end(); ++j) { + (*j)->removeTrans(numberOfTrans); + } + + for(FPGAList::const_iterator k=_simComp->getFPGAList().begin(); k != _simComp->getFPGAList().end(); ++k) { + (*k)->removeTrans(numberOfTrans); + } +} + void Simulator::latencies2XML(std::ostringstream& glob, int id1, int id2) { for(CPUList::const_iterator i=_simComp->getCPUList().begin(); i != _simComp->getCPUList().end(); ++i){ (*i)->latencies2XML(glob, id1, id2); @@ -2039,6 +2063,12 @@ void Simulator::decodeCommand(std::string iCmd, std::ostream& iXmlOutStream){ anEntityMsg << TAG_TRANSACTION_NBo << "nb=\"" << returnedNbOfTransactions << "\"" << TAG_TRANSACTION_NBc << std::endl; std::cout << "End list of all transactions belong to a task." << std::endl; break; + case 26: //Emptying simulation transactions during simulation + aInpStream >> aParam2; + std::cout << "Remove list of " << aParam2 << " transactions per CPU or Bus." << std::endl; + removeOldTransaction(aParam2); + std::cout << "End remove list of transactions." << std::endl; + break; default: anEntityMsg << TAG_MSGo << MSG_CMDNFOUND<< TAG_MSGc << std::endl; anErrorCode=3; diff --git a/simulators/c++2/src_simulator/sim/Simulator.h b/simulators/c++2/src_simulator/sim/Simulator.h index 14407b323f2c73e2b1d9e90773dccca8733b7cf2..592ab1288b022a25bf0518ad1d417f0fc945523a 100644 --- a/simulators/c++2/src_simulator/sim/Simulator.h +++ b/simulators/c++2/src_simulator/sim/Simulator.h @@ -273,7 +273,9 @@ public: */ int allTrans2XML(std::ostringstream& glob, int maxNbOfTrans) const; - int allTrans2XMLByTask(std::ostringstream& glob, std::string taskName) const; + int allTrans2XMLByTask(std::ostringstream& glob, std::string taskName) const; + + void removeOldTransaction(int numberOfTrans); void latencies2XML(std::ostringstream& glob, int id1, int id2); diff --git a/src/main/java/remotesimulation/CommandParser.java b/src/main/java/remotesimulation/CommandParser.java index 72ff0cd8637fbc1639e76b126dd0c238d703a0a8..21650bacebc2a2c6137a0c09f0a59c2227e2060b 100755 --- a/src/main/java/remotesimulation/CommandParser.java +++ b/src/main/java/remotesimulation/CommandParser.java @@ -328,6 +328,14 @@ public class CommandParser { sc = new SimulationCommand("list-all-transactions-of-a-task", "lat", "25", params, paramNames, "Get all transactions of Task"); commandList.add(sc); + // Remove all the transactions in the past + params = new int[1]; + paramNames = new String[1]; + params[0] = 1; + paramNames[0] = "<YES>: 1, <NO>: 0"; + sc = new SimulationCommand("remove-all-trans", "rmat", "26", params, paramNames, "Remove all the transactions in the past"); + commandList.add(sc); + // rm-breakpoint params = new int[2]; paramNames = new String[2]; diff --git a/src/main/java/ui/interactivesimulation/JPanelTaskTransactions.java b/src/main/java/ui/interactivesimulation/JPanelTaskTransactions.java index 9127cb443223ed342c95a273c02ec92a4f6e1ef2..8a6479159805f55301ffd58b0f774f0c41a8a6ed 100644 --- a/src/main/java/ui/interactivesimulation/JPanelTaskTransactions.java +++ b/src/main/java/ui/interactivesimulation/JPanelTaskTransactions.java @@ -15,7 +15,7 @@ import java.util.Vector; public class JPanelTaskTransactions extends JPanel { private JFrameInteractiveSimulation jfis; private TaskTransactionTableModel ttm; - private JButton updateTransactionInformationButton; + private JButton updateTransactionInformationButton, clearAllOldTransactions; private JScrollPane jspTransactionInfo; private JComboBox<String> tasks; private Vector<SimulationTransaction> _trans; @@ -85,7 +85,7 @@ public class JPanelTaskTransactions extends JPanel { nbOfTransactions = new JTextField(Integer.toString(defaultNbOfTransactions), defaultNbOfTransactions); add(nbOfTransactions, c2); - add(new JLabel("# Task Name: "), c2); + add(new JLabel("Task Name: "), c2); tasks = new JComboBox<>(); tasks.addItem("-----"); if(tmlm != null){ @@ -98,6 +98,15 @@ public class JPanelTaskTransactions extends JPanel { add(tasks, c2); updateTransactionInformationButton = new JButton(jfis.actions[InteractiveSimulationActions.ACT_UPDATE_TRANSACTIONS]); add(updateTransactionInformationButton, c2); + clearAllOldTransactions = new JButton(); + clearAllOldTransactions.setText("Clear all old transactions"); + clearAllOldTransactions.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent actionEvent) { + jfis.sendCommand("rmat 1"); + } + }); + add(clearAllOldTransactions, c2); tasks.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { diff --git a/ttool/src/test/java/tmltranslator/HTMLParseTest.java b/ttool/src/test/java/tmltranslator/HTMLParseTest.java index 2e920d645a63a5231c4c7f77c4382c0aa70bcfa8..67475ef21c1f3fe7c502a32cd8f4d37fe2c12e04 100644 --- a/ttool/src/test/java/tmltranslator/HTMLParseTest.java +++ b/ttool/src/test/java/tmltranslator/HTMLParseTest.java @@ -355,47 +355,29 @@ public class HTMLParseTest extends AbstractUITest { int lineNum = 1; - while (line1 != null || line2 != null) - { - if(line1 == null || line2 == null) - { + while (line1 != null || line2 != null) { + if (line1 == null || line2 == null) { areEqual = false; - break; - } - else if(! line1.equalsIgnoreCase(line2)) - { + } else if (!line1.equalsIgnoreCase(line2)) { areEqual = false; - break; } - line1 = reader1.readLine(); - line2 = reader2.readLine(); - lineNum++; } - if(areEqual) - { - System.out.println("Two files have same content. levan"); + if (areEqual) { + System.out.println("Two files have same content."); assertTrue(areEqual); - } - else - { - System.out.println("Two files have different content. They differ at line "+lineNum); - - System.out.println("File1 has "+line1+" and File2 has "+line2+" at line "+lineNum); + } else { + System.out.println("Two files have different content. They differ at line " + lineNum); + System.out.println("File1 has " + line1 + " and File2 has " + line2 + " at line " + lineNum); assertTrue(areEqual); } - reader1.close(); - reader2.close(); - } } - - } diff --git a/ttool/src/test/java/tmltranslator/RemoveAllTransactionsTests.java b/ttool/src/test/java/tmltranslator/RemoveAllTransactionsTests.java new file mode 100644 index 0000000000000000000000000000000000000000..a9830670690a978e1dda63273962793351d3cbff --- /dev/null +++ b/ttool/src/test/java/tmltranslator/RemoveAllTransactionsTests.java @@ -0,0 +1,220 @@ +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"}; + final static String EXPECTED_FILE_REMOVE_ALL_TRANS = getBaseResourcesDir() + "tmltranslator/expected/expected_remove_all_trans.txt"; + 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 < MODELS_PARSE_HTML.length; 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 2 " + graphPath +"_save.txt"; + proc = Runtime.getRuntime().exec(params); + 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);// check transacList empty or not + + BufferedReader reader1 = new BufferedReader(new FileReader(graphPath + "_save.txt")); + + BufferedReader reader2 = new BufferedReader(new FileReader(EXPECTED_FILE_REMOVE_ALL_TRANS)); + + String line1 = reader1.readLine(); + + String line2 = reader2.readLine(); + + boolean areEqual = true; + + int lineNum = 1; + + while (line1 != null || line2 != null) { + if (line1 == null || line2 == null) { + areEqual = false; + break; + } else if (!line1.equalsIgnoreCase(line2)) { + areEqual = false; + break; + } + line1 = reader1.readLine(); + line2 = reader2.readLine(); + lineNum++; + } + + if (areEqual) { + System.out.println("Two files have same content."); + assertTrue(areEqual); + } else { + System.out.println("Two files have different content. They differ at line " + lineNum); + System.out.println("File1 has " + line1 + " and File2 has " + line2 + " at line " + lineNum); + assertTrue(areEqual); + } + reader1.close(); + reader2.close(); + } + } +} diff --git a/ttool/src/test/resources/tmltranslator/expected/expected_remove_all_trans.txt b/ttool/src/test/resources/tmltranslator/expected/expected_remove_all_trans.txt new file mode 100644 index 0000000000000000000000000000000000000000..b90eda308c92b57b77546e0ddf02ee55275259f5 --- /dev/null +++ b/ttool/src/test/resources/tmltranslator/expected/expected_remove_all_trans.txt @@ -0,0 +1,4 @@ +========= Scheduling for device: FPGA0 ========= +Application__Task3: Write 20,Application__ch t:355 l:2 (vl:8) params: Ch: Application__ch +========= Scheduling for device: Bus0_0 ========= +Application__Task3: Write 20,Application__ch t:355 l:2 (vl:8) params: Ch: Application__ch