Skip to content
Browse files

2006-04-19 Massimiliano Mantione <massi@ximian.com>

	* Makefile.am: Added tests to see if inline breaks the call stack.
	* test-inline-call-stack.cs: Likewise.
	* test-inline-call-stack-library.cs: Likewise.


svn path=/trunk/mono/; revision=59633
  • Loading branch information...
1 parent f09649a commit 2d609335731a455423d5f282112d342591f89599 Massimiliano Mantione committed Apr 19, 2006
View
5 mono/tests/ChangeLog
@@ -1,3 +1,8 @@
+2006-04-19 Massimiliano Mantione <massi@ximian.com>
+ * Makefile.am: Added tests to see if inline breaks the call stack.
+ * test-inline-call-stack.cs: Likewise.
+ * test-inline-call-stack-library.cs: Likewise.
+
2006-04-12 Zoltan Varga <vargaz@gmail.com>
* thread6.cs: Add regression test for #78024.
View
11 mono/tests/Makefile.am
@@ -275,9 +275,9 @@ EXTRA_DIST=test-driver $(TEST_CS_SRC) $(TEST_CS2_SRC) $(TEST_IL_SRC) $(TEST_IL2_
# mkbundle works on ppc, but the pkg-config POC doesn't when run with make test
if POWERPC
-test: testjit test-type-load
+test: testjit test-type-load test-inline-call-stack
else
-test: testjit testbundle test-type-load
+test: testjit testbundle test-type-load test-inline-call-stack
endif
TestDriver.dll:
@@ -438,6 +438,13 @@ test-type-load: TestDriver.dll
$(MCS) -t:library -out:t.dll $(srcdir)/t-missing.cs
$(RUNTIME) load-exceptions.exe
+test-inline-call-stack-library.dll: TestDriver.dll $(srcdir)/test-inline-call-stack-library.cs
+ $(MCS) -t:library -out:test-inline-call-stack-library.dll $(srcdir)/test-inline-call-stack-library.cs
+test-inline-call-stack.exe: TestDriver.dll test-inline-call-stack-library.dll $(srcdir)/test-inline-call-stack.cs
+ $(MCS) -r:TestDriver.dll -r:test-inline-call-stack-library.dll -out:test-inline-call-stack.exe $(srcdir)/test-inline-call-stack.cs
+test-inline-call-stack: TestDriver.dll test-inline-call-stack-library.dll test-inline-call-stack.exe
+ $(RUNTIME) test-inline-call-stack.exe
+
# Useful if mono is compiled with --enable-shared=no
patch-libtool:
cp "../../libtool" .
View
102 mono/tests/test-inline-call-stack-library.cs
@@ -0,0 +1,102 @@
+using System;
+using System.Diagnostics;
+using System.Reflection;
+
+namespace Library {
+ public class StaticFlag {
+ private static bool _flag = false;
+ public static bool Flag {
+ get {
+ return _flag;
+ }
+ set {
+ _flag = value;
+ }
+ }
+
+ }
+
+ public class CallingAssemblyDependant {
+ private string _calledFrom;
+ public string CalledFrom {
+ get {
+ return _calledFrom;
+ }
+ }
+
+ public CallingAssemblyDependant () {
+ _calledFrom = Assembly.GetCallingAssembly ().GetName ().Name;
+ }
+
+ public static string CalledFromLibrary () {
+ return new CallingAssemblyDependant ().CalledFrom;
+ }
+ }
+
+ public class ResourceRelaxedFieldInit {
+ private static ResourceRelaxedFieldInit _singleResource = new ResourceRelaxedFieldInit ();
+ public static ResourceRelaxedFieldInit Single {
+ get {
+ return _singleResource;
+ }
+ }
+
+ private bool _flag;
+ public bool Flag {
+ get {
+ return _flag;
+ }
+ }
+
+ public ResourceRelaxedFieldInit () {
+ _flag = StaticFlag.Flag;
+ }
+ }
+
+ public class ResourceStrictFieldInit {
+ private static ResourceStrictFieldInit _singleResource = new ResourceStrictFieldInit ();
+ public static ResourceStrictFieldInit Single {
+ get {
+ return _singleResource;
+ }
+ }
+
+ private bool _flag;
+ public bool Flag {
+ get {
+ return _flag;
+ }
+ }
+
+ public ResourceStrictFieldInit () {
+ _flag = StaticFlag.Flag;
+ }
+
+ static ResourceStrictFieldInit () {
+ }
+ }
+
+ public class InlinedMethods {
+ public static MethodBase GetCurrentMethod () {
+ return MethodBase.GetCurrentMethod ();
+ }
+ public static Assembly GetExecutingAssembly () {
+ return Assembly.GetExecutingAssembly ();
+ }
+ public static Assembly GetCallingAssembly () {
+ return Assembly.GetCallingAssembly ();
+ }
+ public static Assembly CallCallingAssembly () {
+ return GetCallingAssembly ();
+ }
+ public static StackFrame GetStackFrame () {
+ return new StackFrame ();
+ }
+ public static ResourceRelaxedFieldInit GetResourceRelaxedFieldInit () {
+ return ResourceRelaxedFieldInit.Single;
+ }
+ public static ResourceStrictFieldInit GetResourceStrictFieldInit () {
+ return ResourceStrictFieldInit.Single;
+ }
+ }
+}
View
74 mono/tests/test-inline-call-stack.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Diagnostics;
+using System.Reflection;
+using Library;
+
+
+namespace Program {
+ public class Test {
+ public static string TestPassed (bool value) {
+ return value ? "PASSED" : "FAILED";
+ }
+ public static string TestFailed (bool value) {
+ return TestPassed (! value);
+ }
+
+ public static int Main () {
+ MethodBase myMethodBase = MethodBase.GetCurrentMethod ();
+ MethodBase inlinedMethodBase = InlinedMethods.GetCurrentMethod ();
+
+ Assembly myExecutingAssembly = Assembly.GetExecutingAssembly ();
+ Assembly inlinedExecutingAssembly = InlinedMethods.GetExecutingAssembly ();
+
+ Assembly myCallingAssembly = Assembly.GetCallingAssembly ();
+ Assembly inlinedCallingAssembly = InlinedMethods.CallCallingAssembly ();
+
+ StackFrame myStackFrame = new StackFrame ();
+ StackFrame inlinedStackFrame = InlinedMethods.GetStackFrame ();
+
+ string myConstructorCalledFrom = new CallingAssemblyDependant ().CalledFrom;
+ string inlinedConstructorCalledFrom = CallingAssemblyDependant.CalledFromLibrary ();
+
+ StaticFlag.Flag = true;
+ bool strictFlag = ResourceStrictFieldInit.Single.Flag;
+ bool relaxedFlag = ResourceRelaxedFieldInit.Single.Flag;
+
+ Console.WriteLine ("[{0}]CurrentMethod: my {1}, inlined {2}, equals {3}",
+ TestFailed (myMethodBase == inlinedMethodBase),
+ myMethodBase.Name, inlinedMethodBase.Name,
+ myMethodBase == inlinedMethodBase);
+
+ Console.WriteLine ("[{0}]ExecutingAssembly: my {1}, inlined {2}, equals {3}",
+ TestFailed (myExecutingAssembly == inlinedExecutingAssembly),
+ myExecutingAssembly.GetName ().Name, inlinedExecutingAssembly.GetName ().Name,
+ myExecutingAssembly == inlinedExecutingAssembly);
+
+ Console.WriteLine ("[{0}]CallingAssembly: my {1}, inlined {2}, equals {3}",
+ TestFailed (myCallingAssembly == inlinedCallingAssembly),
+ myCallingAssembly.GetName ().Name, inlinedCallingAssembly.GetName ().Name,
+ myCallingAssembly == inlinedCallingAssembly);
+
+ Console.WriteLine ("[{0}]StackFrame.GetMethod: my {1}, inlined {2}, equals {3}",
+ TestFailed (myStackFrame.GetMethod ().Name == inlinedStackFrame.GetMethod ().Name),
+ myStackFrame.GetMethod ().Name, inlinedStackFrame.GetMethod ().Name,
+ myStackFrame.GetMethod ().Name == inlinedStackFrame.GetMethod ().Name);
+
+ Console.WriteLine ("[{0}]ConstructorCalledFrom: my {1}, inlined {2}, equals {3}",
+ TestFailed (myConstructorCalledFrom == inlinedConstructorCalledFrom),
+ myConstructorCalledFrom, inlinedConstructorCalledFrom,
+ myConstructorCalledFrom == inlinedConstructorCalledFrom);
+
+ Console.WriteLine ("strictFlag: {0}, relaxedFlag: {1}",
+ strictFlag, relaxedFlag);
+ if ((myMethodBase != inlinedMethodBase) &&
+ (myCallingAssembly != inlinedCallingAssembly) &&
+ (myStackFrame.GetMethod ().Name != inlinedStackFrame.GetMethod ().Name) &&
+ (myConstructorCalledFrom != inlinedConstructorCalledFrom)) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ }
+}
+

0 comments on commit 2d60933

Please sign in to comment.
Something went wrong with that request. Please try again.