Skip to content

Fix EnableDisableTests flakiness by removing shared static state#2484

Open
krwq with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-enable-disable-tests-flakiness
Open

Fix EnableDisableTests flakiness by removing shared static state#2484
krwq with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-enable-disable-tests-flakiness

Conversation

Copilot AI commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

EnableDisableTests used static readonly fields for GpioDriverMock and GpioController, shared across all test instances. Parallel test execution caused one test to close/reset pin 1 on the shared mock while another test's device was mid-Enable(), throwing InvalidOperationException: Pin 1 is not yet opened.

  • Mcp23xxxTest.cs: Added nullable ResetDriverMock property and constructor overload to TestDevice struct (backward-compatible with existing tests)
  • EnableDisableTests.cs: Removed static s_driverMock/s_gpioMock fields. Each test device in ResetTestDevices now creates its own isolated GpioDriverMock. InitialResetState creates a local GpioController from the per-device mock.
// Before: single static mock shared across all tests
private static readonly GpioDriverMock s_driverMock = new GpioDriverMock();
devices.Add(new TestDevice(new Mcp23008(i2c, reset: 1, controller: new GpioController(s_driverMock)), i2c.DeviceMock));

// After: each test device gets its own mock
driverMock = new GpioDriverMock();
devices.Add(new TestDevice(new Mcp23008(i2c, reset: 1, controller: new GpioController(driverMock)), i2c.DeviceMock, driverMock));

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 1oavsblobprodcus350.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/tools/ArduinoCsCompiler/ArduinoCsCompiler.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/src/devices/Arduino/Arduino.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • 1s1vsblobprodcus386.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/src/System.Device.Gpio/System.Device.Gpio.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/tools/ArduinoCsCompiler/ArduinoCsCompiler.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/tools/DevicesApiTester/DeviceApiTester.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • 2kmvsblobprodcus39.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build /p:SkipArcadeSdkImport=true (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build /p:TreatWarningsAsErrors=false --nologo (dns block)
  • 37bvsblobprodcus311.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build Mcp23xxx.csproj (dns block)
  • 37cvsblobprodcus359.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build Mcp23xxx.csproj (dns block)
  • 4m6vsblobprodcus384.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
  • 4vyvsblobprodcus361.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/samples/samples.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/src/System.Device.Gpio/System.Device.Gpio.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/tools/ArduinoCsCompiler/ArduinoCsCompiler.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • 6s7vsblobprodcus313.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
  • 80zvsblobprodcus35.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/samples/samples.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/src/System.Device.Gpio/System.Device.Gpio.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • bcnvsblobprodcus378.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build Mcp23xxx.csproj (dns block)
  • fdpvsblobprodcus345.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build Mcp23xxx.csproj (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/tools/ArduinoCsCompiler/ArduinoCsCompiler.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • gbsvsblobprodcus365.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/tools/ArduinoCsCompiler/ArduinoCsCompiler.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/src/devices/Ft4222/Ft4222.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • gervsblobprodcus329.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/tools/ArduinoCsCompiler/ArduinoCsCompiler.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/tools/DevicesApiTester/DeviceApiTester.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • ibzvsblobprodcus369.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/samples/samples.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/tools/ArduinoCsCompiler/ArduinoCsCompiler.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • josvsblobprodcus372.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
  • l49vsblobprodcus358.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
  • o3svsblobprodcus318.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build Mcp23xxx.csproj (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/samples/samples.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • ofvvsblobprodcus315.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/src/System.Device.Gpio/System.Device.Gpio.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/tools/ArduinoCsCompiler/ArduinoCsCompiler.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/tools/DevicesApiTester/DeviceApiTester.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • p2ovsblobprodcus312.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
    • Triggering command: /usr/bin/dotnet dotnet restore (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build Mcp23xxx.csproj (dns block)
  • pkvvsblobprodcus321.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/samples/samples.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/src/System.Device.Gpio/System.Device.Gpio.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • s4uvsblobprodcus326.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build Mcp23xxx.csproj (dns block)
    • Triggering command: /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /home/REDACTED/work/iot/iot/samples/samples.sln --packages /tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/packages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal /p:TargetFrameworkRootPath=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:NetCoreTargetingPackRoot=/tmp/codeql-scratch-db3f4ba25dde505c/dbs/csharp/working/emptyFakeDotnetRoot /p:AllowMissingPrunePackageData=true (dns block)
  • sc4vsblobprodcus331.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
  • securitytools.pkgs.visualstudio.com
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp /opt/hostedtoolcache/CodeQL/2.24.2/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp (dns block)
  • tphvsblobprodcus375.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build Mcp23xxx.csproj (dns block)
  • ukkvsblobprodcus352.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build Mcp23xxx.csproj (dns block)
  • uy6vsblobprodcus34.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build Mcp23xxx.csproj (dns block)
  • yluvsblobprodcus367.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>EnableDisableTests flakiness</issue_title>
<issue_description>```
[xUnit.net 00:00:01.05] Iot.Device.Mcp23xxx.Tests.EnableDisableTests.InitialResetState(testDevice: Iot.Device.Mcp23xxx.Tests.Mcp23xxxTest+TestDevice) [FAIL]
Failed Iot.Device.Mcp23xxx.Tests.EnableDisableTests.InitialResetState(testDevice: Iot.Device.Mcp23xxx.Tests.Mcp23xxxTest+TestDevice) [1 ms]
Error Message:
System.InvalidOperationException : Pin 1 is not yet opened.
Stack Trace:
at Iot.Device.Mcp23xxx.Tests.Mcp23xxxTest.GpioDriverMock.GetPinMode(Int32 pinNumber) in /Users/runner/work/1/s/src/devices/Mcp23xxx/tests/Mcp23xxxTest.cs:line 243
at System.Device.Gpio.GpioController.Write(Int32 pinNumber, PinValue value) in /_/src/System.Device.Gpio/System/Device/Gpio/GpioController.cs:line 277
at Iot.Device.Mcp23xxx.Mcp23xxx.Enable() in /Users/runner/work/1/s/src/devices/Mcp23xxx/Mcp23xxx.cs:line 294
at Iot.Device.Mcp23xxx.Tests.EnableDisableTests.InitialResetState(TestDevice testDevice) in /Users/runner/work/1/s/src/devices/Mcp23xxx/tests/EnableDisableTests.cs:line 23
at InvokeStub_EnableDisableTests.InitialResetState(Object, Span`1)
at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)


<agent_instructions>This looks like parallelization issue and likely we should just remove static pieces and replace them with instance. Ideally make minimal changes to the branch</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Microsoft Reviewers: Open in CodeFlow

…h per-device instances

Co-authored-by: krwq <660048+krwq@users.noreply.github.com>
@dotnet-policy-service dotnet-policy-service Bot added the area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio label Mar 12, 2026
Co-authored-by: krwq <660048+krwq@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix flakiness in EnableDisableTests for initial reset state Fix EnableDisableTests flakiness by removing shared static state Mar 12, 2026
Copilot AI requested a review from krwq March 12, 2026 17:01
Copilot finished work on behalf of krwq March 12, 2026 17:01
@joperezr

Copy link
Copy Markdown
Member

FYI — as we previously discussed, I've opened #2537 to make the Arduino_Compiler_CI check opt-in (triggered by a /run-arduino-tests comment from a maintainer) rather than running on every PR. This should stop the flakiness from blocking unrelated PRs while your fix here lands.

@raffaeler raffaeler marked this pull request as ready for review July 9, 2026 15:47
Copilot AI review requested due to automatic review settings July 9, 2026 15:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses flaky parallel test failures in the Mcp23xxx test suite by removing shared static GPIO mock state and ensuring each test case uses an isolated GpioDriverMock/GpioController instance.

Changes:

  • Extend Mcp23xxxTest.TestDevice to optionally carry a per-device GpioDriverMock used for reset-pin assertions.
  • Update EnableDisableTests to remove static GPIO mocks and construct per-test/per-device mocks instead.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/devices/Mcp23xxx/tests/Mcp23xxxTest.cs Adds optional ResetDriverMock to TestDevice to support reset-pin checks with per-test isolated mocks.
src/devices/Mcp23xxx/tests/EnableDisableTests.cs Removes shared static GPIO state; each TestDevice created for reset-related tests now has its own GpioDriverMock.

Comment on lines +17 to +19
GpioDriverMock driverMock = testDevice.ResetDriverMock!;
GpioController gpioMock = new GpioController(driverMock);
gpioMock.OpenPin(1, PinMode.Input);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EnableDisableTests flakiness

4 participants