From a92153ed88859af9d68b206ec320fc993fe5cdc7 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 6 Mar 2012 02:21:19 +0000 Subject: [PATCH 1/8] Get all test methods in OpenSim.Region.ScriptEngine.Tests.dll to report that they're running --- .../CodeTools/Tests/CSCodeGeneratorTest.cs | 95 +++++++++++++++++++ .../Shared/CodeTools/Tests/CompilerTest.cs | 7 +- .../ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 11 ++- .../Shared/Tests/LSL_TypesTestLSLFloat.cs | 72 +++++++++++--- .../Shared/Tests/LSL_TypesTestLSLInteger.cs | 8 ++ .../Shared/Tests/LSL_TypesTestLSLString.cs | 8 ++ .../Shared/Tests/LSL_TypesTestList.cs | 42 +++++++- .../Shared/Tests/LSL_TypesTestVector3.cs | 9 +- 8 files changed, 227 insertions(+), 25 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs index 63afb0b111..2add011853 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs @@ -29,6 +29,7 @@ using System.Collections.Generic; using System.Text.RegularExpressions; using NUnit.Framework; using OpenSim.Region.ScriptEngine.Shared.CodeTools; +using OpenSim.Tests.Common; namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests { @@ -43,6 +44,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests [Test] public void TestDefaultState() { + TestHelpers.InMethod(); + string input = @"default { state_entry() @@ -63,6 +66,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests [Test] public void TestCustomState() { + TestHelpers.InMethod(); + string input = @"default { state_entry() @@ -93,6 +98,8 @@ state another_state [Test] public void TestEventWithArguments() { + TestHelpers.InMethod(); + string input = @"default { at_rot_target(integer tnum, rotation targetrot, rotation ourrot) @@ -113,6 +120,8 @@ state another_state [Test] public void TestIntegerDeclaration() { + TestHelpers.InMethod(); + string input = @"default { touch_start(integer num_detected) @@ -135,6 +144,8 @@ state another_state [Test] public void TestLoneIdent() { + TestHelpers.InMethod(); + // A lone ident should be removed completely as it's an error in C# // (MONO at least). string input = @"default @@ -161,6 +172,8 @@ state another_state [Test] public void TestAssignments() { + TestHelpers.InMethod(); + string input = @"default { touch_start(integer num_detected) @@ -187,6 +200,8 @@ state another_state [Test] public void TestAdditionSubtractionOperator() { + TestHelpers.InMethod(); + string input = @"default { touch_start(integer num_detected) @@ -215,6 +230,8 @@ state another_state [Test] public void TestStrings() { + TestHelpers.InMethod(); + string input = @"default { touch_start(integer num_detected) @@ -242,6 +259,8 @@ state another_state [Test] public void TestBinaryExpression() { + TestHelpers.InMethod(); + string input = @"default { touch_start(integer num_detected) @@ -284,6 +303,8 @@ state another_state [Test] public void TestFloatConstants() { + TestHelpers.InMethod(); + string input = @"default { touch_start(integer num_detected) @@ -336,6 +357,8 @@ state another_state [Test] public void TestComments() { + TestHelpers.InMethod(); + string input = @"// this test tests comments default { @@ -358,6 +381,8 @@ default [Test] public void TestStringsWithEscapedQuotesAndComments() { + TestHelpers.InMethod(); + string input = @"// this test tests strings, with escaped quotes and comments in strings default { @@ -397,6 +422,8 @@ default [Test] public void TestCStyleComments() { + TestHelpers.InMethod(); + string input = @"/* this test tests comments of the C variety */ @@ -426,6 +453,8 @@ default [Test] public void TestGlobalDefinedFunctions() { + TestHelpers.InMethod(); + string input = @"// this test tests custom defined functions string onefunc() @@ -470,6 +499,8 @@ default [Test] public void TestGlobalDeclaredVariables() { + TestHelpers.InMethod(); + string input = @"// this test tests custom defined functions and global variables string globalString; @@ -525,6 +556,8 @@ default [Test] public void TestMoreAssignments() { + TestHelpers.InMethod(); + string input = @"// this test tests +=, -=, *=, /=, %= string globalString; @@ -579,6 +612,8 @@ default [Test] public void TestVectorConstantNotation() { + TestHelpers.InMethod(); + string input = @"default { touch_start(integer num_detected) @@ -606,6 +641,8 @@ default [Test] public void TestVectorMemberAccess() { + TestHelpers.InMethod(); + string input = @"default { touch_start(integer num_detected) @@ -632,6 +669,8 @@ default [Test] public void TestExpressionInParentheses() { + TestHelpers.InMethod(); + string input = @"default { touch_start(integer num_detected) @@ -660,6 +699,8 @@ default [Test] public void TestIncrementDecrementOperator() { + TestHelpers.InMethod(); + string input = @"// here we'll test the ++ and -- operators default @@ -690,6 +731,8 @@ default [Test] public void TestLists() { + TestHelpers.InMethod(); + string input = @"// testing lists default @@ -718,6 +761,8 @@ default [Test] public void TestIfStatement() { + TestHelpers.InMethod(); + string input = @"// let's test if statements default @@ -822,6 +867,8 @@ default [Test] public void TestIfElseStatement() { + TestHelpers.InMethod(); + string input = @"// let's test complex logical expressions default @@ -928,6 +975,8 @@ default [Test] public void TestWhileLoop() { + TestHelpers.InMethod(); + string input = @"// let's test while loops default @@ -968,6 +1017,8 @@ default [Test] public void TestDoWhileLoop() { + TestHelpers.InMethod(); + string input = @"// let's test do-while loops default @@ -1012,6 +1063,8 @@ default [Test] public void TestForLoop() { + TestHelpers.InMethod(); + string input = @"// let's test for loops default @@ -1056,6 +1109,8 @@ default [Test] public void TestFloatsWithTrailingDecimal() { + TestHelpers.InMethod(); + string input = @"// a curious feature of LSL that allows floats to be defined with a trailing dot default @@ -1108,6 +1163,8 @@ default [Test] public void TestUnaryAndBinaryOperators() { + TestHelpers.InMethod(); + string input = @"// let's test a few more operators default @@ -1144,6 +1201,8 @@ default [Test] public void TestTypecasts() { + TestHelpers.InMethod(); + string input = @"// let's test typecasts default @@ -1189,6 +1248,8 @@ default [Test] public void TestStates() { + TestHelpers.InMethod(); + string input = @"// let's test states default @@ -1229,6 +1290,8 @@ state statetwo [Test] public void TestHexIntegerConstants() { + TestHelpers.InMethod(); + string input = @"// let's test hex integers default @@ -1261,6 +1324,8 @@ default [Test] public void TestJumps() { + TestHelpers.InMethod(); + string input = @"// let's test jumps default @@ -1291,6 +1356,8 @@ default [Test] public void TestImplicitVariableInitialization() { + TestHelpers.InMethod(); + string input = @"// let's test implicitly initializing variables default @@ -1334,6 +1401,8 @@ default [Test] public void TestMultipleEqualsExpression() { + TestHelpers.InMethod(); + string input = @"// let's test x = y = 5 type expressions default @@ -1366,6 +1435,8 @@ default [Test] public void TestUnaryExpressionLastInVectorConstant() { + TestHelpers.InMethod(); + string input = @"// let's test unary expressions some more default @@ -1390,6 +1461,8 @@ default [Test] public void TestVectorMemberPlusEquals() { + TestHelpers.InMethod(); + string input = @"// let's test unary expressions some more default @@ -1424,6 +1497,8 @@ default [Test] public void TestWhileLoopWithNoBody() { + TestHelpers.InMethod(); + string input = @"default { state_entry() @@ -1447,6 +1522,8 @@ default [Test] public void TestDoWhileLoopWithNoBody() { + TestHelpers.InMethod(); + string input = @"default { state_entry() @@ -1472,6 +1549,8 @@ default [Test] public void TestIfWithNoBody() { + TestHelpers.InMethod(); + string input = @"default { state_entry() @@ -1495,6 +1574,8 @@ default [Test] public void TestIfElseWithNoBody() { + TestHelpers.InMethod(); + string input = @"default { state_entry() @@ -1521,6 +1602,8 @@ default [Test] public void TestForLoopWithNoBody() { + TestHelpers.InMethod(); + string input = @"default { state_entry() @@ -1544,6 +1627,8 @@ default [Test] public void TestForLoopWithNoAssignment() { + TestHelpers.InMethod(); + string input = @"default { state_entry() @@ -1569,6 +1654,8 @@ default [Test] public void TestForLoopWithOnlyIdentInAssignment() { + TestHelpers.InMethod(); + string input = @"default { state_entry() @@ -1594,6 +1681,8 @@ default [Test] public void TestAssignmentInIfWhileDoWhile() { + TestHelpers.InMethod(); + string input = @"default { state_entry() @@ -1631,6 +1720,8 @@ default [Test] public void TestLSLListHack() { + TestHelpers.InMethod(); + string input = @"default { state_entry() @@ -1656,6 +1747,8 @@ default [ExpectedException(typeof(System.Exception))] public void TestSyntaxError() { + TestHelpers.InMethod(); + string input = @"default { state_entry() @@ -1682,6 +1775,8 @@ default [ExpectedException(typeof(System.Exception))] public void TestSyntaxErrorDeclaringVariableInForLoop() { + TestHelpers.InMethod(); + string input = @"default { state_entry() diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs index c5483c8e8d..1fa6954d00 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using Microsoft.CSharp; using NUnit.Framework; using OpenSim.Region.ScriptEngine.Shared.CodeTools; +using OpenSim.Tests.Common; namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests { @@ -92,6 +93,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests //[Test] public void TestUseUndeclaredVariable() { + TestHelpers.InMethod(); + m_compilerParameters.OutputAssembly = Path.Combine(m_testDir, Path.GetRandomFileName() + ".dll"); string input = @"default @@ -124,6 +127,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests //[Test] public void TestCastAndConcatString() { + TestHelpers.InMethod(); + m_compilerParameters.OutputAssembly = Path.Combine(m_testDir, Path.GetRandomFileName() + ".dll"); string input = @"string s = "" a string""; @@ -150,4 +155,4 @@ default Assert.AreEqual(0, m_compilerResults.Errors.Count); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 3baa72372c..9cf9258571 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs @@ -46,7 +46,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [TestFixture, LongRunning] public class LSL_ApiTest { - private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; private const float FLOAT_ACCURACY = 0.00005f; @@ -55,7 +54,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [SetUp] public void SetUp() { - IConfigSource initConfigSource = new IniConfigSource(); IConfig config = initConfigSource.AddConfig("XEngine"); config.Set("Enabled", "true"); @@ -75,6 +73,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestllAngleBetween() { + TestHelpers.InMethod(); + CheckllAngleBetween(new Vector3(1, 0, 0), 0, 1, 1); CheckllAngleBetween(new Vector3(1, 0, 0), 90, 1, 1); CheckllAngleBetween(new Vector3(1, 0, 0), 180, 1, 1); @@ -158,6 +158,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // llRot2Euler test. public void TestllRot2Euler() { + TestHelpers.InMethod(); + // 180, 90 and zero degree rotations. CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.0f, 1.0f)); CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.707107f, 0.707107f)); @@ -256,6 +258,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // llSetPrimitiveParams and llGetPrimitiveParams test. public void TestllSetPrimitiveParams() { + TestHelpers.InMethod(); + // Create Prim1. Scene scene = SceneHelpers.SetupScene(); string obj1Name = "Prim1"; @@ -486,9 +490,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests } [Test] - // llVecNorm test. public void TestllVecNorm() { + TestHelpers.InMethod(); + // Check special case for normalizing zero vector. CheckllVecNorm(new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); // Check various vectors. diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs index 10b52cf479..3ed256212e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs @@ -213,6 +213,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestConstructFromInt() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat; foreach (KeyValuePair number in m_intDoubleSet) @@ -228,6 +230,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestConstructFromDouble() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat; foreach (KeyValuePair number in m_doubleDoubleSet) @@ -243,6 +247,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestExplicitCastLSLFloatToInt() { + TestHelpers.InMethod(); + int testNumber; foreach (KeyValuePair number in m_doubleIntSet) @@ -258,6 +264,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestExplicitCastLSLFloatToUint() { + TestHelpers.InMethod(); + uint testNumber; foreach (KeyValuePair number in m_doubleUintSet) @@ -273,6 +281,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestImplicitCastLSLFloatToBooleanTrue() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat; bool testBool; @@ -291,6 +301,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestImplicitCastLSLFloatToBooleanFalse() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat = new LSL_Types.LSLFloat(0.0); bool testBool = testFloat; @@ -303,6 +315,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestImplicitCastIntToLSLFloat() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat; foreach (int number in m_intList) @@ -318,6 +332,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestImplicitCastLSLIntegerToLSLFloat() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat; foreach (int number in m_intList) @@ -333,6 +349,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestExplicitCastLSLIntegerToLSLFloat() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat; foreach (int number in m_intList) @@ -348,6 +366,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestExplicitCastStringToLSLFloat() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat; foreach (KeyValuePair number in m_stringDoubleSet) @@ -363,6 +383,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestExplicitCastLSLStringToLSLFloat() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat; foreach (KeyValuePair number in m_stringDoubleSet) @@ -378,6 +400,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestImplicitCastDoubleToLSLFloat() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat; foreach (double number in m_doubleList) @@ -393,6 +417,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestImplicitCastLSLFloatToDouble() { + TestHelpers.InMethod(); + double testNumber; LSL_Types.LSLFloat testFloat; @@ -411,26 +437,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestExplicitCastLSLFloatToFloat() { - float testFloat; - float numberAsFloat; - LSL_Types.LSLFloat testLSLFloat; - foreach (double number in m_doubleList) - { - testLSLFloat = new LSL_Types.LSLFloat(number); - numberAsFloat = (float)number; - testFloat = (float)testLSLFloat; + TestHelpers.InMethod(); - Assert.That((double)testFloat, new DoubleToleranceConstraint((double)numberAsFloat, _lowPrecisionTolerance)); - } + float testFloat; + float numberAsFloat; + LSL_Types.LSLFloat testLSLFloat; + + foreach (double number in m_doubleList) + { + testLSLFloat = new LSL_Types.LSLFloat(number); + numberAsFloat = (float)number; + testFloat = (float)testLSLFloat; + + Assert.That((double)testFloat, new DoubleToleranceConstraint((double)numberAsFloat, _lowPrecisionTolerance)); + } } - /// /// Tests the equality (==) operator. /// [Test] public void TestEqualsOperator() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloatA, testFloatB; foreach (double number in m_doubleList) @@ -450,6 +480,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestNotEqualOperator() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloatA, testFloatB; foreach (double number in m_doubleList) @@ -469,6 +501,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestIncrementOperator() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat; double testNumber; @@ -493,6 +527,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestDecrementOperator() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat; double testNumber; @@ -517,6 +553,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestToString() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat; foreach (KeyValuePair number in m_doubleStringSet) @@ -532,6 +570,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestAddTwoLSLFloats() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testResult; foreach (KeyValuePair number in m_doubleDoubleSet) @@ -547,6 +587,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestSubtractTwoLSLFloats() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testResult; foreach (KeyValuePair number in m_doubleDoubleSet) @@ -562,6 +604,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestMultiplyTwoLSLFloats() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testResult; foreach (KeyValuePair number in m_doubleDoubleSet) @@ -577,6 +621,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestDivideTwoLSLFloats() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testResult; foreach (KeyValuePair number in m_doubleDoubleSet) @@ -595,6 +641,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestImplicitCastBooleanToLSLFloat() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testFloat; testFloat = (1 == 0); @@ -610,4 +658,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.That(testFloat.value, new DoubleToleranceConstraint(1.0, _lowPrecisionTolerance)); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs index 3ad673bff8..8d1169a37c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs @@ -79,6 +79,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestExplicitCastLSLFloatToLSLInteger() { + TestHelpers.InMethod(); + LSL_Types.LSLInteger testInteger; foreach (KeyValuePair number in m_doubleIntSet) @@ -94,6 +96,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestExplicitCastStringToLSLInteger() { + TestHelpers.InMethod(); + LSL_Types.LSLInteger testInteger; foreach (KeyValuePair number in m_stringIntSet) @@ -109,6 +113,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestExplicitCastLSLStringToLSLInteger() { + TestHelpers.InMethod(); + LSL_Types.LSLInteger testInteger; foreach (KeyValuePair number in m_stringIntSet) @@ -124,6 +130,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestImplicitCastBooleanToLSLInteger() { + TestHelpers.InMethod(); + LSL_Types.LSLInteger testInteger; testInteger = (1 == 0); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs index fa976ed84b..c4ca1a87a8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs @@ -71,6 +71,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestConstructFromLSLFloat() { + TestHelpers.InMethod(); + LSL_Types.LSLString testString; foreach (KeyValuePair number in m_doubleStringSet) @@ -86,6 +88,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestExplicitCastLSLFloatToLSLString() { + TestHelpers.InMethod(); + LSL_Types.LSLString testString; foreach (KeyValuePair number in m_doubleStringSet) @@ -101,6 +105,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestExplicitCastLSLStringToQuaternion() { + TestHelpers.InMethod(); + string quaternionString = "<0.00000, 0.70711, 0.00000, 0.70711>"; LSL_Types.LSLString quaternionLSLString = new LSL_Types.LSLString(quaternionString); @@ -118,6 +124,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestImplicitCastBooleanToLSLFloat() { + TestHelpers.InMethod(); + LSL_Types.LSLString testString; testString = (LSL_Types.LSLString) (1 == 0); diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs index 66a732976d..b81225f799 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs @@ -44,6 +44,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestConcatenateString() { + TestHelpers.InMethod(); + LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test")); testList += new LSL_Types.LSLString("addition"); @@ -64,6 +66,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestConcatenateInteger() { + TestHelpers.InMethod(); + LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test")); testList += new LSL_Types.LSLInteger(20); @@ -84,6 +88,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestConcatenateDouble() { + TestHelpers.InMethod(); + LSL_Types.list testList = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger('a'), new LSL_Types.LSLString("test")); testList += new LSL_Types.LSLFloat(2.0f); @@ -104,6 +110,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestCastLSLIntegerItemToLSLInteger() { + TestHelpers.InMethod(); + LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(123); LSL_Types.list testList = new LSL_Types.list(testValue); @@ -116,6 +124,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestCastLSLFloatItemToLSLFloat() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(123.45678987); LSL_Types.list testList = new LSL_Types.list(testValue); @@ -128,6 +138,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestCastLSLStringItemToLSLString() { + TestHelpers.InMethod(); + LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello there"); LSL_Types.list testList = new LSL_Types.list(testValue); @@ -140,6 +152,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestCastVector3ItemToVector3() { + TestHelpers.InMethod(); + LSL_Types.Vector3 testValue = new LSL_Types.Vector3(12.34, 56.987654, 0.00987); LSL_Types.list testList = new LSL_Types.list(testValue); @@ -151,6 +165,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestCastQuaternionItemToQuaternion() { + TestHelpers.InMethod(); + LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.34, 56.44323, 765.983421, 0.00987); LSL_Types.list testList = new LSL_Types.list(testValue); @@ -165,6 +181,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestGetLSLIntegerItemForLSLIntegerItem() { + TestHelpers.InMethod(); + LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(999911); LSL_Types.list testList = new LSL_Types.list(testValue); @@ -177,6 +195,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestGetLSLFloatItemForLSLFloatItem() { + TestHelpers.InMethod(); + LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(321.45687876); LSL_Types.list testList = new LSL_Types.list(testValue); @@ -189,11 +209,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestGetLSLFloatItemForLSLIntegerItem() { - LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(3060987); - LSL_Types.LSLFloat testFloatValue = new LSL_Types.LSLFloat(testValue); - LSL_Types.list testList = new LSL_Types.list(testValue); + TestHelpers.InMethod(); - Assert.AreEqual(testFloatValue, testList.GetLSLFloatItem(0)); + LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(3060987); + LSL_Types.LSLFloat testFloatValue = new LSL_Types.LSLFloat(testValue); + LSL_Types.list testList = new LSL_Types.list(testValue); + + Assert.AreEqual(testFloatValue, testList.GetLSLFloatItem(0)); } /// @@ -202,6 +224,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestGetLSLStringItemForLSLStringItem() { + TestHelpers.InMethod(); + LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello all"); LSL_Types.list testList = new LSL_Types.list(testValue); @@ -214,6 +238,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestGetLSLStringItemForKeyItem() { + TestHelpers.InMethod(); + LSL_Types.key testValue = new LSL_Types.key("98000000-0000-2222-3333-100000001000"); LSL_Types.LSLString testStringValue = new LSL_Types.LSLString(testValue); @@ -228,6 +254,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestGetVector3ItemForVector3Item() { + TestHelpers.InMethod(); + LSL_Types.Vector3 testValue = new LSL_Types.Vector3(92.34, 58.98754, -0.10987); LSL_Types.list testList = new LSL_Types.list(testValue); @@ -239,6 +267,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestGetQuaternionItemForQuaternionItem() { + TestHelpers.InMethod(); + LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.64, 59.43723, 765.3421, 4.00987); LSL_Types.list testList = new LSL_Types.list(testValue); @@ -251,6 +281,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests [Test] public void TestGetKeyItemForKeyItem() { + TestHelpers.InMethod(); + LSL_Types.key testValue = new LSL_Types.key("00000000-0000-2222-3333-100000001012"); LSL_Types.list testList = new LSL_Types.list(testValue); @@ -258,4 +290,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.AreEqual(testValue, testList.GetKeyItem(0)); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs index 195af7fe4a..ebf8001e0f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs @@ -32,16 +32,17 @@ using OpenSim.Region.ScriptEngine.Shared; namespace OpenSim.Region.ScriptEngine.Shared.Tests { + /// + /// Tests for Vector3 + /// [TestFixture] public class LSL_TypesTestVector3 { - /// - /// Tests for Vector3 - /// [Test] - public void TestDotProduct() { + TestHelpers.InMethod(); + // The numbers we test for. Dictionary expectsSet = new Dictionary(); expectsSet.Add("<1, 2, 3> * <2, 3, 4>", 20.0); From b3449e998ab7fc9a952559821caea6484fc57e6e Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 6 Mar 2012 02:30:22 +0000 Subject: [PATCH 2/8] Fix TestSyntaxError() and TestSyntaxErrorDeclaringVariableInForLoop() They were all failing assertions but the exceptions these threw were caught as expected Exceptions. I don't think we can easily distinguish these from the Exceptions that we're expecting. So for now we'll do some messy manually checking with boolean setting instead. This patch also corrects the assertions themselves. --- .../CodeTools/Tests/CSCodeGeneratorTest.cs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs index 2add011853..776361958e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs @@ -1744,11 +1744,12 @@ default } [Test] - [ExpectedException(typeof(System.Exception))] public void TestSyntaxError() { TestHelpers.InMethod(); + bool gotException = false; + string input = @"default { state_entry() @@ -1764,19 +1765,22 @@ default } catch (System.Exception e) { - // The syntax error is on line 6, char 5 (expected ';', found + // The syntax error is on line 5, char 4 (expected ';', found // '}'). - Assert.AreEqual("(4,4) syntax error", e.Message); - throw; + Assert.AreEqual("(5,4) syntax error", e.Message); + gotException = true; } + + Assert.That(gotException, Is.True); } [Test] - [ExpectedException(typeof(System.Exception))] public void TestSyntaxErrorDeclaringVariableInForLoop() { TestHelpers.InMethod(); + bool gotException = false; + string input = @"default { state_entry() @@ -1792,11 +1796,13 @@ default } catch (System.Exception e) { - // The syntax error is on line 5, char 14 (Syntax error) - Assert.AreEqual("(3,13) syntax error", e.Message); + // The syntax error is on line 4, char 13 (Syntax error) + Assert.AreEqual("(4,13) syntax error", e.Message); - throw; + gotException = true; } + + Assert.That(gotException, Is.True); } } } From 0f4cdc0c5bb750ec4ab7b100dc82d3ff08c9e427 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 6 Mar 2012 19:05:32 +0000 Subject: [PATCH 3/8] Explictly close down the StatsReporter so that we can shutdown its timer This is another step necessary for the scene to be garbage collected between performance tests --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a01b851914..6b285812c8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1076,6 +1076,8 @@ namespace OpenSim.Region.Framework.Scenes { m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName); + StatsReporter.Close(); + m_restartTimer.Stop(); m_restartTimer.Close(); diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 35cd025c01..210f48d669 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -185,6 +185,12 @@ namespace OpenSim.Region.Framework.Scenes OnSendStatsResult += StatsManager.SimExtraStats.ReceiveClassicSimStatsPacket; } + public void Close() + { + m_report.Elapsed -= statsHeartBeat; + m_report.Close(); + } + public void SetUpdateMS(int ms) { statsUpdatesEveryMS = ms; From e9d8eb5a270645ece83c864dbd3c84bf226a57f7 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 6 Mar 2012 22:31:25 +0000 Subject: [PATCH 4/8] Remove unnecessary explicit ElapsedEventHandler in SimReporter --- OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 210f48d669..5c56264ec4 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -178,7 +178,7 @@ namespace OpenSim.Region.Framework.Scenes m_objectCapacity = scene.RegionInfo.ObjectCapacity; m_report.AutoReset = true; m_report.Interval = statsUpdatesEveryMS; - m_report.Elapsed += new ElapsedEventHandler(statsHeartBeat); + m_report.Elapsed += statsHeartBeat; m_report.Enabled = true; if (StatsManager.SimExtraStats != null) From 98251cdab364baf20537a1b5a6260c68e6630ccf Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 6 Mar 2012 23:21:17 +0000 Subject: [PATCH 5/8] Add sensor, dataserver requests, timer and listener counts to "xengine status" command. This is for diagnostic purposes. --- .../Scripting/WorldComm/WorldCommModule.cs | 20 +++++++ .../Region/Framework/Interfaces/IWorldComm.cs | 5 ++ .../Api/Implementation/AsyncCommandManager.cs | 53 ++++++++++++++++++- .../Api/Implementation/Plugins/Dataserver.cs | 9 ++++ .../Api/Implementation/Plugins/Listener.cs | 25 +++++---- .../Implementation/Plugins/SensorRepeat.cs | 12 +++++ .../Api/Implementation/Plugins/Timer.cs | 9 ++++ .../Region/ScriptEngine/XEngine/XEngine.cs | 15 ++++++ 8 files changed, 136 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 640a60be04..ef9b4e069b 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -151,6 +151,14 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm #region IWorldComm Members + public int ListenerCount + { + get + { + return m_listenerManager.ListenerCount; + } + } + /// /// Create a listen event callback with the specified filters. /// The parameters localID,itemID are needed to uniquely identify @@ -438,6 +446,18 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm private int m_maxhandles; private int m_curlisteners; + /// + /// Total number of listeners + /// + public int ListenerCount + { + get + { + lock (m_listeners) + return m_listeners.Count; + } + } + public ListenerManager(int maxlisteners, int maxhandles) { m_maxlisteners = maxlisteners; diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs index dafbf30bfc..e8e375e037 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs @@ -49,6 +49,11 @@ namespace OpenSim.Region.Framework.Interfaces public interface IWorldComm { + /// + /// Total number of listeners + /// + int ListenerCount { get; } + /// /// Create a listen event callback with the specified filters. /// The parameters localID,itemID are needed to uniquely identify diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 14edde41d4..993d10f909 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs @@ -247,7 +247,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Remove Sensors m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); + } + /// + /// Get the sensor repeat plugin for this script engine. + /// + /// + /// + public static SensorRepeat GetSensorRepeatPlugin(IScriptEngine engine) + { + if (m_SensorRepeat.ContainsKey(engine)) + return m_SensorRepeat[engine]; + else + return null; + } + + /// + /// Get the dataserver plugin for this script engine. + /// + /// + /// + public static Dataserver GetDataserverPlugin(IScriptEngine engine) + { + if (m_Dataserver.ContainsKey(engine)) + return m_Dataserver[engine]; + else + return null; + } + + /// + /// Get the timer plugin for this script engine. + /// + /// + /// + public static Timer GetTimerPlugin(IScriptEngine engine) + { + if (m_Timer.ContainsKey(engine)) + return m_Timer[engine]; + else + return null; + } + + /// + /// Get the listener plugin for this script engine. + /// + /// + /// + public static Listener GetListenerPlugin(IScriptEngine engine) + { + if (m_Listener.ContainsKey(engine)) + return m_Listener[engine]; + else + return null; } public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) @@ -270,7 +321,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api data.AddRange(timers); } - Object[] sensors=m_SensorRepeat[engine].GetSerializationData(itemID); + Object[] sensors = m_SensorRepeat[engine].GetSerializationData(itemID); if (sensors.Length > 0) { data.Add("sensor"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs index 7fa19b17a2..9f78a49c0f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs @@ -38,6 +38,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins { public AsyncCommandManager m_CmdManager; + public int DataserverRequestsCount + { + get + { + lock (DataserverRequests) + return DataserverRequests.Count; + } + } + private Dictionary DataserverRequests = new Dictionary(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs index 740816fd08..93e0261da6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs @@ -42,22 +42,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins public AsyncCommandManager m_CmdManager; + private IWorldComm m_commsPlugin; + + public int ListenerCount + { + get { return m_commsPlugin.ListenerCount; } + } + public Listener(AsyncCommandManager CmdManager) { m_CmdManager = CmdManager; + m_commsPlugin = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); } public void CheckListeners() { if (m_CmdManager.m_ScriptEngine.World == null) return; - IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); - if (comms != null) + if (m_commsPlugin != null) { - while (comms.HasMessages()) + while (m_commsPlugin.HasMessages()) { - ListenerInfo lInfo = (ListenerInfo)comms.GetNextMessage(); + ListenerInfo lInfo = (ListenerInfo)m_commsPlugin.GetNextMessage(); //Deliver data to prim's listen handler object[] resobj = new object[] @@ -81,17 +88,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins public Object[] GetSerializationData(UUID itemID) { - IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); - - return comms.GetSerializationData(itemID); + return m_commsPlugin.GetSerializationData(itemID); } public void CreateFromData(uint localID, UUID itemID, UUID hostID, Object[] data) { - IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); - - comms.CreateFromData(localID, itemID, hostID, data); + m_commsPlugin.CreateFromData(localID, itemID, hostID, data); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index fbb7c39265..1c272f8a39 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -44,6 +44,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins public AsyncCommandManager m_CmdManager; + /// + /// Number of sensors active. + /// + public int SensorsCount + { + get + { + lock (SenseRepeatListLock) + return SenseRepeaters.Count; + } + } + public SensorRepeat(AsyncCommandManager CmdManager) { m_CmdManager = CmdManager; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index eeb59d9877..bc63030ec2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs @@ -37,6 +37,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins { public AsyncCommandManager m_CmdManager; + public int TimersCount + { + get + { + lock (TimerListLock) + return Timers.Count; + } + } + public Timer(AsyncCommandManager CmdManager) { m_CmdManager = CmdManager; diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index c68f03ff87..d1cac9c1d3 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -49,7 +49,10 @@ using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenSim.Region.ScriptEngine.Shared.CodeTools; using OpenSim.Region.ScriptEngine.Shared.Instance; +using OpenSim.Region.ScriptEngine.Shared.Api; +using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; using OpenSim.Region.ScriptEngine.Interfaces; +using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; using ScriptCompileQueue = OpenSim.Framework.LocklessQueue; @@ -386,6 +389,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine sb.AppendFormat("Work items waiting : {0}\n", m_ThreadPool.WaitingCallbacks); // sb.AppendFormat("Assemblies loaded : {0}\n", m_Assemblies.Count); + SensorRepeat sr = AsyncCommandManager.GetSensorRepeatPlugin(this); + sb.AppendFormat("Sensors : {0}\n", sr.SensorsCount); + + Dataserver ds = AsyncCommandManager.GetDataserverPlugin(this); + sb.AppendFormat("Dataserver requests : {0}\n", ds.DataserverRequestsCount); + + Timer t = AsyncCommandManager.GetTimerPlugin(this); + sb.AppendFormat("Timers : {0}\n", t.TimersCount); + + Listener l = AsyncCommandManager.GetListenerPlugin(this); + sb.AppendFormat("Listeners : {0}\n", l.ListenerCount); + MainConsole.Instance.OutputFormat(sb.ToString()); } From 33769799233c144a4971efecf25afe1f6ab1d66f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 6 Mar 2012 23:51:50 +0000 Subject: [PATCH 6/8] Remove static m_MainInstance in LocalGridServiceConnector. I believe this was originally required back when there could be two LocalGridServiceConnectors but this is no longer the case. Having such statics makes performance testing much more difficult since they prevent GC of objects unless static references are explicitly nulled. --- .../Grid/LocalGridServiceConnector.cs | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 3c36799050..4f0363a3ec 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -48,8 +48,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - private static LocalGridServicesConnector m_MainInstance; - private IGridService m_GridService; private Dictionary m_LocalCache = new Dictionary(); @@ -62,7 +60,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public LocalGridServicesConnector(IConfigSource source) { m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated"); - m_MainInstance = this; InitialiseService(source); } @@ -87,7 +84,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (name == Name) { InitialiseService(source); - m_MainInstance = this; m_Enabled = true; m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled"); } @@ -126,12 +122,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void PostInitialise() { - if (m_MainInstance == this) - { - MainConsole.Instance.Commands.AddCommand("LocalGridConnector", false, "show neighbours", - "show neighbours", - "Shows the local regions' neighbours", NeighboursCommand); - } + MainConsole.Instance.Commands.AddCommand("LocalGridConnector", false, "show neighbours", + "show neighbours", + "Shows the local regions' neighbours", NeighboursCommand); } public void Close() @@ -143,22 +136,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (m_Enabled) scene.RegisterModuleInterface(this); - if (m_MainInstance == this) - { - if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID)) - m_log.ErrorFormat("[LOCAL GRID CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!"); - else - m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene)); - } + if (m_LocalCache.ContainsKey(scene.RegionInfo.RegionID)) + m_log.ErrorFormat("[LOCAL GRID CONNECTOR]: simulator seems to have more than one region with the same UUID. Please correct this!"); + else + m_LocalCache.Add(scene.RegionInfo.RegionID, new RegionCache(scene)); } public void RemoveRegion(Scene scene) { - if (m_MainInstance == this) - { - m_LocalCache[scene.RegionInfo.RegionID].Clear(); - m_LocalCache.Remove(scene.RegionInfo.RegionID); - } + m_LocalCache[scene.RegionInfo.RegionID].Clear(); + m_LocalCache.Remove(scene.RegionInfo.RegionID); } public void RegionLoaded(Scene scene) @@ -259,6 +246,5 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid MainConsole.Instance.Output(caps.ToString()); } - } -} +} \ No newline at end of file From 23aba007dd0c6e8983feef6fc078b3d5b674ed3a Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 7 Mar 2012 00:04:24 +0000 Subject: [PATCH 7/8] Add documentation to make more explicit the difference between OnRezScript and OnNewScript in the event manager OnNewScript fires when a script is added to a scene OnRezScript fires when the script actually runs (i.e. after permission checks, state retrieval, etc.) --- .../Region/Framework/Scenes/EventManager.cs | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 569c235a1b..6ff2a6f39c 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -138,8 +138,11 @@ namespace OpenSim.Region.Framework.Scenes public event OnPermissionErrorDelegate OnPermissionError; /// - /// Fired when a new script is created. + /// Fired when a script is run. /// + /// + /// Occurs after OnNewScript. + /// public event NewRezScript OnRezScript; public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); @@ -187,10 +190,16 @@ namespace OpenSim.Region.Framework.Scenes public event ClientClosed OnClientClosed; - // Fired when a script is created - // The indication that a new script exists in this region. public delegate void NewScript(UUID clientID, SceneObjectPart part, UUID itemID); + + /// + /// Fired when a script is created. + /// + /// + /// Occurs before OnRezScript + /// public event NewScript OnNewScript; + public virtual void TriggerNewScript(UUID clientID, SceneObjectPart part, UUID itemID) { NewScript handlerNewScript = OnNewScript; @@ -212,10 +221,16 @@ namespace OpenSim.Region.Framework.Scenes } } - //TriggerUpdateScript: triggered after Scene receives client's upload of updated script and stores it as asset - // An indication that the script has changed. public delegate void UpdateScript(UUID clientID, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID); + + /// + /// An indication that the script has changed. + /// + /// + /// Triggered after the scene receives a client's upload of an updated script and has stored it in an asset. + /// public event UpdateScript OnUpdateScript; + public virtual void TriggerUpdateScript(UUID clientId, UUID itemId, UUID primId, bool isScriptRunning, UUID newAssetID) { UpdateScript handlerUpdateScript = OnUpdateScript; From f3678d217f7b1d69faf4aaeb0097348f3d7f91b6 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 7 Mar 2012 00:31:18 +0000 Subject: [PATCH 8/8] Stop individually deleting objects at the end of each ObjectTortureTest. We can now do this since the entire scene and all objects within it are now successfully gc'd at the end of these tests. This greatly improves the time taken to run each test (by reducing teardown time, not the time to actually do the test work that we're interested in). Slightly simplifies config read in Scene constructor to help facilitate this. --- OpenSim/Region/Framework/Scenes/Scene.cs | 49 +++++++++----------- OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 2 +- OpenSim/Tests/Torture/NPCTortureTests.cs | 4 ++ OpenSim/Tests/Torture/ObjectTortureTests.cs | 8 +--- OpenSim/Tests/Torture/ScriptTortureTests.cs | 8 ++++ 5 files changed, 36 insertions(+), 35 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6b285812c8..11e5ce36d2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -628,10 +628,10 @@ namespace OpenSim.Region.Framework.Scenes #region Region Config - try + // Region config overrides global config + // + if (m_config.Configs["Startup"] != null) { - // Region config overrides global config - // IConfig startupConfig = m_config.Configs["Startup"]; m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); @@ -721,46 +721,39 @@ namespace OpenSim.Region.Framework.Scenes m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); } - catch - { - m_log.Warn("[SCENE]: Failed to load StartupConfig"); - } #endregion Region Config #region Interest Management - if (m_config != null) + IConfig interestConfig = m_config.Configs["InterestManagement"]; + if (interestConfig != null) { - IConfig interestConfig = m_config.Configs["InterestManagement"]; - if (interestConfig != null) + string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower(); + + try { - string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower(); - - try - { - m_priorityScheme = (UpdatePrioritizationSchemes)Enum.Parse(typeof(UpdatePrioritizationSchemes), update_prioritization_scheme, true); - } - catch (Exception) - { - m_log.Warn("[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time"); - m_priorityScheme = UpdatePrioritizationSchemes.Time; - } - - m_reprioritizationEnabled = interestConfig.GetBoolean("ReprioritizationEnabled", true); - m_reprioritizationInterval = interestConfig.GetDouble("ReprioritizationInterval", 5000.0); - m_rootReprioritizationDistance = interestConfig.GetDouble("RootReprioritizationDistance", 10.0); - m_childReprioritizationDistance = interestConfig.GetDouble("ChildReprioritizationDistance", 20.0); + m_priorityScheme = (UpdatePrioritizationSchemes)Enum.Parse(typeof(UpdatePrioritizationSchemes), update_prioritization_scheme, true); } + catch (Exception) + { + m_log.Warn("[PRIORITIZER]: UpdatePrioritizationScheme was not recognized, setting to default prioritizer Time"); + m_priorityScheme = UpdatePrioritizationSchemes.Time; + } + + m_reprioritizationEnabled = interestConfig.GetBoolean("ReprioritizationEnabled", true); + m_reprioritizationInterval = interestConfig.GetDouble("ReprioritizationInterval", 5000.0); + m_rootReprioritizationDistance = interestConfig.GetDouble("RootReprioritizationDistance", 10.0); + m_childReprioritizationDistance = interestConfig.GetDouble("ChildReprioritizationDistance", 20.0); } - m_log.InfoFormat("[SCENE]: Using the {0} prioritization scheme", m_priorityScheme); + m_log.DebugFormat("[SCENE]: Using the {0} prioritization scheme", m_priorityScheme); #endregion Interest Management StatsReporter = new SimStatsReporter(this); StatsReporter.OnSendStatsResult += SendSimStatsPackets; - StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; + StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; } /// diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 8a69d7c21b..7bf08ae702 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -136,7 +136,7 @@ namespace OpenSim.Tests.Common StartAuthenticationService(testScene); LocalInventoryServicesConnector inventoryService = StartInventoryService(testScene); StartGridService(testScene); - LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); + LocalUserAccountServicesConnector userAccountService = StartUserAccountService(testScene); LocalPresenceServicesConnector presenceService = StartPresenceService(testScene); inventoryService.PostInitialise(); diff --git a/OpenSim/Tests/Torture/NPCTortureTests.cs b/OpenSim/Tests/Torture/NPCTortureTests.cs index 8078d9dfab..65732dbc1f 100644 --- a/OpenSim/Tests/Torture/NPCTortureTests.cs +++ b/OpenSim/Tests/Torture/NPCTortureTests.cs @@ -75,6 +75,10 @@ namespace OpenSim.Tests.Torture [TestFixtureTearDown] public void TearDown() { + scene.Close(); + GC.Collect(); + GC.WaitForPendingFinalizers(); + // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple // threads. Possibly, later tests should be rewritten not to worry about such things. Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; diff --git a/OpenSim/Tests/Torture/ObjectTortureTests.cs b/OpenSim/Tests/Torture/ObjectTortureTests.cs index e83186a929..7e9946b17b 100644 --- a/OpenSim/Tests/Torture/ObjectTortureTests.cs +++ b/OpenSim/Tests/Torture/ObjectTortureTests.cs @@ -156,11 +156,6 @@ namespace OpenSim.Tests.Torture // objects will be clean up by the garbage collector before the next stress test is run. scene.Update(); - // Currently, we need to do this in order to garbage collect the scene objects ready for the next test run. - // However, what we really need to do is find out why the entire scene is not garbage collected in - // teardown. - scene.DeleteAllSceneObjects(); - Console.WriteLine( "Took {0}ms, {1}MB ({2} - {3}) to create {4} objects each containing {5} prim(s)", Math.Round(elapsed.TotalMilliseconds), @@ -170,7 +165,8 @@ namespace OpenSim.Tests.Torture objectsToAdd, primsInEachObject); - scene = null; + scene.Close(); +// scene = null; } } } \ No newline at end of file diff --git a/OpenSim/Tests/Torture/ScriptTortureTests.cs b/OpenSim/Tests/Torture/ScriptTortureTests.cs index d94bbde680..87932cb7f8 100644 --- a/OpenSim/Tests/Torture/ScriptTortureTests.cs +++ b/OpenSim/Tests/Torture/ScriptTortureTests.cs @@ -91,6 +91,14 @@ namespace OpenSim.Tests.Torture m_scene.StartScripts(); } + [TearDown] + public void TearDown() + { + m_scene.Close(); + GC.Collect(); + GC.WaitForPendingFinalizers(); + } + [Test] public void TestCompileAndStart100Scripts() {