From: Sebastien Pouliot Date: Tue, 15 Mar 2005 13:04:26 +0000 (-0000) Subject: svn path=/trunk/mono/; revision=41835 X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=e80b099f7dec4b7890b869783074bbbd7cfbf67e;p=mono.git svn path=/trunk/mono/; revision=41835 --- diff --git a/mono/tests/cas/demand/Makefile b/mono/tests/cas/demand/Makefile index 50b6286792e..d15b9aba9ed 100644 --- a/mono/tests/cas/demand/Makefile +++ b/mono/tests/cas/demand/Makefile @@ -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 = diff --git a/mono/tests/cas/demand/README b/mono/tests/cas/demand/README index d9ffa86d3db..0a389f26260 100644 --- a/mono/tests/cas/demand/README +++ b/mono/tests/cas/demand/README @@ -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 index 00000000000..740ebe036f0 --- /dev/null +++ b/mono/tests/cas/demand/selfassert.cs @@ -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 index 00000000000..98fc405bcc7 --- /dev/null +++ b/mono/tests/cas/demand/selfdeny.cs @@ -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 index 00000000000..5ee50e75915 --- /dev/null +++ b/mono/tests/cas/demand/selfpermit.cs @@ -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 (); + } +}