aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-01-22 01:13:45 +0000
committerJustin Clark-Casey (justincc)2013-01-22 01:13:45 +0000
commita558f9797d3a2af00f6472adfc46ad5363d9bc1b (patch)
treebe3ea22938c8585e75fa069f773236ce2a81c899 /OpenSim
parentIncrease WaitForEventCompletionOnScriptStop to 120 secs to show that the co-o... (diff)
downloadopensim-SC_OLD-a558f9797d3a2af00f6472adfc46ad5363d9bc1b.zip
opensim-SC_OLD-a558f9797d3a2af00f6472adfc46ad5363d9bc1b.tar.gz
opensim-SC_OLD-a558f9797d3a2af00f6472adfc46ad5363d9bc1b.tar.bz2
opensim-SC_OLD-a558f9797d3a2af00f6472adfc46ad5363d9bc1b.tar.xz
factor out common code in existing co-op termination regression tests
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs79
1 files changed, 24 insertions, 55 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
index 53b992d..952ae40 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
@@ -99,23 +99,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
99 TestHelpers.InMethod(); 99 TestHelpers.InMethod();
100// TestHelpers.EnableLogging(); 100// TestHelpers.EnableLogging();
101 101
102 UUID userId = TestHelpers.ParseTail(0x1); 102 string script =
103// UUID objectId = TestHelpers.ParseTail(0x100);
104// UUID itemId = TestHelpers.ParseTail(0x3);
105 string itemName = "TestStopOnObjectDerezLongSleep() Item";
106
107 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "TestStopOnObjectDerezLongSleep", 0x100);
108 m_scene.AddNewSceneObject(so, true);
109
110 InventoryItemBase itemTemplate = new InventoryItemBase();
111// itemTemplate.ID = itemId;
112 itemTemplate.Name = itemName;
113 itemTemplate.Folder = so.UUID;
114 itemTemplate.InvType = (int)InventoryType.LSL;
115
116 m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
117
118 SceneObjectPart partWhereRezzed = m_scene.RezNewScript(userId, itemTemplate,
119@"default 103@"default
120{ 104{
121 state_entry() 105 state_entry()
@@ -123,31 +107,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
123 llSay(0, ""Thin Lizzy""); 107 llSay(0, ""Thin Lizzy"");
124 llSleep(60); 108 llSleep(60);
125 } 109 }
126}"); 110}";
127
128 TaskInventoryItem rezzedItem = partWhereRezzed.Inventory.GetInventoryItem(itemName);
129
130 // Wait for the script to start the event before we try stopping it.
131 m_chatEvent.WaitOne(60000);
132
133 Console.WriteLine("Script started with message [{0}]", m_osChatMessageReceived.Message);
134
135 // FIXME: This is a very poor way of trying to avoid a low-probability race condition where the script
136 // executes llSay() but has not started the sleep before we try to stop it.
137 Thread.Sleep(1000);
138
139 // We need a way of carrying on if StopScript() fail, since it won't return if the script isn't actually
140 // stopped. This kind of multi-threading is far from ideal in a regression test.
141 new Thread(() => { m_xEngine.StopScript(rezzedItem.ItemID); m_stoppedEvent.Set(); }).Start();
142
143 if (!m_stoppedEvent.WaitOne(30000))
144 Assert.Fail("Script did not co-operatively stop.");
145 111
146 bool running; 112 TestStop(script);
147 TaskInventoryItem scriptItem = partWhereRezzed.Inventory.GetInventoryItem(itemName);
148 Assert.That(
149 SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, scriptItem, out running), Is.True);
150 Assert.That(running, Is.False);
151 } 113 }
152 114
153 [Test] 115 [Test]
@@ -156,12 +118,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
156 TestHelpers.InMethod(); 118 TestHelpers.InMethod();
157// TestHelpers.EnableLogging(); 119// TestHelpers.EnableLogging();
158 120
121 string script =
122@"default
123{
124 state_entry()
125 {
126 llSay(0, ""Thin Lizzy"");
127 integer i = 0;
128 for (i = 0; i < 2147483647; i++)
129 llSay(0, ""Iter "" + (string)i);
130 }
131}";
132
133 TestStop(script);
134 }
135
136 private void TestStop(string script)
137 {
159 UUID userId = TestHelpers.ParseTail(0x1); 138 UUID userId = TestHelpers.ParseTail(0x1);
160// UUID objectId = TestHelpers.ParseTail(0x100); 139// UUID objectId = TestHelpers.ParseTail(0x100);
161// UUID itemId = TestHelpers.ParseTail(0x3); 140// UUID itemId = TestHelpers.ParseTail(0x3);
162 string itemName = "TestStopOnLongForLoop() Item"; 141 string itemName = "TestStop() Item";
163 142
164 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "TestStopOnLongForLoop", 0x100); 143 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "TestStop", 0x100);
165 m_scene.AddNewSceneObject(so, true); 144 m_scene.AddNewSceneObject(so, true);
166 145
167 InventoryItemBase itemTemplate = new InventoryItemBase(); 146 InventoryItemBase itemTemplate = new InventoryItemBase();
@@ -172,17 +151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
172 151
173 m_scene.EventManager.OnChatFromWorld += OnChatFromWorld; 152 m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
174 153
175 SceneObjectPart partWhereRezzed = m_scene.RezNewScript(userId, itemTemplate, 154 SceneObjectPart partWhereRezzed = m_scene.RezNewScript(userId, itemTemplate, script);
176@"default
177{
178 state_entry()
179 {
180 llSay(0, ""Thin Lizzy"");
181 integer i = 0;
182 for (i = 0; i < 2147483647; i++)
183 llSay(0, ""Iter "" + (string)i);
184 }
185}");
186 155
187 TaskInventoryItem rezzedItem = partWhereRezzed.Inventory.GetInventoryItem(itemName); 156 TaskInventoryItem rezzedItem = partWhereRezzed.Inventory.GetInventoryItem(itemName);
188 157
@@ -192,7 +161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
192 Console.WriteLine("Script started with message [{0}]", m_osChatMessageReceived.Message); 161 Console.WriteLine("Script started with message [{0}]", m_osChatMessageReceived.Message);
193 162
194 // FIXME: This is a very poor way of trying to avoid a low-probability race condition where the script 163 // FIXME: This is a very poor way of trying to avoid a low-probability race condition where the script
195 // executes llSay() but has not started the sleep before we try to stop it. 164 // executes llSay() but has not started the next statement before we try to stop it.
196 Thread.Sleep(1000); 165 Thread.Sleep(1000);
197 166
198 // We need a way of carrying on if StopScript() fail, since it won't return if the script isn't actually 167 // We need a way of carrying on if StopScript() fail, since it won't return if the script isn't actually