aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-01-22 00:59:46 +0000
committerJustin Clark-Casey (justincc)2013-01-22 00:59:46 +0000
commitcd446c32d6d4c6453dbc85c5d8ac75c65a6db979 (patch)
tree1e537a151d798a2851cc75848356c8ab85253b3e /OpenSim/Region/ScriptEngine
parentrefactor: rename XEngineTest to more descriptive XEngineBasicTests (diff)
downloadopensim-SC_OLD-cd446c32d6d4c6453dbc85c5d8ac75c65a6db979.zip
opensim-SC_OLD-cd446c32d6d4c6453dbc85c5d8ac75c65a6db979.tar.gz
opensim-SC_OLD-cd446c32d6d4c6453dbc85c5d8ac75c65a6db979.tar.bz2
opensim-SC_OLD-cd446c32d6d4c6453dbc85c5d8ac75c65a6db979.tar.xz
Add regression test TestStopOnLongForLoop()
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs59
1 files changed, 59 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
index 8c3e9e0..c23d7a6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
@@ -146,6 +146,65 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
146 Assert.That(running, Is.False); 146 Assert.That(running, Is.False);
147 } 147 }
148 148
149 [Test]
150 public void TestStopOnLongForLoop()
151 {
152 TestHelpers.InMethod();
153// TestHelpers.EnableLogging();
154
155 UUID userId = TestHelpers.ParseTail(0x1);
156// UUID objectId = TestHelpers.ParseTail(0x100);
157// UUID itemId = TestHelpers.ParseTail(0x3);
158 string itemName = "TestStopOnLongForLoop() Item";
159
160 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "TestStopOnLongForLoop", 0x100);
161 m_scene.AddNewSceneObject(so, true);
162
163 InventoryItemBase itemTemplate = new InventoryItemBase();
164// itemTemplate.ID = itemId;
165 itemTemplate.Name = itemName;
166 itemTemplate.Folder = so.UUID;
167 itemTemplate.InvType = (int)InventoryType.LSL;
168
169 m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
170
171 SceneObjectPart partWhereRezzed = m_scene.RezNewScript(userId, itemTemplate,
172@"default
173{
174 state_entry()
175 {
176 llSay(0, ""Thin Lizzy"");
177 integer i = 0;
178 for (i = 0; i < 2147483647; i++)
179 llSay(0, ""Iter "" + (string)i);
180 }
181}");
182
183 TaskInventoryItem rezzedItem = partWhereRezzed.Inventory.GetInventoryItem(itemName);
184
185 // Wait for the script to start the event before we try stopping it.
186 m_chatEvent.WaitOne(60000);
187
188 Console.WriteLine("Script started with message [{0}]", m_osChatMessageReceived.Message);
189
190 // FIXME: This is a very poor way of trying to avoid a low-probability race condition where the script
191 // executes llSay() but has not started the sleep before we try to stop it.
192 Thread.Sleep(1000);
193
194 // We need a way of carrying on if StopScript() fail, since it won't return if the script isn't actually
195 // stopped. This kind of multi-threading is far from ideal in a regression test.
196 new Thread(() => { m_xEngine.StopScript(rezzedItem.ItemID); m_stoppedEvent.Set(); }).Start();
197
198 if (!m_stoppedEvent.WaitOne(30000))
199 Assert.Fail("Script did not co-operatively stop.");
200
201 bool running;
202 TaskInventoryItem scriptItem = partWhereRezzed.Inventory.GetInventoryItem(itemName);
203 Assert.That(
204 SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, scriptItem, out running), Is.True);
205 Assert.That(running, Is.False);
206 }
207
149 private void OnChatFromWorld(object sender, OSChatMessage oscm) 208 private void OnChatFromWorld(object sender, OSChatMessage oscm)
150 { 209 {
151// Console.WriteLine("Got chat [{0}]", oscm.Message); 210// Console.WriteLine("Got chat [{0}]", oscm.Message);