Mark tests as not working under TARGET_JVM
[mono.git] / mcs / class / corlib / Test / System.Threading / MutexTest.cs
index 2fa5a2b3082a979756299d10639cdfcab80b9188..6b3289c33ba07d6aaf0d9eaf3bb1b19a130e43a3 100644 (file)
@@ -5,16 +5,16 @@
 // (C) Eduardo Garcia Cebollero\r
 // \r
 \r
-using NUnit.Framework;\r
 using System;\r
 using System.Threading;\r
 \r
+using NUnit.Framework;\r
+\r
 namespace MonoTests.System.Threading\r
 {\r
-\r
-       public class MutexTest : TestCase \r
+       [TestFixture]\r
+       public class MutexTest\r
        {\r
-       \r
                //Auxiliary Classes (Future Threads)\r
                private class ConcClass\r
                {\r
@@ -25,11 +25,11 @@ namespace MonoTests.System.Threading
                                this.id = id;\r
                                this.mut = mut;\r
                        }\r
-                       public void wait()\r
+                       public void Wait()\r
                        {\r
                                mut.WaitOne();\r
                        }\r
-                       public void signal()\r
+                       public void Signal()\r
                        {\r
                                mut.ReleaseMutex();\r
                        }\r
@@ -47,7 +47,7 @@ namespace MonoTests.System.Threading
                        public void WithoutWait()\r
                        {\r
                                this.marker = this.id;\r
-                               this.signal();\r
+                               this.Signal();\r
                        }\r
 \r
 \r
@@ -55,15 +55,15 @@ namespace MonoTests.System.Threading
                        {\r
                                while (this.marker<100)\r
                                {\r
-                                       this.wait();\r
+                                       this.Wait();\r
                                        this.marker++;\r
-                                       this.signal();\r
+                                       this.Signal();\r
                                }\r
                        }\r
 \r
                        public void WaitAndForget()\r
                        {\r
-                               this.wait();\r
+                               this.Wait();\r
                                this.marker = id;\r
                        }\r
                        public void WaitAndWait()\r
@@ -75,24 +75,15 @@ namespace MonoTests.System.Threading
                        }\r
                }\r
 \r
-               protected override void SetUp() {}\r
-\r
-               protected override void TearDown() {}\r
-\r
+               [Test]\r
                public void TestCtor1()\r
                {\r
-                       try\r
-                       {\r
-                               Mutex Sem = new Mutex();\r
-                       }\r
-                       catch (Exception e)\r
-                       {\r
-                               Fail("#01 Error Creating The Simple Mutex:" + e.ToString());\r
-                       }\r
+                       Mutex Sem = new Mutex();\r
                }\r
 \r
 // These tests produce mutex release errors\r
-/*\r
+/**\r
+               [Test]\r
                public void TestCtorDefaultValue()\r
                {\r
                        Mutex Sem = new Mutex();\r
@@ -103,6 +94,7 @@ namespace MonoTests.System.Threading
                        AssertEquals("#02 The default value of The mutex wrong set:",class1.id,class1.marker);\r
                }\r
 \r
+               [Test]\r
                public void TestCtorCtor2()\r
                {\r
                        Mutex Sem = new Mutex(false);\r
@@ -112,7 +104,8 @@ namespace MonoTests.System.Threading
                        while(thread1.IsAlive);\r
                        AssertEquals("#03 The value of The mutex wrong set:",class1.id,class1.marker);\r
                }\r
-               \r
+       \r
+               [Test]\r
                public void TestCtorCtor3()\r
                {\r
                        Mutex Sem = new Mutex(true);\r
@@ -122,27 +115,27 @@ namespace MonoTests.System.Threading
                        while(thread1.IsAlive);\r
                        AssertEquals("#04 The default value of The mutex wrong set:",class1.id,class1.marker);\r
                }\r
-\r
 */\r
-               \r
+\r
                // Hangs #72534\r
+               [Test]\r
                [Category("NotWorking")]\r
                public void TestWaitAndSignal1()\r
                {\r
-                       Mutex Sem = new Mutex(false);\r
-                       ConcClassLoop class1 = new ConcClassLoop(1,Sem);\r
-                       Thread thread1 = new Thread(new ThreadStart(class1.Loop));\r
+                       Mutex Sem = new Mutex (false);\r
+                       ConcClassLoop class1 = new ConcClassLoop (1, Sem);\r
+                       Thread thread1 = new Thread (new ThreadStart (class1.Loop));\r
                        try {\r
-                               thread1.Start();\r
+                               thread1.Start ();\r
                                TestUtil.WaitForNotAlive (thread1, "");\r
-                               AssertEquals("#41 Mutex Worked InCorrecly:",100,class1.marker);\r
-                       }\r
-                       finally {\r
+                               Assert.AreEqual (100, class1.marker);\r
+                       } finally {\r
                                thread1.Abort ();\r
                        }\r
                }\r
 \r
                // Hangs\r
+               [Test]\r
                [Category("NotWorking")]\r
                [Ignore ("It hangs and breaks the domain which runs nunit-console itself")]\r
                public void TestWaitAndFoget1()\r
@@ -160,24 +153,34 @@ namespace MonoTests.System.Threading
                                thread2.Start();\r
                                TestUtil.WaitForNotAlive (thread2, "t2");\r
                        \r
-                               AssertEquals("#51 The Mutex Has been Kept after end of the thread:", class2.id,class2.marker);\r
-                       }\r
-                       finally {\r
+                               Assert.AreEqual (class2.id, class2.marker);\r
+                       } finally {\r
                                thread1.Abort ();\r
                                thread2.Abort ();\r
                        }\r
                }\r
 \r
+               [Test]\r
+               [Category("TargetJvmNotSupported")] // IntPtr native handles are not supported for TARGET_JVM.\r
                public void TestHandle()\r
                {\r
                        Mutex Sem = new Mutex();\r
-                       try\r
-                       {\r
-                               IntPtr Handle = Sem.Handle;\r
-                       }\r
-                       catch (Exception e)\r
-                       {\r
-                               Fail("#61 Unexpected Exception accessing Sem.Handle:" + e.ToString());\r
+                       IntPtr Handle = Sem.Handle;\r
+               }\r
+\r
+               [Test] // bug #79358\r
+               [Category ("NotWorking")]\r
+               public void DoubleRelease ()\r
+               {\r
+                       Mutex mutex = new Mutex ();\r
+                       mutex.WaitOne ();\r
+                       mutex.ReleaseMutex ();\r
+\r
+                       try {\r
+                               mutex.ReleaseMutex ();\r
+                               Assert.Fail ("#1");\r
+                       } catch (ApplicationException ex) {\r
+                               Assert.AreEqual (typeof (ApplicationException), ex.GetType (), "#2");\r
                        }\r
                }\r
        }\r