aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-02-17 16:51:09 +0000
committerJustin Clarke Casey2009-02-17 16:51:09 +0000
commit4e779bbd8129c8fb0b2c109ca2912265ca85c8a5 (patch)
tree3d805495ea0a58fcd1aba0c3b9eb11f5688f1733
parent* Get rid of a unit test race condition based on my misreading of the AutoRes... (diff)
downloadopensim-SC-4e779bbd8129c8fb0b2c109ca2912265ca85c8a5.zip
opensim-SC-4e779bbd8129c8fb0b2c109ca2912265ca85c8a5.tar.gz
opensim-SC-4e779bbd8129c8fb0b2c109ca2912265ca85c8a5.tar.bz2
opensim-SC-4e779bbd8129c8fb0b2c109ca2912265ca85c8a5.tar.xz
* switch to pulsing monitors to perform test sync instead of events, since this doesn't allow one to accidentally forget to reset the event
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs16
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs28
2 files changed, 28 insertions, 16 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index d1956b4..4e55f21 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -44,12 +44,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
44 [TestFixture] 44 [TestFixture]
45 public class InventoryArchiverTests 45 public class InventoryArchiverTests
46 { 46 {
47 private EventWaitHandle m_waitHandle = new AutoResetEvent(false);
48
49 private void SaveCompleted( 47 private void SaveCompleted(
50 bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException) 48 bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException)
51 { 49 {
52 m_waitHandle.Set(); 50 lock (this)
51 {
52 Monitor.PulseAll(this);
53 }
53 } 54 }
54 55
55 /// <summary> 56 /// <summary>
@@ -109,8 +110,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
109 MemoryStream archiveWriteStream = new MemoryStream(); 110 MemoryStream archiveWriteStream = new MemoryStream();
110 archiverModule.OnInventoryArchiveSaved += SaveCompleted; 111 archiverModule.OnInventoryArchiveSaved += SaveCompleted;
111 112
112 archiverModule.ArchiveInventory(userFirstName, userLastName, "Objects", archiveWriteStream); 113 archiverModule.ArchiveInventory(userFirstName, userLastName, "Objects", archiveWriteStream);
113 m_waitHandle.WaitOne(60000, true); 114
115 lock (this)
116 {
117 archiverModule.ArchiveInventory(userFirstName, userLastName, "Objects", archiveWriteStream);
118 Monitor.Wait(this, 60000);
119 }
114 120
115 /* 121 /*
116 byte[] archive = archiveWriteStream.ToArray(); 122 byte[] archive = archiveWriteStream.ToArray();
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 25fffc4..bde15b3 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -43,11 +43,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
43 [TestFixture] 43 [TestFixture]
44 public class ArchiverTests 44 public class ArchiverTests
45 { 45 {
46 private EventWaitHandle m_waitHandle = new ManualResetEvent(false);
47
48 private void SaveCompleted(string errorMessage) 46 private void SaveCompleted(string errorMessage)
49 { 47 {
50 m_waitHandle.Set(); 48 lock (this)
49 {
50 Monitor.PulseAll(this);
51 }
51 } 52 }
52 53
53 /// <summary> 54 /// <summary>
@@ -103,12 +104,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
103 scene.AddNewSceneObject(new SceneObjectGroup(part2), false); 104 scene.AddNewSceneObject(new SceneObjectGroup(part2), false);
104 } 105 }
105 106
106 MemoryStream archiveWriteStream = new MemoryStream(); 107 MemoryStream archiveWriteStream = new MemoryStream();
107
108 scene.EventManager.OnOarFileSaved += SaveCompleted; 108 scene.EventManager.OnOarFileSaved += SaveCompleted;
109 archiverModule.ArchiveRegion(archiveWriteStream); 109
110 m_waitHandle.WaitOne(60000, true); 110 lock (this)
111 m_waitHandle.Reset(); 111 {
112 archiverModule.ArchiveRegion(archiveWriteStream);
113 Monitor.Wait(this, 60000);
114 }
112 115
113 byte[] archive = archiveWriteStream.ToArray(); 116 byte[] archive = archiveWriteStream.ToArray();
114 MemoryStream archiveReadStream = new MemoryStream(archive); 117 MemoryStream archiveReadStream = new MemoryStream(archive);
@@ -251,9 +254,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
251 254
252 // Write out this scene 255 // Write out this scene
253 scene.EventManager.OnOarFileSaved += SaveCompleted; 256 scene.EventManager.OnOarFileSaved += SaveCompleted;
254 archiverModule.ArchiveRegion(archiveWriteStream); 257
255 m_waitHandle.WaitOne(60000, true); 258 lock (this)
256 m_waitHandle.Reset(); 259 {
260 archiverModule.ArchiveRegion(archiveWriteStream);
261 Monitor.Wait(this, 60000);
262 }
257 } 263 }
258 264
259 { 265 {