microsoft / Windows-driver-samples

This repo contains driver samples prepared for use with Microsoft Visual Studio and the Windows Driver Kit (WDK). It contains both Universal Windows Driver and desktop-only driver samples.
Microsoft Public License
6.76k stars 4.89k forks source link

Build System: Catch Sporadic Failures #1123

Closed JakobL-MSFT closed 4 months ago

JakobL-MSFT commented 4 months ago

This PR enable retry logic to catch sporadic failures.

We /can/ do this now because samples in general are building extremely cleanly and Failures are mostly unexpected events. (If we expect lots of failures, then retrying would take a lot of time)

We /should/ do this now because we have dramatically extended the number of combinations each build takes and the number of branches we test against. What is perhaps only happening in 1 of 5000 combinations will statistically happens once if you build 125 drivers across 4 flavors across 10 builds.

How it works: Specifically, whenever a build failure occur for a given (Driver, Configuration, Platform) combination (say, video/indirectdisplay, Debug, arm64) the tool will re-run up to three times. If all three builds results in failure, then the tool will mark the combination as indeed a failure. If, however, on the second or third attempt, a successful build occurs, then the tool will mark the combination "Sporadic".

Note: We should still pursue "Sporadic" failures. This PR helps isolate these from true Failures and allows other progress to me made.

Example:

(Assume 3 passing samples, 1 sample with a Failure, and 1 sample with a Sporadic failure)


>.\Build-AllSamples.ps1 -Samples '^tools"
...
Building all combinations...

Some combinations were built with errors:
Build errors in Sample tools.dv.samples.dv-faildriver-wdm.driver; Configuration: Debug; Platform: arm64 {
C:\wdstest\wdstest-tmp\ewdk\EWDK_ge_release_26063_240216-1326\Program Files\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: The build tools for WindowsKernelModeDriver12.0 (Platform Toolset = 'WindowsKernelModeDriver12.0') cannot be found. To build using the WindowsKernelModeDriver12.0 build tools, please install WindowsKernelModeDriver12.0 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\wdstest\wdstest-tmp\git\develop\tools\dv\samples\DV-FailDriver-WDM\driver\defect_toastmon.vcxproj]
} tools.dv.samples.dv-faildriver-wdm.driver Debug|arm64
Write-Error: C:\wdstest\wdstest-tmp\git\develop\Build-AllSamples.ps1:71
Line |
  71 |  .\Build-SampleSet -SampleSet $sampleSet -Configurations $Configuratio …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Some combinations were built with errors.

Some combinations were built with sporadic error:
Build sporadic errors in Sample tools.sdv.samples.sdv-faildriver-wdm; Configuration: Debug; Platform: x64 {
C:\wdstest\wdstest-tmp\ewdk\EWDK_ge_release_26063_240216-1326\Program Files\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: The build tools for WindowsKernelModeDriver12.0 (Platform Toolset = 'WindowsKernelModeDriver12.0') cannot be found. To build using the WindowsKernelModeDriver12.0 build tools, please install WindowsKernelModeDriver12.0 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\wdstest\wdstest-tmp\git\develop\tools\sdv\samples\SDV-FailDriver-WDM\driver\fail_driver1.vcxproj]
} tools.sdv.samples.sdv-faildriver-wdm Debug|x64
Write-Error: C:\wdstest\wdstest-tmp\git\develop\Build-AllSamples.ps1:71
Line |
  71 |  .\Build-SampleSet -SampleSet $sampleSet -Configurations $Configuratio …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Some combinations were built with sporadic errors.

Built all combinations.

Elapsed time:         0 minutes, 32 seconds.
Disk Remaining (GB):  182.792900085449
Samples:              5
Configurations:       2 (Debug Release)
Platforms:            2 (x64 arm64)
Combinations:         20
Succeeded:            18
Excluded:             0
Unsupported:          0
Failed:               1
Sporadic:             1
Log files directory:  C:\wdstest\wdstest-tmp\git\develop\_logs
Overview report:      C:\wdstest\wdstest-tmp\git\develop\_logs\_overview.htm
JakobL-MSFT commented 4 months ago

I tested this further. Here are results. Essence: Works really well.

Here is what I ran:

    Build-Samples $ewdk_ge_release_eeap_26058        "user/jakobl/build_catch_sporadic_failures"
    Build-Samples $ewdk_ge_release_eeap_26063        "user/jakobl/build_catch_sporadic_failures"
    Build-Samples $ewdk_ge_release_latest            "user/jakobl/build_catch_sporadic_failures"
    Build-Samples $ewdk_ge_release_sigma             "user/jakobl/build_catch_sporadic_failures"
    Build-Samples $ewdk_ge_release_sigma_dev         "user/jakobl/build_catch_sporadic_failures"
    Build-Samples $ewdk_rs_prerelease                "user/jakobl/build_catch_sporadic_failures"
    Build-Samples $ewdk_rs_sparc                     "user/jakobl/build_catch_sporadic_failures"
    Build-Samples $ewdk_ge_release_prs               "user/jakobl/build_catch_sporadic_failures"

So 8 full builds. Each with 130 drivers and 4 flavors. That is 520 combinations. Total of 4120 combinations across all 8 EWDKs.

Sporadic Failures:

Actual Failures:

Runtime:


Log for Host x64:

...
WDSTest: 2024-02-20 18:57:34: Build-Samples EWDK_ge_release_26058_240209-1555 user/jakobl/build_catch_sporadic_failures {
Build Environment:          (8 different EWDKs)
Build Number:               (Varies)
Samples:                    130
Configurations:             2 (Debug Release)
Platforms:                  2 (x64 arm64)
InfVerif_AdditionalOptions: /samples
Combinations:               520
LogicalProcessors:          12
ThrottleFactor:             5
ThrottleLimit:              60
...
Failed:               0
Sporadic:             0
...
Build sporadic errors in Sample storage.class.classpnp; Configuration: Release; Platform: arm64 {
D:\wdstest\wdstest-tmp\ewdk\EWDK_ge_release_26063_240216-1326\Program Files\Windows Kits\10\build\10.0.26063.0\WindowsDriver.common.targets(937,5): error MSB6003: The specified task executable "tracewpp.exe" could not be run. System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. [D:\wdstest\wdstest-tmp\run\storage\class\classpnp\src\classpnp.vcxproj]
...
Failed:               0
Sporadic:             1
---
Failed:               0
Sporadic:             0
---
Failed:               0
Sporadic:             0
---
Build sporadic errors in Sample wmi.wmisamp; Configuration: Debug; Platform: x64 {
D:\wdstest\wdstest-tmp\ewdk\EWDK_ge_release_sigma_dev_26062_240216-1700\Program Files\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(2027,5): error MSB6003: The specified task executable "rc.exe" could not be run. System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. [D:\wdstest\wdstest-tmp\run\wmi\wmisamp\WmiSamp.vcxproj]
...
Failed:               0
Sporadic:             1
...
Build sporadic errors in Sample nfp.net; Configuration: Release; Platform: x64 {
D:\wdstest\wdstest-tmp\ewdk\EWDK_rs_prerelease_27562_240216-1514\Program Files\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(1151,5): error MSB6003: The specified task executable "link.exe" could not be run. System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open. [D:\wdstest\wdstest-tmp\run\nfp\net\exe\NetNfpControl.vcxproj]
...
Failed:               0
Sporadic:             1
...
Failed:               0
Sporadic:             0
...
Failed:               0
Sporadic:             0
...
WDSTest: 2024-02-20 21:41:02: Build-Samples EWDK_ge_release_prs_26063_240216-1342 user/jakobl/build_catch_sporadic_failures }