diff options
author | Justin Clark-Casey (justincc) | 2013-01-22 02:16:10 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-01-22 02:16:10 +0000 |
commit | b93e8020e25ab22973e5ef25cc563ee39a9c3f66 (patch) | |
tree | 237c08c462da3af3a4fa77818ea031d21488bb93 /OpenSim/Region | |
parent | Add do-while co-op termination test (diff) | |
download | opensim-SC_OLD-b93e8020e25ab22973e5ef25cc563ee39a9c3f66.zip opensim-SC_OLD-b93e8020e25ab22973e5ef25cc563ee39a9c3f66.tar.gz opensim-SC_OLD-b93e8020e25ab22973e5ef25cc563ee39a9c3f66.tar.bz2 opensim-SC_OLD-b93e8020e25ab22973e5ef25cc563ee39a9c3f66.tar.xz |
Add regression test for co-op stop of an infinite jump loop
Also fixes bug in do-while test
Improves detection of failure due to invalid script in test
Sets up xengine anew for each test rather than once for the while testsuite to improve isolation between tests.
Stop listening for chat after the first 'script is running' chat is received to reduce test run time.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs index 33d2175..3365c92 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs | |||
@@ -50,14 +50,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
50 | private TestScene m_scene; | 50 | private TestScene m_scene; |
51 | private OpenSim.Region.ScriptEngine.XEngine.XEngine m_xEngine; | 51 | private OpenSim.Region.ScriptEngine.XEngine.XEngine m_xEngine; |
52 | 52 | ||
53 | private AutoResetEvent m_chatEvent = new AutoResetEvent(false); | 53 | private AutoResetEvent m_chatEvent; |
54 | private AutoResetEvent m_stoppedEvent = new AutoResetEvent(false); | 54 | private AutoResetEvent m_stoppedEvent; |
55 | 55 | ||
56 | private OSChatMessage m_osChatMessageReceived; | 56 | private OSChatMessage m_osChatMessageReceived; |
57 | 57 | ||
58 | [TestFixtureSetUp] | 58 | [SetUp] |
59 | public void Init() | 59 | public void Init() |
60 | { | 60 | { |
61 | m_osChatMessageReceived = null; | ||
62 | m_chatEvent = new AutoResetEvent(false); | ||
63 | m_stoppedEvent = new AutoResetEvent(false); | ||
64 | |||
61 | //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin"); | 65 | //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin"); |
62 | // Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); | 66 | // Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); |
63 | m_xEngine = new OpenSim.Region.ScriptEngine.XEngine.XEngine(); | 67 | m_xEngine = new OpenSim.Region.ScriptEngine.XEngine.XEngine(); |
@@ -76,8 +80,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
76 | xEngineConfig.Set("AppDomainLoading", "false"); | 80 | xEngineConfig.Set("AppDomainLoading", "false"); |
77 | 81 | ||
78 | xEngineConfig.Set("ScriptStopStrategy", "co-op"); | 82 | xEngineConfig.Set("ScriptStopStrategy", "co-op"); |
83 | |||
84 | // This is really just set for debugging the test. | ||
79 | xEngineConfig.Set("WriteScriptSourceToDebugFile", true); | 85 | xEngineConfig.Set("WriteScriptSourceToDebugFile", true); |
80 | 86 | ||
87 | // Set to false if we need to debug test so the old scripts don't get wiped before each separate test | ||
88 | // xEngineConfig.Set("DeleteScriptsOnStartup", false); | ||
89 | |||
81 | // This is not currently used at all for co-op termination. Bumping up to demonstrate that co-op termination | 90 | // This is not currently used at all for co-op termination. Bumping up to demonstrate that co-op termination |
82 | // has an effect - without it tests will fail due to a 120 second wait for the event to finish. | 91 | // has an effect - without it tests will fail due to a 120 second wait for the event to finish. |
83 | xEngineConfig.Set("WaitForEventCompletionOnScriptStop", 120000); | 92 | xEngineConfig.Set("WaitForEventCompletionOnScriptStop", 120000); |
@@ -174,7 +183,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
174 | llSay(0, ""Thin Lizzy""); | 183 | llSay(0, ""Thin Lizzy""); |
175 | 184 | ||
176 | while (1 == 1) | 185 | while (1 == 1) |
177 | llSay(0, ""Iter "" + (string)i); | 186 | llSay(0, ""Iter "" + (string)i++); |
178 | } | 187 | } |
179 | }"; | 188 | }"; |
180 | 189 | ||
@@ -197,7 +206,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
197 | 206 | ||
198 | while (1 == 1) | 207 | while (1 == 1) |
199 | { | 208 | { |
200 | llSay(0, ""Iter "" + (string)i); | 209 | llSay(0, ""Iter "" + (string)i++); |
201 | } | 210 | } |
202 | } | 211 | } |
203 | }"; | 212 | }"; |
@@ -221,8 +230,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
221 | 230 | ||
222 | do | 231 | do |
223 | { | 232 | { |
224 | llSay(0, ""Iter "" + (string)i); | 233 | llSay(0, ""Iter "" + (string)i++); |
225 | } while (1 == 1) | 234 | } while (1 == 1); |
235 | } | ||
236 | }"; | ||
237 | |||
238 | TestStop(script); | ||
239 | } | ||
240 | |||
241 | [Test] | ||
242 | public void TestStopOnInfiniteJumpLoop() | ||
243 | { | ||
244 | TestHelpers.InMethod(); | ||
245 | // TestHelpers.EnableLogging(); | ||
246 | |||
247 | string script = | ||
248 | @"default | ||
249 | { | ||
250 | state_entry() | ||
251 | { | ||
252 | integer i = 0; | ||
253 | llSay(0, ""Thin Lizzy""); | ||
254 | |||
255 | @p1; | ||
256 | llSay(0, ""Iter "" + (string)i++); | ||
257 | jump p1; | ||
226 | } | 258 | } |
227 | }"; | 259 | }"; |
228 | 260 | ||
@@ -276,7 +308,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests | |||
276 | 308 | ||
277 | private void OnChatFromWorld(object sender, OSChatMessage oscm) | 309 | private void OnChatFromWorld(object sender, OSChatMessage oscm) |
278 | { | 310 | { |
279 | // Console.WriteLine("Got chat [{0}]", oscm.Message); | 311 | m_scene.EventManager.OnChatFromWorld -= OnChatFromWorld; |
312 | Console.WriteLine("Got chat [{0}]", oscm.Message); | ||
280 | 313 | ||
281 | m_osChatMessageReceived = oscm; | 314 | m_osChatMessageReceived = oscm; |
282 | m_chatEvent.Set(); | 315 | m_chatEvent.Set(); |