-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix repo reference Signed-off-by: Alan Jowett <[email protected]> * Nuget restore Signed-off-by: Alan Jowett <[email protected]> * Setup repo Signed-off-by: Alan Jowett <[email protected]> * Export program info Signed-off-by: Alan Jowett <[email protected]> * Add wprp file Signed-off-by: Alan Jowett <[email protected]> * Set analyze options for external repos Signed-off-by: Alan Jowett <[email protected]> * Fix static analysis failures Signed-off-by: Alan Jowett <[email protected]> * Add test scripts Signed-off-by: Alan Jowett <[email protected]> * Enable simple tests Signed-off-by: Alan Jowett <[email protected]> * Add address sanitizer pass Signed-off-by: Alan Jowett <[email protected]> * Remove unspported tests Signed-off-by: Alan Jowett <[email protected]> --------- Signed-off-by: Alan Jowett <[email protected]> Co-authored-by: Alan Jowett <[email protected]>
- Loading branch information
1 parent
337196d
commit 92edf14
Showing
12 changed files
with
236 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (c) Microsoft Corporation | ||
SPDX-License-Identifier: MIT | ||
--> | ||
<RuleSet Name="External rules" Description="Override parent ruleset" ToolsVersion="16.0"> | ||
<Include Path="..\Analyze.default.ruleset" Action="Default" /> | ||
<Rules AnalyzerId="Microsoft.Analyzers.NativeCodeAnalysis" RuleNamespace="Microsoft.Rules.Native"> | ||
<!-- Arithmetic overflow: Using operator 'operator' on a size-a byte value and then casting the result to a size-b byte value. Cast the value to the wider type before calling operator 'operator' to avoid overflow --> | ||
<Rule Id="C26451" Action="Warning" /> | ||
<!-- Variable '%variable%' is uninitialized. Always initialize a member variable (type.6). --> | ||
<Rule Id="C26495" Action="Warning" /> | ||
<!-- Warning C26812: Prefer 'enum class' over 'enum' (Enum.3) --> | ||
<Rule Id="C26812" Action="Warning" /> | ||
<!-- "This kind of function may not throw. Declare it 'noexcept'." --> | ||
<Rule Id="C26439" Action="Warning" /> | ||
<!-- Arithmetic overflow: '%operator%' operation causes overflow at compile time. Use a wider type to store the operands --> | ||
<Rule Id="C26450" Action="Warning" /> | ||
<!-- Unannotated fallthrough between switch labels (es.78). --> | ||
<Rule Id="C26819" Action="Warning" /> | ||
<!-- Potentially expensive copy of variable name in range-for loop. Consider making it a const reference (es.71). --> | ||
<Rule Id="C26817" Action="Warning" /> | ||
<!-- Assigning by value when a const-reference would suffice, use const auto& instead (p.9). --> | ||
<Rule Id="C26820" Action="Warning" /> | ||
<!-- Don't try to declare a local variable with no name (es.84) --> | ||
<Rule Id="C26444" Action="Warning" /> | ||
</Rules> | ||
</RuleSet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (c) Microsoft Corporation | ||
SPDX-License-Identifier: MIT | ||
--> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" TreatAsLocalProperty="Platform"> | ||
<!-- Override the rules for projects that are not under control of this project --> | ||
<PropertyGroup Condition="'$(Analysis)'=='True' AND '$(AnalysisOnExternal)'=='True'"> | ||
<DisableAnalyzeExternal>true</DisableAnalyzeExternal> | ||
<RunCodeAnalysis>true</RunCodeAnalysis> | ||
<CodeAnalysisRuleSet>$(SolutionDir)external\Analyze.external.ruleset</CodeAnalysisRuleSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(AddressSanitizer)'=='True' OR '$(Fuzzer)'=='True' OR '$(Configuration)'=='FuzzerDebug'"> | ||
<EnableASAN>true</EnableASAN> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Fuzzer)'=='True' OR '$(Configuration)'=='FuzzerDebug'"> | ||
<AdditionalOptions>/fsanitize-coverage=inline-bool-flag /fsanitize-coverage=edge /fsanitize-coverage=trace-cmp /fsanitize-coverage=trace-div /ZH:SHA_256 %(AdditionalOptions)</AdditionalOptions> | ||
<FuzzerLibs>libsancov.lib;clang_rt.fuzzer_MDd-x86_64.lib</FuzzerLibs> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup> | ||
<Link> | ||
<AdditionalLibraryDirectories>$(VC_LibraryPath_VC_x64_Desktop);%(Link.AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'"> | ||
<ClCompile> | ||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> | ||
<WholeProgramOptimization Condition="'$(EnableASAN)' != 'true'">true</WholeProgramOptimization> | ||
<TreatWarningAsError>false</TreatWarningAsError> | ||
</ClCompile> | ||
<Link> | ||
<AdditionalOptions Condition="'$(EnableASAN)' != 'true'">/spgo %(AdditionalOptions)</AdditionalOptions> | ||
<LinkTimeCodeGeneration Condition="'$(EnableASAN)' != 'true'">UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug' OR '$(Configuration)'=='FuzzerDebug'"> | ||
<ClCompile> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> | ||
<TreatWarningAsError>false</TreatWarningAsError> | ||
</ClCompile> | ||
</ItemDefinitionGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright (c) Microsoft Corporation | ||
# SPDX-License-Identifier: MIT | ||
|
||
# This script executes the provided test command, waits for <timeout in seconds> | ||
# and then captures a dump of the test process if it is still running. The dump | ||
# is captured using the procdump tool from Sysinternals. The dump is saved to | ||
# the <output folder> with the name of the test executable and the current date | ||
# and time. | ||
|
||
# Modifying $args directly can cause issues, so copy it to a new variable. | ||
$arguments = $args | ||
|
||
# Check that the correct number of arguments have been provided. | ||
if ($arguments.Count -eq 0) { | ||
Write-Output "Usage: Run-Test.ps1 <output folder> <timeout in seconds> <test command> <test arguments>" | ||
exit 1 | ||
} | ||
|
||
# Extract the output folder and timeout from the arguments. | ||
$OutputFolder = $arguments[0] | ||
$arguments = $arguments[1..($arguments.Length - 1)] | ||
$Timeout = [int]$arguments[0] | ||
$arguments = $arguments[1..($arguments.Length - 1)] | ||
|
||
# Start the test process using the provided command and arguments. | ||
# This can't use Start-Process as that doesn't save exit code and always returns 0. | ||
$processInfo = New-Object System.Diagnostics.ProcessStartInfo | ||
$processInfo.UseShellExecute = $false | ||
$processInfo.FileName = $arguments[0] | ||
$processInfo.Arguments = $arguments[1..($arguments.Length - 1)] -join ' ' | ||
|
||
$process = New-Object System.Diagnostics.Process | ||
$process.StartInfo = $processInfo | ||
$process.Start() | Out-Null | ||
|
||
if (!$process.WaitForExit($Timeout * 1000)) { | ||
$dumpFileName = "$($process.ProcessName)_$(Get-Date -Format 'yyyy-MM-dd_HH-mm-ss').dmp" | ||
$dumpFilePath = Join-Path $OutputFolder $dumpFileName | ||
Write-Output "Capturing dump of $($process.ProcessName) to $dumpFilePath" | ||
Start-Process -NoNewWindow -Wait -FilePath procdump -ArgumentList "-accepteula -ma $($process.Id) $dumpFilePath" | ||
if (!$process.HasExited) { | ||
Write-Output "Killing $($process.ProcessName)" | ||
$process.Kill() | ||
} | ||
} | ||
|
||
Write-Output "Test $($process.ProcessName) exited with code $($process.ExitCode)" | ||
exit $process.ExitCode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (c) Microsoft Corporation | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Define the commands to run | ||
$commands = @( | ||
"git submodule update --init --recursive", | ||
"cmake -G 'Visual Studio 17 2022' -S external\catch2 -B external\catch2\build -DBUILD_TESTING=OFF", | ||
"nuget restore ntosebpfext.sln", | ||
"packages\eBPF-for-Windows.0.15.1\build\native\bin\export_program_info.exe" | ||
) | ||
|
||
# Loop through each command and run them sequentially without opening a new window | ||
foreach ($command in $commands) { | ||
Write-Host ">> Running command: $command" | ||
Invoke-Expression -Command $command | ||
|
||
# Check the exit code | ||
if ($LASTEXITCODE -ne 0) { | ||
Write-Host "Command failed. Exit code: $LASTEXITCODE" | ||
Exit $LASTEXITCODE | ||
} | ||
} | ||
Write-Host "All commands succeeded." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
Copyright (c) Microsoft Corporation | ||
SPDX-License-Identifier: MIT | ||
--> | ||
<WindowsPerformanceRecorder Version="1.0" Author="Microsoft Corporation" Copyright="Microsoft Corporation" Company="Microsoft Corporation"> | ||
<Profiles> | ||
<EventCollector Id="EventCollector_EbpfCoreProvider" Name="EbpfCoreProvider"> | ||
<BufferSize Value="256" /> | ||
<Buffers Value="1024" /> | ||
</EventCollector> | ||
|
||
<EventProvider Id="ExecutionContext" Name="394f321c-5cf4-404c-aa34-4df1428a7f9c" NonPagedMemory="true"/> | ||
<EventProvider Id="NtosEbpfExt" Name="d15cc421-e9e4-459b-87a6-b45b7d84e9a8" NonPagedMemory="true"/> | ||
|
||
<Profile | ||
Id="EbpfForWindowsProvider-File.Verbose.File" | ||
Name="EbpfForWindowsProvider-File" | ||
Description="Traces for all eBPF for Windows providers" | ||
LoggingMode="File" | ||
DetailLevel="Verbose"> | ||
<Collectors> | ||
<EventCollectorId Value="EventCollector_EbpfCoreProvider"> | ||
<EventProviders> | ||
<EventProviderId Value="ExecutionContext"/> | ||
</EventProviders> | ||
<EventProviders> | ||
<EventProviderId Value="NtosEbpfExt"/> | ||
</EventProviders> | ||
</EventCollectorId> | ||
</Collectors> | ||
</Profile> | ||
|
||
<Profile | ||
Id="EbpfForWindowsProvider-Memory.Verbose.Memory" | ||
Name="EbpfForWindowsProvider-Memory" | ||
Description="Traces for all eBPF for Windows providers" | ||
LoggingMode="Memory" | ||
DetailLevel="Verbose"> | ||
<Collectors> | ||
<EventCollectorId Value="EventCollector_EbpfCoreProvider"> | ||
<EventProviders> | ||
<EventProviderId Value="ExecutionContext"/> | ||
</EventProviders> | ||
<EventProviders> | ||
<EventProviderId Value="NtosEbpfExt"/> | ||
</EventProviders> | ||
</EventCollectorId> | ||
</Collectors> | ||
</Profile> | ||
|
||
</Profiles> | ||
</WindowsPerformanceRecorder> |
Oops, something went wrong.