Author: spouliot
Date: 2005-05-13 09:07:59 -0400 (Fri, 13 May 2005)
New Revision: 44497

Added:
   trunk/mono/mono/tests/cas/threads/tpool1.cs
   trunk/mono/mono/tests/cas/threads/tpool2.cs
Modified:
   trunk/mono/mono/tests/cas/threads/ChangeLog
   trunk/mono/mono/tests/cas/threads/Makefile
   trunk/mono/mono/tests/cas/threads/README
Log:
2005-05-13  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * tpool1-2.cs: New. ThreadPool based tests.



Modified: trunk/mono/mono/tests/cas/threads/ChangeLog
===================================================================
--- trunk/mono/mono/tests/cas/threads/ChangeLog 2005-05-13 13:01:50 UTC (rev 
44496)
+++ trunk/mono/mono/tests/cas/threads/ChangeLog 2005-05-13 13:07:59 UTC (rev 
44497)
@@ -1,3 +1,7 @@
+2005-05-13  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * tpool1-2.cs: New. ThreadPool based tests.
+
 2005-05-12  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * delegate1-2.cs: Updated to use ControlEvidence.

Modified: trunk/mono/mono/tests/cas/threads/Makefile
===================================================================
--- trunk/mono/mono/tests/cas/threads/Makefile  2005-05-13 13:01:50 UTC (rev 
44496)
+++ trunk/mono/mono/tests/cas/threads/Makefile  2005-05-13 13:07:59 UTC (rev 
44497)
@@ -3,16 +3,19 @@
 PROFILE = net_1_1
 
 all:   thread1.exe thread2.exe thread3.exe \
+       tpool1.exe tpool2.exe \
        timer1.exe timer2.exe swf-timer3.exe swf-timer4.exe \
        delegate1.exe delegate2.exe \
        swf-control1.exe
 
 aot:   thread1.exe.so thread2.exe.so thread3.exe.so \
+       tpool1.exe.so tpool2.exe.so \
        timer1.exe.so timer2.exe.so swf-timer3.exe.so swf-timer4.exe.so \
        delegate1.exe.so delegate2.exe.so \
        swf-control1.exe.so
 
 FULLTRUST_TEST_FILES = thread1 thread2 thread3 \
+       tpool1 tpool2 \
        timer1 timer2 swf-timer3 swf-timer4 \
        delegate1 delegate2 \
        swf-control1

Modified: trunk/mono/mono/tests/cas/threads/README
===================================================================
--- trunk/mono/mono/tests/cas/threads/README    2005-05-13 13:01:50 UTC (rev 
44496)
+++ trunk/mono/mono/tests/cas/threads/README    2005-05-13 13:07:59 UTC (rev 
44497)
@@ -27,6 +27,9 @@
 
 * swf-control1.cs: Use Control.BeginInvoke to test stack propagation.
 
+* tpool1.cs:   Use ThreadPool.QueueUserWorkItem to test stack propagation.
+* tpool2.cs:   Use ThreadPool.UnsafeQueueUserWorkItem to test non-propagation
+               of the stack.
 
 Notes:
 

Added: trunk/mono/mono/tests/cas/threads/tpool1.cs
===================================================================
--- trunk/mono/mono/tests/cas/threads/tpool1.cs 2005-05-13 13:01:50 UTC (rev 
44496)
+++ trunk/mono/mono/tests/cas/threads/tpool1.cs 2005-05-13 13:07:59 UTC (rev 
44497)
@@ -0,0 +1,53 @@
+using System;
+using System.Security;
+using System.Security.Permissions;
+using System.Threading;
+
+class Program {
+
+       static void ShowStackTrace (object o)
+       {
+               if (debug)
+                       Console.WriteLine ((int)o);
+
+               try {
+                       Console.WriteLine (Environment.UserName);
+                       result = 1;
+               }
+               catch (SecurityException se) {
+                       if (debug)
+                               Console.WriteLine ("EXPECTED SecurityException 
{0}", se);
+               }
+               catch (Exception ex) {
+                       Console.WriteLine ("UNEXPECTED {0}", ex);
+                       result = 1;
+               }
+       }
+
+       static bool debug;
+       static int result = 0;
+
+       // this Deny will prevent the Environment.UserName property from working
+       [EnvironmentPermission (SecurityAction.Deny, Read = "USERNAME")]
+       static int Main (string[] args)
+       {
+               debug = (args.Length > 0);
+               if (debug) {
+                       SecurityManager.SecurityEnabled = (args [0] != "off");
+               }
+
+               if (SecurityManager.SecurityEnabled) {
+                       Console.WriteLine ("SecurityManager.SecurityEnabled: 
true");
+                       ShowStackTrace ((object)-1);
+               } else {
+                       Console.WriteLine ("SecurityManager.SecurityEnabled: 
false");
+               }
+
+               result = 0;
+               for (int i=0; i < 5; i++)
+                       ThreadPool.QueueUserWorkItem (new WaitCallback 
(ShowStackTrace), i);
+               
+               System.Threading.Thread.Sleep (5000);
+               return result;
+       }
+}

Added: trunk/mono/mono/tests/cas/threads/tpool2.cs
===================================================================
--- trunk/mono/mono/tests/cas/threads/tpool2.cs 2005-05-13 13:01:50 UTC (rev 
44496)
+++ trunk/mono/mono/tests/cas/threads/tpool2.cs 2005-05-13 13:07:59 UTC (rev 
44497)
@@ -0,0 +1,54 @@
+using System;
+using System.Security;
+using System.Security.Permissions;
+using System.Threading;
+
+class Program {
+
+       static void ShowStackTrace (object o)
+       {
+               if (debug)
+                       Console.WriteLine ((int)o);
+
+               try {
+                       Console.WriteLine (Environment.UserName);
+                       result = 0;
+               }
+               catch (SecurityException se) {
+                       Console.WriteLine ("UNEXPECTED SecurityException {0}", 
se);
+                       result = 1;
+               }
+               catch (Exception ex) {
+                       Console.WriteLine ("UNEXPECTED {0}", ex);
+                       result = 1;
+               }
+       }
+
+       static bool debug;
+       static int result = 0;
+
+       // this Deny will *NOT* prevent the Environment.UserName property from 
working
+       // as the UnsafeQueueUserWorkItem method *DOESN'T* propagate the stack
+       [EnvironmentPermission (SecurityAction.Deny, Read = "USERNAME")]
+       static int Main (string[] args)
+       {
+               debug = (args.Length > 0);
+               if (debug) {
+                       SecurityManager.SecurityEnabled = (args [0] != "off");
+               }
+
+               if (SecurityManager.SecurityEnabled) {
+                       Console.WriteLine ("SecurityManager.SecurityEnabled: 
true");
+                       ShowStackTrace ((object)-1);
+               } else {
+                       Console.WriteLine ("SecurityManager.SecurityEnabled: 
false");
+               }
+
+               result = 0;
+               for (int i=0; i < 5; i++)
+                       ThreadPool.UnsafeQueueUserWorkItem (new WaitCallback 
(ShowStackTrace), i);
+               
+               System.Threading.Thread.Sleep (5000);
+               return result;
+       }
+}

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to