Skip to content

Commit

Permalink
Updated RuntimeSystems [f-z].
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed May 22, 2022
1 parent 31a363b commit 01fa5bf
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,42 +185,27 @@ public ConcurrentCollectValueHolder(int value) =>
}

[Description("These tests are verified the IL2C manages tracing the object references and collect garbages from the heap memory.")]
[TestCase("ABCDEF", "ObjRefInsideObjRef", IncludeTypes = new[] { typeof(ObjRefInsideObjRefType) })]
[TestCase("ABCDEF", "ObjRefInsideValueType", IncludeTypes = new[] { typeof(ObjRefInsideValueTypeType) })]
[TestCase("ABCDEF", "ObjRefInsideValueTypeInsideObjRef", IncludeTypes = new[] { typeof(ObjRefInsideValueTypeInsideObjRefType), typeof(ObjRefInsideValueTypeType) })]
[TestCase("ABCDEF", "ObjRefInsideObjRefInsideValueType", IncludeTypes = new[] { typeof(ObjRefInsideObjRefInsideValueTypeType), typeof(ObjRefInsideObjRefType) })]
[TestCase("ABCDEF1", "MultipleInsideValueType", 0, IncludeTypes = new[] { typeof(MultipleInsideValueTypeType), typeof(ObjRefInsideValueTypeType), typeof(ObjRefInsideObjRefType) })]
[TestCase("ABCDEF2", "MultipleInsideValueType", 1, IncludeTypes = new[] { typeof(MultipleInsideValueTypeType), typeof(ObjRefInsideValueTypeType), typeof(ObjRefInsideObjRefType) })]
[TestCase("ABCDEF3", "MultipleInsideValueType", 2, IncludeTypes = new[] { typeof(MultipleInsideValueTypeType), typeof(ObjRefInsideValueTypeType), typeof(ObjRefInsideObjRefType) })]
[TestCase("ABCDEFABCGHI", new[] { "ArrayForObjRefInsideObjRefTypeTracking", "MakeArrayForObjRefInsideObjRefType" }, "ABC", "DEF", "GHI", IncludeTypes = new[] { typeof(ObjRefInsideObjRefType) })]
[TestCase("ABCDEFABCGHI", new[] { "ArrayForObjRefInsideValueTypeTypeTracking", "MakeArrayForObjRefInsideValueTypeType" }, "ABC", "DEF", "GHI", IncludeTypes = new[] { typeof(ObjRefInsideValueTypeType) })]
[TestCase("ABCDEFGHI", new[] { "DelegateMarkHandlerTracking", "MakeDelegateMarkHandlerForObjRefTestDelegate" }, "ABC", "DEF", IncludeTypes = new[] { typeof(DelegateMarkHandlerForObjRef), typeof(DelegateMarkHandlerForObjRefTestDelegate) })]
[TestCase("ABCGHIJKL", new[] { "MulticastDelegateMarkHandlerTracking", "MakeMulticastDelegateMarkHandlerForObjRefTestDelegate" }, "ABC", "DEF", "GHI", IncludeTypes = new[] { typeof(DelegateMarkHandlerForObjRef), typeof(DelegateMarkHandlerForObjRefTestDelegate) })]
[TestCase(12345, new[] { "TraceStaticField", "RunTraceStaticField" }, 12345, IncludeTypes = new[] { typeof(StaticFieldTracible), typeof(StaticFieldInstanceType) })]
[TestCase(1, new[] { "CallFinalizerByCollect", "RunCallFinalizer" }, IncludeTypes = new[] { typeof(FinalzerImplemented), typeof(FinalizerCalleeHolder) })]
[TestCase(1, new[] { "CallFinalizerByCollectWithGeneration", "RunCallFinalizer" }, 0, IncludeTypes = new[] { typeof(FinalzerImplemented), typeof(FinalizerCalleeHolder) })]
[TestCase(1, new[] { "CallFinalizerByCollectWithGeneration", "RunCallFinalizer" }, 1, IncludeTypes = new[] { typeof(FinalzerImplemented), typeof(FinalizerCalleeHolder) })]
[TestCase(1, new[] { "CallFinalizerByCollectWithGeneration", "RunCallFinalizer" }, 2, IncludeTypes = new[] { typeof(FinalzerImplemented), typeof(FinalizerCalleeHolder) })]
[TestCase(0, new[] { "DontCallFinalizerByCollectWithPinned", "RunDontCallFinalizerWithPinned" }, IncludeTypes = new[] { typeof(FinalzerImplementedWithPinned), typeof(FinalizerCalleeHolder) })]
[TestCase(123, new[] { "DontCollectWithResurrect", "RunDontCollectWithResurrect" }, 123, IncludeTypes = new[] { typeof(FinalzerImplementedWithResurrect) })]
[TestCase(2, new[] { "CallFinalizerByCollectWithReRegister", "RunCallFinalizerWithReRegister" }, IncludeTypes = new[] { typeof(FinalzerImplementedWithReRegister), typeof(FinalizerCalleeHolder) })]
[TestCase(0, new[] { "SuppressFinalize", "RunCallFinalizerWithSuppressed" }, IncludeTypes = new[] { typeof(FinalzerImplemented), typeof(FinalizerCalleeHolder) })]
[TestCase(1, new[] { "ReRegisterForFinalize", "RunCallFinalizerWithSuppressedAndReRegistered" }, IncludeTypes = new[] { typeof(FinalzerImplemented), typeof(FinalizerCalleeHolder) })]
[TestCase(200000, "ConcurrentCollect", 10, 100000, IncludeTypes = new[] { typeof(ConcurrentCollectClosure), typeof(ConcurrentCollectValueHolder) })]
public sealed class GarbageCollection
{
[TestCase("ABCDEF", "ObjRefInsideObjRef", IncludeTypes = new[] { typeof(ObjRefInsideObjRefType) })]
[MethodImpl(MethodImplOptions.ForwardRef)]
public static extern string ObjRefInsideObjRef();

[TestCase("ABCDEF", "ObjRefInsideValueType", IncludeTypes = new[] { typeof(ObjRefInsideValueTypeType) })]
[MethodImpl(MethodImplOptions.ForwardRef)]
public static extern string ObjRefInsideValueType();

[TestCase("ABCDEF", "ObjRefInsideValueTypeInsideObjRef", IncludeTypes = new[] { typeof(ObjRefInsideValueTypeInsideObjRefType), typeof(ObjRefInsideValueTypeType) })]
[MethodImpl(MethodImplOptions.ForwardRef)]
public static extern string ObjRefInsideValueTypeInsideObjRef();

[TestCase("ABCDEF", "ObjRefInsideObjRefInsideValueType", IncludeTypes = new[] { typeof(ObjRefInsideObjRefInsideValueTypeType), typeof(ObjRefInsideObjRefType) })]
[MethodImpl(MethodImplOptions.ForwardRef)]
public static extern string ObjRefInsideObjRefInsideValueType();

[TestCase("ABCDEF1", "MultipleInsideValueType", 0, IncludeTypes = new[] { typeof(MultipleInsideValueTypeType), typeof(ObjRefInsideValueTypeType), typeof(ObjRefInsideObjRefType) })]
[TestCase("ABCDEF2", "MultipleInsideValueType", 1, IncludeTypes = new[] { typeof(MultipleInsideValueTypeType), typeof(ObjRefInsideValueTypeType), typeof(ObjRefInsideObjRefType) })]
[TestCase("ABCDEF3", "MultipleInsideValueType", 2, IncludeTypes = new[] { typeof(MultipleInsideValueTypeType), typeof(ObjRefInsideValueTypeType), typeof(ObjRefInsideObjRefType) })]
[MethodImpl(MethodImplOptions.ForwardRef)]
public static extern string MultipleInsideValueType(int index);

Expand All @@ -235,6 +220,7 @@ private static void RunTraceStaticField(int value)
private static ObjRefInsideObjRefType[] MakeArrayForObjRefInsideObjRefType(string a, string b, string c) =>
new[] { new ObjRefInsideObjRefType(a + b), new ObjRefInsideObjRefType(a + c) };

[TestCase("ABCDEFABCGHI", new[] { "ArrayForObjRefInsideObjRefTypeTracking", "MakeArrayForObjRefInsideObjRefType" }, "ABC", "DEF", "GHI", IncludeTypes = new[] { typeof(ObjRefInsideObjRefType) })]
public static string ArrayForObjRefInsideObjRefTypeTracking(string a, string b, string c)
{
// Test for Array_MarkHandler.
Expand All @@ -249,6 +235,7 @@ public static string ArrayForObjRefInsideObjRefTypeTracking(string a, string b,
private static ObjRefInsideValueTypeType[] MakeArrayForObjRefInsideValueTypeType(string a, string b, string c) =>
new[] { new ObjRefInsideValueTypeType(a + b), new ObjRefInsideValueTypeType(a + c) };

[TestCase("ABCDEFABCGHI", new[] { "ArrayForObjRefInsideValueTypeTypeTracking", "MakeArrayForObjRefInsideValueTypeType" }, "ABC", "DEF", "GHI", IncludeTypes = new[] { typeof(ObjRefInsideValueTypeType) })]
public static string ArrayForObjRefInsideValueTypeTypeTracking(string a, string b, string c)
{
// Test for Array_MarkHandler.
Expand All @@ -266,6 +253,7 @@ private static DelegateMarkHandlerForObjRefTestDelegate MakeDelegateMarkHandlerF
return new DelegateMarkHandlerForObjRefTestDelegate(target.CombineForStrings);
}

[TestCase("ABCDEFGHI", new[] { "DelegateMarkHandlerTracking", "MakeDelegateMarkHandlerForObjRefTestDelegate" }, "ABC", "DEF", IncludeTypes = new[] { typeof(DelegateMarkHandlerForObjRef), typeof(DelegateMarkHandlerForObjRefTestDelegate) })]
public static string DelegateMarkHandlerTracking(string a, string b)
{
// Test for Delegate_MarkHandler.
Expand All @@ -286,6 +274,7 @@ private static DelegateMarkHandlerForObjRefTestDelegate MakeMulticastDelegateMar
new DelegateMarkHandlerForObjRefTestDelegate(target2.CombineForStrings);
}

[TestCase("ABCGHIJKL", new[] { "MulticastDelegateMarkHandlerTracking", "MakeMulticastDelegateMarkHandlerForObjRefTestDelegate" }, "ABC", "DEF", "GHI", IncludeTypes = new[] { typeof(DelegateMarkHandlerForObjRef), typeof(DelegateMarkHandlerForObjRefTestDelegate) })]
public static string MulticastDelegateMarkHandlerTracking(string a, string b, string c)
{
// Test for Delegate_MarkHandler (tracks each delegate target)
Expand All @@ -297,6 +286,7 @@ public static string MulticastDelegateMarkHandlerTracking(string a, string b, st
return d("JKL");
}

[TestCase(12345, new[] { "TraceStaticField", "RunTraceStaticField" }, 12345, IncludeTypes = new[] { typeof(StaticFieldTracible), typeof(StaticFieldInstanceType) })]
public static int TraceStaticField(int value)
{
RunTraceStaticField(value);
Expand All @@ -312,6 +302,7 @@ private static void RunCallFinalizer(FinalizerCalleeHolder holder)
var implemented = new FinalzerImplemented(holder);
}

[TestCase(1, new[] { "CallFinalizerByCollect", "RunCallFinalizer" }, IncludeTypes = new[] { typeof(FinalzerImplemented), typeof(FinalizerCalleeHolder) })]
public static int CallFinalizerByCollect()
{
var holder = new FinalizerCalleeHolder();
Expand All @@ -323,6 +314,9 @@ public static int CallFinalizerByCollect()
return holder.Called;
}

[TestCase(1, new[] { "CallFinalizerByCollectWithGeneration", "RunCallFinalizer" }, 0, IncludeTypes = new[] { typeof(FinalzerImplemented), typeof(FinalizerCalleeHolder) })]
[TestCase(1, new[] { "CallFinalizerByCollectWithGeneration", "RunCallFinalizer" }, 1, IncludeTypes = new[] { typeof(FinalzerImplemented), typeof(FinalizerCalleeHolder) })]
[TestCase(1, new[] { "CallFinalizerByCollectWithGeneration", "RunCallFinalizer" }, 2, IncludeTypes = new[] { typeof(FinalzerImplemented), typeof(FinalizerCalleeHolder) })]
public static int CallFinalizerByCollectWithGeneration(int generation)
{
var holder = new FinalizerCalleeHolder();
Expand All @@ -340,6 +334,7 @@ private static void RunDontCallFinalizerWithPinned(FinalizerCalleeHolder holder)
var handle = GCHandle.Alloc(implemented, GCHandleType.Pinned);
}

[TestCase(0, new[] { "DontCallFinalizerByCollectWithPinned", "RunDontCallFinalizerWithPinned" }, IncludeTypes = new[] { typeof(FinalzerImplementedWithPinned), typeof(FinalizerCalleeHolder) })]
public static int DontCallFinalizerByCollectWithPinned()
{
var holder = new FinalizerCalleeHolder();
Expand All @@ -356,6 +351,7 @@ private static void RunDontCollectWithResurrect(int value)
var implemented = new FinalzerImplementedWithResurrect(value);
}

[TestCase(123, new[] { "DontCollectWithResurrect", "RunDontCollectWithResurrect" }, 123, IncludeTypes = new[] { typeof(FinalzerImplementedWithResurrect) })]
public static int DontCollectWithResurrect(int value)
{
RunDontCollectWithResurrect(value);
Expand All @@ -371,6 +367,7 @@ private static void RunCallFinalizerWithReRegister(FinalizerCalleeHolder holder)
var implemented = new FinalzerImplementedWithReRegister(holder);
}

[TestCase(2, new[] { "CallFinalizerByCollectWithReRegister", "RunCallFinalizerWithReRegister" }, IncludeTypes = new[] { typeof(FinalzerImplementedWithReRegister), typeof(FinalizerCalleeHolder) })]
public static int CallFinalizerByCollectWithReRegister()
{
var holder = new FinalizerCalleeHolder();
Expand All @@ -396,6 +393,7 @@ private static void RunCallFinalizerWithSuppressed(FinalizerCalleeHolder holder)
GC.SuppressFinalize(implemented);
}

[TestCase(0, new[] { "SuppressFinalize", "RunCallFinalizerWithSuppressed" }, IncludeTypes = new[] { typeof(FinalzerImplemented), typeof(FinalizerCalleeHolder) })]
public static int SuppressFinalize()
{
var holder = new FinalizerCalleeHolder();
Expand All @@ -414,6 +412,7 @@ private static void RunCallFinalizerWithSuppressedAndReRegistered(FinalizerCalle
GC.ReRegisterForFinalize(implemented);
}

[TestCase(1, new[] { "ReRegisterForFinalize", "RunCallFinalizerWithSuppressedAndReRegistered" }, IncludeTypes = new[] { typeof(FinalzerImplemented), typeof(FinalizerCalleeHolder) })]
public static int ReRegisterForFinalize()
{
var holder = new FinalizerCalleeHolder();
Expand All @@ -425,6 +424,7 @@ public static int ReRegisterForFinalize()
return holder.Called;
}

[TestCase(200000, "ConcurrentCollect", 10, 100000, IncludeTypes = new[] { typeof(ConcurrentCollectClosure), typeof(ConcurrentCollectValueHolder) })]
public static int ConcurrentCollect(int count, int increments)
{
var target = new ConcurrentCollectClosure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,13 @@ public struct NativePointerInside
}

[Description("These tests are verified the IL2C manages interoperability with the P/Invoke adn IL2C/Invoke method and internalcall method.")]
[TestCase(null, new[] { "InternalCallWithUnicodeStringArgument", "OutputDebugString1" }, "ABC", Assert = TestCaseAsserts.IgnoreValidateInvokeResult)]
[TestCase(null, new[] { "DllImportWithUnicodeStringArgument", "OutputDebugString2" }, "ABC", Assert = TestCaseAsserts.IgnoreValidateInvokeResult)]
[TestCase(12345678, "TransparencyForNativePointer", 12345678)]
[TestCase(12345678, "TransparencyForNativePointerInsideNativeType", 12345678, IncludeTypes = new[] { typeof(NativePointerInside) })]
[TestCase("ABCDEF", new[] { "BypassObjRefWithObjRefHandle", "ConcatAndToObjRefHandle" }, "ABC", "DEF")]
public sealed class Interoperability
{
[NativeMethod("windows.h", SymbolName = "OutputDebugStringW", CharSet = NativeCharSet.Unicode)]
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void OutputDebugString1(string message);

[TestCase(null, new[] { "InternalCallWithUnicodeStringArgument", "OutputDebugString1" }, "ABC", Assert = TestCaseAsserts.IgnoreValidateInvokeResult)]
public static void InternalCallWithUnicodeStringArgument(string message)
{
OutputDebugString1(message);
Expand All @@ -41,18 +37,21 @@ public static void InternalCallWithUnicodeStringArgument(string message)
[DllImport("kernel32", EntryPoint = "OutputDebugStringW")]
private static extern void OutputDebugString2(string message);

[TestCase(null, new[] { "DllImportWithUnicodeStringArgument", "OutputDebugString2" }, "ABC", Assert = TestCaseAsserts.IgnoreValidateInvokeResult)]
public static void DllImportWithUnicodeStringArgument(string message)
{
OutputDebugString2(message);
}

[TestCase(12345678, "TransparencyForNativePointer", 12345678)]
public static IntPtr TransparencyForNativePointer(IntPtr value)
{
NativePointer np = value;
IntPtr ip = np;
return ip;
}

[TestCase(12345678, "TransparencyForNativePointerInsideNativeType", 12345678, IncludeTypes = new[] { typeof(NativePointerInside) })]
public static IntPtr TransparencyForNativePointerInsideNativeType(IntPtr value)
{
NativePointerInside npi;
Expand All @@ -68,6 +67,7 @@ private static IntPtr ConcatAndToObjRefHandle(string a, string b)
return GCHandle.ToIntPtr(handle);
}

[TestCase("ABCDEF", new[] { "BypassObjRefWithObjRefHandle", "ConcatAndToObjRefHandle" }, "ABC", "DEF")]
public static string BypassObjRefWithObjRefHandle(string a, string b)
{
var objRefHandle = ConcatAndToObjRefHandle(a, b);
Expand Down
Loading

0 comments on commit 01fa5bf

Please sign in to comment.