MCPcopy Create free account
hub / github.com/SoarGroup/Soar / doTest

Method doTest

Tests/UnitTests/src/multiagenttest.cpp:194–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194void MultiAgentTest::doTest()
195{
196 sml::Kernel* pKernel = sml::Kernel::CreateKernelInNewThread();
197 CPPUNIT_ASSERT_MESSAGE(pKernel->GetLastErrorDescription(), !pKernel->HadError());
198
199 // We'll require commits, just so we're testing that path
200 pKernel->SetAutoCommit(false) ;
201
202 // Comment this in if you need to debug the messages going back and forth.
203 //pKernel->SetTraceCommunications(true) ;
204
205 CPPUNIT_ASSERT(numberAgents < MAX_AGENTS);
206
207 std::vector< std::string > names;
208 std::vector< sml::Agent* > agents;
209 std::vector< std::stringstream* > trace;
210 std::vector< int > callbackPrint;
211
212 // Create the agents
213 for (int agentCounter = 0 ; agentCounter < numberAgents ; ++agentCounter)
214 {
215 std::stringstream name;
216 name << "agent" << 1 + agentCounter;
217 names.push_back(name.str());
218
219 sml::Agent* pAgent = pKernel->CreateAgent(name.str().c_str()) ;
220 CPPUNIT_ASSERT(pAgent != NULL);
221 CPPUNIT_ASSERT_MESSAGE(pKernel->GetLastErrorDescription(), !pKernel->HadError());
222
223 agents.push_back(pAgent);
224
225 std::stringstream path;
226 // TODO: use boost filesystem
227 CPPUNIT_ASSERT(pAgent->LoadProductions("test_agents/testmulti.soar"));
228 createInput(pAgent, 0);
229
230 // Collect the trace output from the run
231 trace.push_back(new std::stringstream());
232 callbackPrint.push_back(pAgent->RegisterForPrintEvent(sml::smlEVENT_PRINT, MultiAgentTest::MyPrintEventHandler, trace[agentCounter]));
233 }
234
235 pKernel->RegisterForUpdateEvent(sml::smlEVENT_AFTER_ALL_GENERATED_OUTPUT, MultiAgentTest::MyUpdateEventHandler, NULL) ;
236
237 // Run for a first set of output, so we can see whether that worked
238 pKernel->RunAllTilOutput() ;
239
240 // Print out some information
241 reportAgentStatus(pKernel, numberAgents, trace) ;
242
243 // Now get serious about a decent run
244 const int kFirstRun = 5 ;
245 for (int i = 0 ; i < kFirstRun ; i++)
246 {
247 // Run for a bit
248 pKernel->RunAllTilOutput() ;
249 }
250
251 reportAgentStatus(pKernel, numberAgents, trace) ;

Callers

nothing calls this directly

Calls 10

CreateAgentMethod · 0.80
LoadProductionsMethod · 0.80
RegisterForPrintEventMethod · 0.80
RunAllTilOutputMethod · 0.80
endMethod · 0.80
HadErrorMethod · 0.45
push_backMethod · 0.45
ShutdownMethod · 0.45

Tested by

no test coverage detected