From 5b4b349776613d9054e85727f8f6a1f079a5225a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 3 Aug 2013 21:27:32 -0700 Subject: Fix the failing TestSendImage. J2K decoding is async. --- .../Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/UDP') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs index 83144e3..6aa8bcc 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs @@ -29,6 +29,7 @@ using System; using System.IO; using System.Net; using System.Reflection; +using System.Threading; using log4net.Config; using Nini.Config; using NUnit.Framework; @@ -105,7 +106,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests args.requestSequence = 1; llim.EnqueueReq(args); - llim.ProcessImageQueue(20); + + // We now have to wait and hit the processing wheel, because the decoding is async + int i = 10; + while (i-- > 0) + { + llim.ProcessImageQueue(20); + Thread.Sleep(100); + } Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(1)); } -- cgit v1.1 From f9dc5815c4788aefed7eab01fa79709d3921e22a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 5 Aug 2013 23:15:30 +0100 Subject: For LLImageManagerTests, make tests execute under synchronous fire and forget conditions. I generally prefer this approach for regression tests because of the complexity of accounting for different threading conditions. --- .../Linden/UDP/Tests/LLImageManagerTests.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/UDP') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs index 6aa8bcc..575e54c 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs @@ -54,6 +54,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests [TestFixtureSetUp] public void FixtureInit() { + // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. + Util.FireAndForgetMethod = FireAndForgetMethod.None; + using ( Stream resource = GetType().Assembly.GetManifestResourceStream( @@ -73,6 +76,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests } } + [TestFixtureTearDown] + public void TearDown() + { + // 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; + } + [SetUp] public override void SetUp() { @@ -106,14 +117,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests args.requestSequence = 1; llim.EnqueueReq(args); - - // We now have to wait and hit the processing wheel, because the decoding is async - int i = 10; - while (i-- > 0) - { - llim.ProcessImageQueue(20); - Thread.Sleep(100); - } + llim.ProcessImageQueue(20); Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(1)); } -- cgit v1.1