Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
	OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
avinationmerge
Melanie 2012-02-07 21:09:04 +00:00
commit 37049180f6
14 changed files with 336 additions and 46 deletions

View File

@ -1549,7 +1549,7 @@ namespace OpenSim.Region.Framework.Scenes
PhysActor = null; PhysActor = null;
} }
// Basic Physics returns null.. joy joy joy. // Basic Physics can also return null as well as an exception catch.
if (PhysActor != null) if (PhysActor != null)
{ {
PhysActor.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info PhysActor.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
@ -1557,10 +1557,6 @@ namespace OpenSim.Region.Framework.Scenes
DoPhysicsPropertyUpdate(RigidBody, true); DoPhysicsPropertyUpdate(RigidBody, true);
PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0);
} }
else
{
m_log.DebugFormat("[SOP]: physics actor is null for {0} with parent {1}", UUID, this.ParentGroup.UUID);
}
} }
} }
} }

View File

@ -326,10 +326,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns></returns> /// <returns></returns>
public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource) public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource)
{ {
// m_log.InfoFormat( // m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}",
// "[PRIM INVENTORY]: " + // item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName);
// "Starting script {0}, {1} in prim {2}, {3}",
// item.Name, item.ItemID, Name, UUID);
if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
{ {
@ -362,8 +360,7 @@ namespace OpenSim.Region.Framework.Scenes
string msg = String.Format("asset ID {0} could not be found", item.AssetID); string msg = String.Format("asset ID {0} could not be found", item.AssetID);
StoreScriptError(item.ItemID, msg); StoreScriptError(item.ItemID, msg);
m_log.ErrorFormat( m_log.ErrorFormat(
"[PRIM INVENTORY]: " + "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
"Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
item.Name, item.ItemID, m_part.AbsolutePosition, item.Name, item.ItemID, m_part.AbsolutePosition,
m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
} }
@ -499,8 +496,9 @@ namespace OpenSim.Region.Framework.Scenes
string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID); string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID);
StoreScriptError(itemId, msg); StoreScriptError(itemId, msg);
m_log.ErrorFormat( m_log.ErrorFormat(
"[PRIM INVENTORY]: " + "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
"Couldn't start script with ID {0} since it {1}", itemId, msg); itemId, m_part.Name, m_part.UUID,
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
} }
} }

View File

@ -52,6 +52,30 @@ namespace OpenSim.Region.Framework.Tests
[TestFixture] [TestFixture]
public class TaskInventoryTests public class TaskInventoryTests
{ {
[Test]
public void TestAddTaskInventoryItem()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneHelpers.SetupScene();
UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
SceneObjectPart sop1 = sog1.RootPart;
// Create an object embedded inside the first
UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000");
TaskInventoryItem taskSceneObjectItem
= TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID);
TaskInventoryItem addedItem = sop1.Inventory.GetInventoryItem(taskSceneObjectItemId);
Assert.That(addedItem.ItemID, Is.EqualTo(taskSceneObjectItemId));
Assert.That(addedItem.OwnerID, Is.EqualTo(user1.PrincipalID));
Assert.That(addedItem.ParentID, Is.EqualTo(sop1.UUID));
Assert.That(addedItem.InvType, Is.EqualTo((int)InventoryType.Object));
Assert.That(addedItem.Type, Is.EqualTo((int)AssetType.Object));
}
[Test] [Test]
public void TestRezObjectFromInventoryItem() public void TestRezObjectFromInventoryItem()
{ {
@ -66,7 +90,7 @@ namespace OpenSim.Region.Framework.Tests
// Create an object embedded inside the first // Create an object embedded inside the first
UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000");
TaskInventoryItem taskSceneObjectItem TaskInventoryItem taskSceneObjectItem
= TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId); = TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId, user1.PrincipalID);
scene.AddSceneObject(sog1); scene.AddSceneObject(sog1);

View File

@ -44,7 +44,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
string dirName = myDomain.FriendlyName; string dirName = myDomain.FriendlyName;
string ScriptEnginesPath = myDomain.SetupInformation.PrivateBinPath; string ScriptEnginesPath = myDomain.SetupInformation.PrivateBinPath;
string[] pathList = new string[] {"bin", ScriptEnginesPath, string[] pathList = new string[] {"", "bin", ScriptEnginesPath,
Path.Combine(ScriptEnginesPath, dirName)}; Path.Combine(ScriptEnginesPath, dirName)};
string assemblyName = args.Name; string assemblyName = args.Name;
@ -56,6 +56,8 @@ namespace OpenSim.Region.ScriptEngine.Shared
string path = Path.Combine(Directory.GetCurrentDirectory(), string path = Path.Combine(Directory.GetCurrentDirectory(),
Path.Combine(s, assemblyName))+".dll"; Path.Combine(s, assemblyName))+".dll";
// Console.WriteLine("Trying to resolve {0}", path);
if (File.Exists(path)) if (File.Exists(path))
return Assembly.LoadFrom(path); return Assembly.LoadFrom(path);
} }

View File

@ -28,12 +28,16 @@
using System; using System;
using System.IO; using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using log4net;
using Tools; using Tools;
namespace OpenSim.Region.ScriptEngine.Shared.CodeTools namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
{ {
public class CSCodeGenerator : ICodeConverter public class CSCodeGenerator : ICodeConverter
{ {
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private SYMBOL m_astRoot = null; private SYMBOL m_astRoot = null;
private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap; private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap;
private int m_indentWidth = 4; // for indentation private int m_indentWidth = 4; // for indentation
@ -87,6 +91,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
/// <returns>String containing the generated C# code.</returns> /// <returns>String containing the generated C# code.</returns>
public string Convert(string script) public string Convert(string script)
{ {
// m_log.DebugFormat("[CS CODE GENERATOR]: Converting to C#\n{0}", script);
m_warnings.Clear(); m_warnings.Clear();
ResetCounters(); ResetCounters();
Parser p = new LSLSyntax(new yyLSLSyntax(), new ErrorHandler(true)); Parser p = new LSLSyntax(new yyLSLSyntax(), new ErrorHandler(true));

View File

@ -291,6 +291,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
public void PerformScriptCompile(string Script, string asset, UUID ownerUUID, public void PerformScriptCompile(string Script, string asset, UUID ownerUUID,
out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap) out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap)
{ {
// m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script);
linemap = null; linemap = null;
m_warnings.Clear(); m_warnings.Clear();
@ -357,6 +359,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture)) if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture))
language = enumCompileType.yp; language = enumCompileType.yp;
// m_log.DebugFormat("[Compiler]: Compile language is {0}", language);
if (!AllowedCompilers.ContainsKey(language.ToString())) if (!AllowedCompilers.ContainsKey(language.ToString()))
{ {
// Not allowed to compile to this language! // Not allowed to compile to this language!
@ -417,7 +421,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
} }
assembly = CompileFromDotNetText(compileScript, language, asset, assembly); assembly = CompileFromDotNetText(compileScript, language, asset, assembly);
return;
} }
public string[] GetWarnings() public string[] GetWarnings()
@ -491,6 +494,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
/// <returns>Filename to .dll assembly</returns> /// <returns>Filename to .dll assembly</returns>
internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset, string assembly) internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset, string assembly)
{ {
// m_log.DebugFormat("[Compiler]: Compiling to assembly\n{0}", Script);
string ext = "." + lang.ToString(); string ext = "." + lang.ToString();
// Output assembly name // Output assembly name
@ -531,8 +536,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
parameters.IncludeDebugInformation = true; parameters.IncludeDebugInformation = true;
string rootPath = string rootPath = AppDomain.CurrentDomain.BaseDirectory;
Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, parameters.ReferencedAssemblies.Add(Path.Combine(rootPath,
"OpenSim.Region.ScriptEngine.Shared.dll")); "OpenSim.Region.ScriptEngine.Shared.dll"));

View File

@ -27,44 +27,100 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
using Nini.Config; using Nini.Config;
using NUnit.Framework; using NUnit.Framework;
using OpenSim.Tests.Common.Mock;
using OpenSim.Region.Framework.Scenes;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.Scripting.WorldComm;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.ScriptEngine.XEngine.Tests namespace OpenSim.Region.ScriptEngine.XEngine.Tests
{ {
/// <summary> /// <summary>
/// Scene presence tests /// XEngine tests.
/// </summary> /// </summary>
/// Commented out XEngineTests that don't do anything
/*
[TestFixture] [TestFixture]
public class XEngineTest public class XEngineTest
{ {
public Scene scene; private TestScene m_scene;
private XEngine m_xEngine;
public static Random random; private AutoResetEvent m_chatEvent = new AutoResetEvent(false);
public TestClient testclient; private OSChatMessage m_osChatMessageReceived;
//TestCommunicationsManager cm;
[TestFixtureSetUp] [TestFixtureSetUp]
public void Init() public void Init()
{ {
TestCommunicationsManager cm = new TestCommunicationsManager(); //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin");
scene = SceneSetupHelpers.SetupScene("My Test", UUID.Random(), 1000, 1000, cm); // Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
random = new Random(); m_xEngine = new XEngine();
// Necessary to stop serialization complaining
WorldCommModule wcModule = new WorldCommModule();
IniConfigSource configSource = new IniConfigSource();
IConfig startupConfig = configSource.AddConfig("Startup");
startupConfig.Set("DefaultScriptEngine", "XEngine");
IConfig xEngineConfig = configSource.AddConfig("XEngine");
xEngineConfig.Set("Enabled", "true");
// These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call
// to AssemblyResolver.OnAssemblyResolve fails.
xEngineConfig.Set("AppDomainLoading", "false");
m_scene = SceneHelpers.SetupScene("My Test", UUID.Random(), 1000, 1000, null, configSource);
SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule);
m_scene.StartScripts();
} }
/// <summary>
/// Test compilation and starting of a script.
/// </summary>
/// <remarks>
/// This is a less than ideal regression test since it involves an asynchronous operation (in this case,
/// compilation of the script).
/// </remarks>
[Test] [Test]
public void T001_XStart() public void TestCompileAndStartScript()
{ {
INonSharedRegionModule xengine = new XEngine(); TestHelpers.InMethod();
SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), xengine); // log4net.Config.XmlConfigurator.Configure();
xengine.RegionLoaded(scene);
UUID userId = TestHelpers.ParseTail(0x1);
// UUID objectId = TestHelpers.ParseTail(0x2);
// UUID itemId = TestHelpers.ParseTail(0x3);
string itemName = "TestStartScript() Item";
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "TestStartScriptPart_", 0x100);
m_scene.AddNewSceneObject(so, true);
InventoryItemBase itemTemplate = new InventoryItemBase();
// itemTemplate.ID = itemId;
itemTemplate.Name = itemName;
itemTemplate.Folder = so.UUID;
itemTemplate.InvType = (int)InventoryType.LSL;
m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
m_scene.RezNewScript(userId, itemTemplate);
m_chatEvent.WaitOne(60000);
Assert.That(m_osChatMessageReceived, Is.Not.Null, "No chat message received in TestStartScript()");
Assert.That(m_osChatMessageReceived.Message, Is.EqualTo("Script running"));
}
private void OnChatFromWorld(object sender, OSChatMessage oscm)
{
// Console.WriteLine("Got chat [{0}]", oscm.Message);
m_osChatMessageReceived = oscm;
m_chatEvent.Set();
} }
} }
*/
} }

View File

@ -747,6 +747,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
{ {
// m_log.DebugFormat(
// "[XEngine]: OnRezScript event triggered for script {0}, startParam {1}, postOnRez {2}, engine {3}, stateSource {4}, script\n{5}",
// itemID, startParam, postOnRez, engine, stateSource, script);
if (script.StartsWith("//MRM:")) if (script.StartsWith("//MRM:"))
return; return;
@ -828,6 +832,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
m_CompileDict[itemID] = 0; m_CompileDict[itemID] = 0;
} }
// m_log.DebugFormat("[XEngine]: Added script {0} to compile queue", itemID);
if (m_CurrentCompile == null) if (m_CurrentCompile == null)
{ {
// NOTE: Although we use a lockless queue, the lock here // NOTE: Although we use a lockless queue, the lock here
@ -889,6 +895,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
bool postOnRez = (bool)p[4]; bool postOnRez = (bool)p[4];
StateSource stateSource = (StateSource)p[5]; StateSource stateSource = (StateSource)p[5];
// m_log.DebugFormat("[XEngine]: DoOnRezScript called for script {0}", itemID);
lock (m_CompileDict) lock (m_CompileDict)
{ {
if (!m_CompileDict.ContainsKey(itemID)) if (!m_CompileDict.ContainsKey(itemID))
@ -989,6 +997,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
} }
catch (Exception e) catch (Exception e)
{ {
// m_log.ErrorFormat("[XEngine]: Exception when rezzing script {0}{1}", e.Message, e.StackTrace);
// try // try
// { // {
if (!m_ScriptErrors.ContainsKey(itemID)) if (!m_ScriptErrors.ContainsKey(itemID))
@ -1464,6 +1474,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
string path = Path.Combine(Directory.GetCurrentDirectory(), string path = Path.Combine(Directory.GetCurrentDirectory(),
Path.Combine(s, assemblyName))+".dll"; Path.Combine(s, assemblyName))+".dll";
// Console.WriteLine("[XEngine]: Trying to resolve {0}", path);
if (File.Exists(path)) if (File.Exists(path))
return Assembly.LoadFrom(path); return Assembly.LoadFrom(path);
} }
@ -1949,16 +1961,24 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public void SuspendScript(UUID itemID) public void SuspendScript(UUID itemID)
{ {
// m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID);
IScriptInstance instance = GetInstance(itemID); IScriptInstance instance = GetInstance(itemID);
if (instance != null) if (instance != null)
instance.Suspend(); instance.Suspend();
// else
// m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID);
} }
public void ResumeScript(UUID itemID) public void ResumeScript(UUID itemID)
{ {
// m_log.DebugFormat("[XEngine]: Received request to resume script with ID {0}", itemID);
IScriptInstance instance = GetInstance(itemID); IScriptInstance instance = GetInstance(itemID);
if (instance != null) if (instance != null)
instance.Resume(); instance.Resume();
// else
// m_log.DebugFormat("[XEngine]: Could not find script with ID {0} to resume", itemID);
} }
public bool HasScript(UUID itemID, out bool running) public bool HasScript(UUID itemID, out bool running)

View File

@ -88,9 +88,27 @@ namespace OpenSim.Tests.Common
/// <param name="id">ID of the region</param> /// <param name="id">ID of the region</param>
/// <param name="x">X co-ordinate of the region</param> /// <param name="x">X co-ordinate of the region</param>
/// <param name="y">Y co-ordinate of the region</param> /// <param name="y">Y co-ordinate of the region</param>
/// <param name="cm">This should be the same if simulating two scenes within a standalone</param> /// <param name="cache"></param>
/// <returns></returns> /// <returns></returns>
public static TestScene SetupScene(string name, UUID id, uint x, uint y, CoreAssetCache cache) public static TestScene SetupScene(
string name, UUID id, uint x, uint y, CoreAssetCache cache)
{
return SetupScene(name, id, x, y, cache, new IniConfigSource());
}
/// <summary>
/// Set up a scene. If it's more then one scene, use the same CommunicationsManager to link regions
/// or a different, to get a brand new scene with new shared region modules.
/// </summary>
/// <param name="name">Name of the region</param>
/// <param name="id">ID of the region</param>
/// <param name="x">X co-ordinate of the region</param>
/// <param name="y">Y co-ordinate of the region</param>
/// <param name="cache"></param>
/// <param name="configSource"></param>
/// <returns></returns>
public static TestScene SetupScene(
string name, UUID id, uint x, uint y, CoreAssetCache cache, IConfigSource configSource)
{ {
Console.WriteLine("Setting up test scene {0}", name); Console.WriteLine("Setting up test scene {0}", name);
@ -106,7 +124,6 @@ namespace OpenSim.Tests.Common
ISimulationDataService simDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null); ISimulationDataService simDataService = OpenSim.Server.Base.ServerUtils.LoadPlugin<ISimulationDataService>("OpenSim.Tests.Common.dll", null);
IEstateDataService estateDataService = null; IEstateDataService estateDataService = null;
IConfigSource configSource = new IniConfigSource();
TestScene testScene = new TestScene( TestScene testScene = new TestScene(
regInfo, acm, scs, simDataService, estateDataService, null, false, configSource, null); regInfo, acm, scs, simDataService, estateDataService, null, false, configSource, null);

View File

@ -72,15 +72,21 @@ namespace OpenSim.Tests.Common
/// <param name="sop"></param> /// <param name="sop"></param>
/// <param name="itemName"></param> /// <param name="itemName"></param>
/// <param name="id"></param> /// <param name="id"></param>
public static TaskInventoryItem AddSceneObject(Scene scene, SceneObjectPart sop, string itemName, UUID id) /// <param name="userId"></param>
public static TaskInventoryItem AddSceneObject(
Scene scene, SceneObjectPart sop, string itemName, UUID id, UUID userId)
{ {
SceneObjectGroup taskSceneObject = SceneHelpers.CreateSceneObject(1, UUID.Zero); SceneObjectGroup taskSceneObject = SceneHelpers.CreateSceneObject(1, UUID.Zero);
AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject); AssetBase taskSceneObjectAsset = AssetHelpers.CreateAsset(0x10, taskSceneObject);
scene.AssetService.Store(taskSceneObjectAsset); scene.AssetService.Store(taskSceneObjectAsset);
TaskInventoryItem taskSceneObjectItem TaskInventoryItem taskSceneObjectItem
= new TaskInventoryItem = new TaskInventoryItem
{ Name = itemName, AssetID = taskSceneObjectAsset.FullID, ItemID = id, { Name = itemName,
Type = (int)AssetType.Object, InvType = (int)InventoryType.Object }; AssetID = taskSceneObjectAsset.FullID,
ItemID = id,
OwnerID = userId,
Type = (int)AssetType.Object,
InvType = (int)InventoryType.Object };
sop.Inventory.AddInventoryItem(taskSceneObjectItem, true); sop.Inventory.AddInventoryItem(taskSceneObjectItem, true);
return taskSceneObjectItem; return taskSceneObjectItem;

View File

@ -118,7 +118,7 @@ namespace OpenSim.Tests.Torture
TestScene scene = SceneHelpers.SetupScene(); TestScene scene = SceneHelpers.SetupScene();
Process process = Process.GetCurrentProcess(); // Process process = Process.GetCurrentProcess();
// long startProcessMemory = process.PrivateMemorySize64; // long startProcessMemory = process.PrivateMemorySize64;
long startGcMemory = GC.GetTotalMemory(true); long startGcMemory = GC.GetTotalMemory(true);
DateTime start = DateTime.Now; DateTime start = DateTime.Now;

View File

@ -0,0 +1,157 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Threading;
using log4net;
using Nini.Config;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.Scripting.WorldComm;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.ScriptEngine.XEngine;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Tests.Torture
{
/// <summary>
/// Script torture tests
/// </summary>
/// <remarks>
/// Don't rely on the numbers given by these tests - they will vary a lot depending on what is already cached,
/// how much memory is free, etc. In some cases, later larger tests will apparently take less time than smaller
/// earlier tests.
/// </remarks>
[TestFixture]
public class ScriptTortureTests
{
private TestScene m_scene;
private XEngine m_xEngine;
private AutoResetEvent m_chatEvent = new AutoResetEvent(false);
private int m_expectedChatMessages;
private List<OSChatMessage> m_osChatMessagesReceived = new List<OSChatMessage>();
[SetUp]
public void Init()
{
//AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin");
// Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
m_xEngine = new XEngine();
// Necessary to stop serialization complaining
WorldCommModule wcModule = new WorldCommModule();
IniConfigSource configSource = new IniConfigSource();
IConfig startupConfig = configSource.AddConfig("Startup");
startupConfig.Set("DefaultScriptEngine", "XEngine");
IConfig xEngineConfig = configSource.AddConfig("XEngine");
xEngineConfig.Set("Enabled", "true");
// These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call
// to AssemblyResolver.OnAssemblyResolve fails.
xEngineConfig.Set("AppDomainLoading", "false");
m_scene = SceneHelpers.SetupScene("My Test", UUID.Random(), 1000, 1000, null, configSource);
SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule);
m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
m_scene.StartScripts();
}
[Test]
public void TestCompileAndStart100Scripts()
{
TestHelpers.InMethod();
log4net.Config.XmlConfigurator.Configure();
TestCompileAndStartScripts(100);
}
private void TestCompileAndStartScripts(int scriptsToCreate)
{
UUID userId = TestHelpers.ParseTail(0x1);
m_expectedChatMessages = scriptsToCreate;
int startingObjectIdTail = 0x100;
for (int idTail = startingObjectIdTail;idTail < startingObjectIdTail + scriptsToCreate; idTail++)
{
AddObjectAndScript(idTail, userId);
}
m_chatEvent.WaitOne(40000 + scriptsToCreate * 1000);
Assert.That(m_osChatMessagesReceived.Count, Is.EqualTo(m_expectedChatMessages));
foreach (OSChatMessage msg in m_osChatMessagesReceived)
Assert.That(
msg.Message,
Is.EqualTo("Script running"),
string.Format(
"Message from {0} was {1} rather than {2}", msg.SenderUUID, msg.Message, "Script running"));
}
private void AddObjectAndScript(int objectIdTail, UUID userId)
{
// UUID itemId = TestHelpers.ParseTail(0x3);
string itemName = string.Format("AddObjectAndScript() Item for object {0}", objectIdTail);
SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, "AddObjectAndScriptPart_", objectIdTail);
m_scene.AddNewSceneObject(so, true);
InventoryItemBase itemTemplate = new InventoryItemBase();
// itemTemplate.ID = itemId;
itemTemplate.Name = itemName;
itemTemplate.Folder = so.UUID;
itemTemplate.InvType = (int)InventoryType.LSL;
m_scene.RezNewScript(userId, itemTemplate);
}
private void OnChatFromWorld(object sender, OSChatMessage oscm)
{
// Console.WriteLine("Got chat [{0}]", oscm.Message);
lock (m_osChatMessagesReceived)
{
m_osChatMessagesReceived.Add(oscm);
if (m_osChatMessagesReceived.Count == m_expectedChatMessages)
m_chatEvent.Set();
}
}
}
}

View File

@ -14,6 +14,8 @@
;StorageProvider = "OpenSim.Data.MySQL.dll" ;StorageProvider = "OpenSim.Data.MySQL.dll"
;ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=***;Old Guids=true;" ;ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=***;Old Guids=true;"
; Uncomment this line if you are using MySQL and want to use a different database for estates ; Uncomment this line if you are using MySQL and want to use a different database for estates
; The usual application for this is to allow estates to be spread out across multiple simulators by share the same database.
; Most people won't need to do this so only uncomment if you know what you're doing.
;EstateConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=***;Old Guids=true;" ;EstateConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=***;Old Guids=true;"
; MSSQL ; MSSQL

View File

@ -3318,7 +3318,9 @@
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/> <Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Region.CoreModules"/>
<Reference name="OpenSim.Region.Framework"/> <Reference name="OpenSim.Region.Framework"/>
<Reference name="OpenSim.Region.ScriptEngine.XEngine"/>
<Reference name="OpenSim.Tests.Common"/> <Reference name="OpenSim.Tests.Common"/>
<Files> <Files>
<Match pattern="*.cs" recurse="false"/> <Match pattern="*.cs" recurse="false"/>