svn path=/trunk/mono/; revision=41835
authorSebastien Pouliot <sebastien@ximian.com>
Tue, 15 Mar 2005 13:04:26 +0000 (13:04 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Tue, 15 Mar 2005 13:04:26 +0000 (13:04 -0000)
mono/tests/cas/demand/Makefile
mono/tests/cas/demand/README
mono/tests/cas/demand/selfassert.cs [new file with mode: 0644]
mono/tests/cas/demand/selfdeny.cs [new file with mode: 0644]
mono/tests/cas/demand/selfpermit.cs [new file with mode: 0644]

index 50b6286792e3c1dcf41ea68461dc51eeb44bc862..d15b9aba9ed51243df72a6ad4f6c21a92eec8249 100644 (file)
@@ -3,13 +3,16 @@ CSCOMPILE = mcs --debug
 PROFILE = net_1_1
 
 all:   pinvoke1.exe pinvoke2.exe pinvoke3.exe \
-       sucs1.exe sucs2.exe sucs3.exe sucs4.exe 
+       sucs1.exe sucs2.exe sucs3.exe sucs4.exe \
+       selfassert.exe selfdeny.exe selfpermit.exe
 
 aot:   pinvoke1.exe.so pinvoke2.exe.so pinvoke3.exe.so \
-       sucs1.exe.so sucs2.exe.so sucs3.exe.so sucs4.exe.so 
+       sucs1.exe.so sucs2.exe.so sucs3.exe.so sucs4.exe.so \
+       selfassert.exe.so selfdeny.exe.so selfpermit.exe.so
 
 FULLTRUST_TEST_FILES = pinvoke1 pinvoke2 pinvoke3 \
-       sucs1 sucs2 sucs3 sucs4
+       sucs1 sucs2 sucs3 sucs4 \
+       selfassert selfdeny selfpermit
 
 UNHANDLED_TEST_FILES = 
 
index d9ffa86d3db4dd8b900939e5eff03093e1210d5f..0a389f2626081d5822163d63cf3284a565066db2 100644 (file)
@@ -27,3 +27,17 @@ sucs4.cs     Call native code with [SUCS] attributes at both class and
 Notes
 - With Mono runtime the native function getuid is called in libc
 - With MS runtime the native function GetTickCount is called in kernel32.dll
+
+
+** Self
+
+Stack walk starts at the caller frame - i.e. the current frame is ignored. The
+self*.cs tests ensure that the walk starts at the right frame (or at least 
+that it ignore the caller frame).
+
+selfassert.cs  Deny on caller, Assert and Demand on callee. Assert is 
+               ignored, Demand is executed and fail on caller's Deny.
+selfdeny.cs    Deny and Demand on the same frame. Deny is ignored. Demand is
+               executed (stack walk).
+selfpermit.cs  PermitOnly Unmanaged, Demand ControlAppDomain. PermitOnly is
+               ignored and Demand (for ControlAppDomain) succeed.
diff --git a/mono/tests/cas/demand/selfassert.cs b/mono/tests/cas/demand/selfassert.cs
new file mode 100644 (file)
index 0000000..740ebe0
--- /dev/null
@@ -0,0 +1,28 @@
+using System;
+using System.Security;
+using System.Security.Permissions;
+
+public class Program {
+
+       [SecurityPermission (SecurityAction.Assert, UnmanagedCode=true)]
+       [SecurityPermission (SecurityAction.Demand, UnmanagedCode=true)]
+       static int Test ()
+       {
+               return 1;
+       }
+
+       [SecurityPermission (SecurityAction.Deny, UnmanagedCode=true)]
+       static int Main ()
+       {
+               int result = 2;
+               try {
+                       result = Test ();
+                       Console.WriteLine ("*1* Unexpected call to Test");
+               }
+               catch (SecurityException se) {
+                       result = 0;
+                       Console.WriteLine ("*0* Expected SecurityException\n{0}", se);
+               }
+               return result;
+       }
+}
diff --git a/mono/tests/cas/demand/selfdeny.cs b/mono/tests/cas/demand/selfdeny.cs
new file mode 100644 (file)
index 0000000..98fc405
--- /dev/null
@@ -0,0 +1,18 @@
+using System;
+using System.Security.Permissions;
+
+public class Program {
+
+       [SecurityPermission (SecurityAction.Deny, UnmanagedCode=true)]
+       [SecurityPermission (SecurityAction.Demand, UnmanagedCode=true)]
+       static int Test ()
+       {
+               Console.WriteLine ("*0* Expected call to Test()");
+               return 0;
+       }
+
+       static int Main ()
+       {
+               return Test ();
+       }
+}
diff --git a/mono/tests/cas/demand/selfpermit.cs b/mono/tests/cas/demand/selfpermit.cs
new file mode 100644 (file)
index 0000000..5ee50e7
--- /dev/null
@@ -0,0 +1,19 @@
+using System;
+using System.Security;
+using System.Security.Permissions;
+
+public class Program {
+
+       [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode=true)]
+       [SecurityPermission (SecurityAction.Demand, ControlAppDomain=true)]
+       static int Test ()
+       {
+               Console.WriteLine ("*0* Expected call to Test()");
+               return 0;
+       }
+
+       static int Main ()
+       {
+               return Test ();
+       }
+}