From b93e8020e25ab22973e5ef25cc563ee39a9c3f66 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 22 Jan 2013 02:16:10 +0000 Subject: 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. --- .../Shared/Instance/Tests/CoopTerminationTests.cs | 49 ++++++++++++++++++---- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') 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 private TestScene m_scene; private OpenSim.Region.ScriptEngine.XEngine.XEngine m_xEngine; - private AutoResetEvent m_chatEvent = new AutoResetEvent(false); - private AutoResetEvent m_stoppedEvent = new AutoResetEvent(false); + private AutoResetEvent m_chatEvent; + private AutoResetEvent m_stoppedEvent; private OSChatMessage m_osChatMessageReceived; - [TestFixtureSetUp] + [SetUp] public void Init() { + m_osChatMessageReceived = null; + m_chatEvent = new AutoResetEvent(false); + m_stoppedEvent = new AutoResetEvent(false); + //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin"); // Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); m_xEngine = new OpenSim.Region.ScriptEngine.XEngine.XEngine(); @@ -76,8 +80,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests xEngineConfig.Set("AppDomainLoading", "false"); xEngineConfig.Set("ScriptStopStrategy", "co-op"); + + // This is really just set for debugging the test. xEngineConfig.Set("WriteScriptSourceToDebugFile", true); + // Set to false if we need to debug test so the old scripts don't get wiped before each separate test +// xEngineConfig.Set("DeleteScriptsOnStartup", false); + // This is not currently used at all for co-op termination. Bumping up to demonstrate that co-op termination // has an effect - without it tests will fail due to a 120 second wait for the event to finish. xEngineConfig.Set("WaitForEventCompletionOnScriptStop", 120000); @@ -174,7 +183,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests llSay(0, ""Thin Lizzy""); while (1 == 1) - llSay(0, ""Iter "" + (string)i); + llSay(0, ""Iter "" + (string)i++); } }"; @@ -197,7 +206,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests while (1 == 1) { - llSay(0, ""Iter "" + (string)i); + llSay(0, ""Iter "" + (string)i++); } } }"; @@ -221,8 +230,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests do { - llSay(0, ""Iter "" + (string)i); - } while (1 == 1) + llSay(0, ""Iter "" + (string)i++); +} while (1 == 1); + } +}"; + + TestStop(script); + } + + [Test] + public void TestStopOnInfiniteJumpLoop() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + string script = +@"default +{ + state_entry() + { + integer i = 0; + llSay(0, ""Thin Lizzy""); + + @p1; + llSay(0, ""Iter "" + (string)i++); + jump p1; } }"; @@ -276,7 +308,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests private void OnChatFromWorld(object sender, OSChatMessage oscm) { -// Console.WriteLine("Got chat [{0}]", oscm.Message); + m_scene.EventManager.OnChatFromWorld -= OnChatFromWorld; + Console.WriteLine("Got chat [{0}]", oscm.Message); m_osChatMessageReceived = oscm; m_chatEvent.Set(); -- cgit v1.1