aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-16 23:05:08 +0100
committerJustin Clark-Casey (justincc)2011-08-16 23:05:08 +0100
commit57e54d84d641787d40a2b45549f6f2d373c5f2f2 (patch)
tree2a9dfca1ecde4281a59ec682d833c1007ccafbd2
parentMove some previously common code back into separate tests. Remove unused reg... (diff)
downloadopensim-SC_OLD-57e54d84d641787d40a2b45549f6f2d373c5f2f2.zip
opensim-SC_OLD-57e54d84d641787d40a2b45549f6f2d373c5f2f2.tar.gz
opensim-SC_OLD-57e54d84d641787d40a2b45549f6f2d373c5f2f2.tar.bz2
opensim-SC_OLD-57e54d84d641787d40a2b45549f6f2d373c5f2f2.tar.xz
Add new FireAndForgetMethod.None.
This executes the callback on the same thread that made the request. Designed for use only by regression tests that rely on a predicable event ordering.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs12
-rw-r--r--OpenSim/Framework/Util.cs11
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs46
3 files changed, 53 insertions, 16 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 02af5d9..ab4ed66 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -412,12 +412,20 @@ namespace OpenSim.Framework
412 } 412 }
413 413
414 /// <summary> 414 /// <summary>
415 /// Add an attachment, if the attachpoint has the 415 /// Add an attachment
416 /// </summary>
417 /// <remarks>
418 /// If the attachpoint has the
416 /// 0x80 bit set then we assume this is an append 419 /// 0x80 bit set then we assume this is an append
417 /// operation otherwise we replace whatever is 420 /// operation otherwise we replace whatever is
418 /// currently attached at the attachpoint 421 /// currently attached at the attachpoint
422 /// </remarks>
423 /// <param name="attachpoint"></param>
424 /// <param name="item">If UUID.Zero, then an any attachment at the attachpoint is removed.</param>
425 /// <param name="asset"></param>
426 /// <returns>
419 /// return true if something actually changed 427 /// return true if something actually changed
420 /// </summary> 428 /// </returns>
421 public bool SetAttachment(int attachpoint, UUID item, UUID asset) 429 public bool SetAttachment(int attachpoint, UUID item, UUID asset)
422 { 430 {
423 if (attachpoint == 0) 431 if (attachpoint == 0)
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 984a7a8..51ced7b 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -56,8 +56,13 @@ namespace OpenSim.Framework
56 /// <summary> 56 /// <summary>
57 /// The method used by Util.FireAndForget for asynchronously firing events 57 /// The method used by Util.FireAndForget for asynchronously firing events
58 /// </summary> 58 /// </summary>
59 /// <remarks>
60 /// None is used to execute the method in the same thread that made the call. It should only be used by regression
61 /// test code that relies on predictable event ordering.
62 /// </remarks>
59 public enum FireAndForgetMethod 63 public enum FireAndForgetMethod
60 { 64 {
65 None,
61 UnsafeQueueUserWorkItem, 66 UnsafeQueueUserWorkItem,
62 QueueUserWorkItem, 67 QueueUserWorkItem,
63 BeginInvoke, 68 BeginInvoke,
@@ -89,7 +94,8 @@ namespace OpenSim.Framework
89 public static readonly Regex UUIDPattern 94 public static readonly Regex UUIDPattern
90 = new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"); 95 = new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
91 96
92 public static FireAndForgetMethod FireAndForgetMethod = FireAndForgetMethod.SmartThreadPool; 97 public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool;
98 public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod;
93 99
94 /// <summary> 100 /// <summary>
95 /// Gets the name of the directory where the current running executable 101 /// Gets the name of the directory where the current running executable
@@ -1506,6 +1512,9 @@ namespace OpenSim.Framework
1506 1512
1507 switch (FireAndForgetMethod) 1513 switch (FireAndForgetMethod)
1508 { 1514 {
1515 case FireAndForgetMethod.None:
1516 realCallback.Invoke(obj);
1517 break;
1509 case FireAndForgetMethod.UnsafeQueueUserWorkItem: 1518 case FireAndForgetMethod.UnsafeQueueUserWorkItem:
1510 ThreadPool.UnsafeQueueUserWorkItem(realCallback, obj); 1519 ThreadPool.UnsafeQueueUserWorkItem(realCallback, obj);
1511 break; 1520 break;
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index c524090..7f25864 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -37,10 +37,11 @@ using NUnit.Framework;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Communications; 39using OpenSim.Framework.Communications;
40using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.CoreModules.Avatar.Attachments;
41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.CoreModules.World.Serialiser; 41using OpenSim.Region.CoreModules.World.Serialiser;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; 42using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
45using OpenSim.Tests.Common.Mock; 46using OpenSim.Tests.Common.Mock;
46 47
@@ -61,18 +62,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
61 [SetUp] 62 [SetUp]
62 public void Init() 63 public void Init()
63 { 64 {
64 scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); 65 // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
66 Util.FireAndForgetMethod = FireAndForgetMethod.None;
65 67
66 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); 68 scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
67 interregionComms.Initialise(new IniConfigSource()); 69 SceneHelpers.SetupSceneModules(scene, new AttachmentsModule());
68 interregionComms.PostInitialise();
69 SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
70 70
71 agent1 = UUID.Random(); 71 agent1 = UUID.Random();
72 random = new Random(); 72 random = new Random();
73 sog1 = NewSOG(UUID.Random(), scene, agent1); 73 sog1 = NewSOG(UUID.Random(), scene, agent1);
74 sog2 = NewSOG(UUID.Random(), scene, agent1); 74 sog2 = NewSOG(UUID.Random(), scene, agent1);
75 } 75 }
76
77 [TearDown]
78 public void TearDown()
79 {
80 // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
81 // threads. Possibly, later tests should be rewritten not to worry about such things.
82 Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
83 }
76 84
77 [Test] 85 [Test]
78 public void TestAddAttachments() 86 public void TestAddAttachments()
@@ -100,11 +108,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
100 Assert.That(presence.HasAttachments(), Is.False); 108 Assert.That(presence.HasAttachments(), Is.False);
101 } 109 }
102 110
103// [Test] 111 [Test]
104// public void TestRezAttachmentsOnAvatarEntrance() 112 public void TestRezAttachmentsOnAvatarEntrance()
105// { 113 {
106// ScenePresence presence = scene.GetScenePresence(agent1); 114 TestHelpers.InMethod();
107// } 115// log4net.Config.XmlConfigurator.Configure();
116
117 UUID spId = TestHelpers.ParseTail(0x1);
118 UUID attItemId = TestHelpers.ParseTail(0x2);
119 UUID attAssetId = TestHelpers.ParseTail(0x3);
120
121 AgentCircuitData acd = SceneHelpers.GenerateAgentData(spId);
122 acd.Appearance = new AvatarAppearance();
123 acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItemId, attAssetId);
124 ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);
125
126// Assert.That(presence.HasAttachments(), Is.True);
127 }
108 128
109 // I'm commenting this test because scene setup NEEDS InventoryService to 129 // I'm commenting this test because scene setup NEEDS InventoryService to
110 // be non-null 130 // be non-null