Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/tests/JIT/Stress/ABI/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ internal class Config
internal const string InstantiatingStubPrefix = "ABIStress_InstantiatingStub_";

internal static StressModes StressModes { get; set; } = StressModes.None;

private const int DefaultSeed = 20010415;
// The base seed. This value combined with the index of the
// caller/pinvoker/callee will uniquely determine how it is generated
// and which callee is used.
internal const int Seed = 0xeadbeef;
internal static int Seed { get; set; } = Environment.GetEnvironmentVariable("CORECLR_SEED") switch
{
string seedStr when seedStr.Equals("random", StringComparison.OrdinalIgnoreCase) => new Random().Next(),
string seedStr when int.TryParse(seedStr, out int envSeed) => envSeed,
_ => DefaultSeed
};
internal const int MinParams = 1;
internal static int MaxParams { get; set; } = 25;
// The number of callees to use. When stressing tailcalls, this is the number of tailcallee parameter lists to pregenerate.
Expand Down
2 changes: 1 addition & 1 deletion src/tests/JIT/Stress/ABI/PInvokes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal partial class Program
private static bool DoPInvokes(int callerIndex)
{
string callerName = Config.PInvokerPrefix + callerIndex;
Random rand = new Random(Seed);
Random rand = new Random(GetSeed(callerName));
List<TypeEx> pms = RandomParameters(s_allTypes, rand);

int calleeIndex = rand.Next(0, Config.NumCallees);
Expand Down
10 changes: 1 addition & 9 deletions src/tests/JIT/Stress/ABI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ namespace ABIStress
{
internal partial class Program
{
private const int DefaultSeed = 20010415;
private static int Seed = Environment.GetEnvironmentVariable("CORECLR_SEED") switch
{
string seedStr when seedStr.Equals("random", StringComparison.OrdinalIgnoreCase) => new Random().Next(),
string seedStr when int.TryParse(seedStr, out int envSeed) => envSeed,
_ => DefaultSeed
};

private static int Main(string[] args)
{
static void Usage()
Expand Down Expand Up @@ -175,7 +167,7 @@ private static bool DoCall(int index)

private static Callee CreateCallee(string name, TypeEx[] candidateParamTypes)
{
Random rand = new Random(Seed);
Random rand = new Random(GetSeed(name));
List<TypeEx> pms = RandomParameters(candidateParamTypes, rand);
var tc = new Callee(name, pms);
return tc;
Expand Down
10 changes: 1 addition & 9 deletions src/tests/JIT/Stress/ABI/Stubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ namespace ABIStress
{
public class StubsTestHelpers
{
private const int DefaultSeed = 20010415;
private static int Seed = Environment.GetEnvironmentVariable("CORECLR_SEED") switch
{
string seedStr when seedStr.Equals("random", StringComparison.OrdinalIgnoreCase) => new Random().Next(),
string seedStr when int.TryParse(seedStr, out int envSeed) => envSeed,
_ => DefaultSeed
};

public static void CompareNumbers(int actual, int expected)
{
if (actual != expected)
Expand Down Expand Up @@ -122,7 +114,7 @@ private static bool DoStubCall(int callerIndex, bool staticMethod, bool onValueT
{
string callerNameSeed = Config.InstantiatingStubPrefix + "Caller" + callerIndex; // Use a consistent seed value here so that the various various of unboxing/instantiating stubs are generated with the same arg shape
string callerName = callerNameSeed + (staticMethod ? "Static" : "Instance") + (onValueType ? "Class" : "ValueType") + typeGenericShape.ToString() + methodGenericShape.ToString();
Random rand = new Random(Seed);
Random rand = new Random(GetSeed(callerName));
List<TypeEx> pms;
do
{
Expand Down
2 changes: 1 addition & 1 deletion src/tests/JIT/Stress/ABI/TailCalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ private static bool DoTailCall(int callerIndex)
}

string callerName = Config.TailCallerPrefix + callerIndex;
Random rand = new Random(Seed);
Random rand = new Random(GetSeed(callerName));
List<TypeEx> callerParams;
List<Callee> callable;
do
Expand Down