Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dynamic Instrumentation] DEBUG-2842 Snapshot exploration test #6064

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
96 changes: 68 additions & 28 deletions tracer/build/_build/Build.ExplorationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,45 @@ Target RunExplorationTests
})
;

Target SetUpSnapshotExplorationTests
=> _ => _
.Description("Sets up the Snapshot Exploration Test")
.Requires(() => ExplorationTestUseCase)
.After(Clean, BuildTracerHome)
.Executes(() =>
{
if (ExplorationTestUseCase != global::ExplorationTestUseCase.Debugger)
{
return;
}

GitCloneBuild();
SetUpSnapshotExplorationTestsInternal();
});

Target RunSnapshotExplorationTests
=> _ => _
.Description("Runs the Snapshot Exploration Test")
.Requires(() => ExplorationTestUseCase)
.After(Clean, BuildTracerHome, BuildNativeLoader, SetUpSnapshotExplorationTests)
.Executes(() =>
{
if (ExplorationTestUseCase != global::ExplorationTestUseCase.Debugger)
{
return;
}

// FileSystemTasks.EnsureCleanDirectory(TestLogsDirectory);
try
{
RunSnapshotExplorationTestsInternal();
}
finally
{
CopyDumpsToBuildData();
}
});

Dictionary<string, string> GetEnvironmentVariables(ExplorationTestDescription testDescription, TargetFramework framework)
{
var envVariables = new Dictionary<string, string>
Expand Down Expand Up @@ -224,44 +263,44 @@ void RunUnitTest(ExplorationTestDescription testDescription)

Logger.Information($"Running exploration test {testDescription.Name}.");

if (Framework != null && !testDescription.IsFrameworkSupported(Framework))
{
throw new InvalidOperationException($"The framework '{Framework}' is not listed in the project's target frameworks of {testDescription.Name}");
}

if (Framework == null)
{
foreach (var targetFramework in testDescription.SupportedFrameworks)
{
var envVariables = GetEnvironmentVariables(testDescription, targetFramework);
Test(targetFramework, envVariables);
Test(testDescription, targetFramework, envVariables);
}
}
else
{
if (!testDescription.IsFrameworkSupported(Framework))
{
throw new InvalidOperationException($"The framework '{Framework}' is not listed in the project's target frameworks of {testDescription.Name}");
}

var envVariables = GetEnvironmentVariables(testDescription, Framework);
Test(Framework, envVariables);
Test(testDescription, Framework, envVariables);
}
}

void Test(TargetFramework targetFramework, Dictionary<string, string> envVariables)
{
DotNetTest(
x =>
{
x = x
.SetProjectFile(testDescription.GetTestTargetPath(ExplorationTestsDirectory, targetFramework, BuildConfiguration))
.EnableNoRestore()
.EnableNoBuild()
.SetConfiguration(BuildConfiguration)
.SetFramework(targetFramework)
.SetProcessEnvironmentVariables(envVariables)
.SetIgnoreFilter(testDescription.TestsToIgnore)
.WithMemoryDumpAfter(100)
;

return x;
});
}
void Test(ExplorationTestDescription testDescription, TargetFramework targetFramework, Dictionary<string, string> envVariables)
{
DotNetTest(
x =>
{
x = x
.SetProjectFile(testDescription.GetTestTargetPath(ExplorationTestsDirectory, targetFramework, BuildConfiguration))
.EnableNoRestore()
.EnableNoBuild()
.SetConfiguration(BuildConfiguration)
.SetFramework(targetFramework)
.SetProcessEnvironmentVariables(envVariables)
.SetIgnoreFilter(testDescription.TestsToIgnore)
.WithMemoryDumpAfter(100)
;

return x;
});
}

private void CreateLineProbesIfNeeded()
Expand Down Expand Up @@ -554,7 +593,7 @@ class ExplorationTestDescription

public bool ShouldRun { get; set; } = true;
public bool LineProbesEnabled { get; set; }

public bool IsSnapshotScenario { get; set; }
public string GetTestTargetPath(AbsolutePath explorationTestsDirectory, TargetFramework framework, Configuration buildConfiguration)
{
var projectPath = $"{explorationTestsDirectory}/{Name}/{PathToUnitTestProject}";
Expand Down Expand Up @@ -616,7 +655,8 @@ public static ExplorationTestDescription GetExplorationTestDescription(Explorati
"Google.Protobuf.CodedInputStreamTest.MaliciousRecursion",
"Google.Protobuf.CodedInputStreamTest.MaliciousRecursion_UnknownFields",
"Google.Protobuf.CodedInputStreamTest.RecursionLimitAppliedWhileSkippingGroup",
"Google.Protobuf.JsonParserTest.MaliciousRecursion"
"Google.Protobuf.JsonParserTest.MaliciousRecursion",
"Google.Protobuf.Test.RefStructCompatibilityTest"
},
LineProbesEnabled = true
},
Expand Down
Loading
Loading