The four follow-ups the beta.12 documentation audit left as chips; three of them here, the fourth (Velopack deltas) rides the release PR. S23-3. The guard's checks 2 and 2b are machine-wide: while Easy Anti-Cheat's service runs for another title, every game refuses with BlockedService, and the notice read "Easy Anti-Cheat was detected in this game". CaptureRefused and SafetyUnhook gain an optional guardReason (additive; reason stays the session's end reason), and BlockedService / BlockedDriver read Safety_Refused_MachineWide_Format, Safety_Unhooked_MachineWide_Format and Summary_Tier2_Why_MachineWide_Format (en/vi; ja as an English copy awaiting the human safety review, like its siblings). Safety_Unhooked_Format loses "will not inject into this game again until you enable it again", untrue both ways since 2026-09-22. Formats.NamedRefusal is the one place a named refusal is worded; SafetyNotices and HookingConsentResult both use it. L1's adapter. SelectAdapter had no caller, and fixing that alone would have changed little: the composite merges L3 > L2 > L1 per field, and L2 and L3 read their own first GPU. CaptureProgress carries the handshake's AdapterLuid; the recorder hands it to the poller once (noted in the .partial); CompositeTelemetrySource.SelectAdapter points L1 at it (IGpuAdapterSelector) and tells the other layers its vendor (IGpuVendorFollower): L2 maps that vendor's LHM node, L3 contributes nothing for a non-NVIDIA adapter. What stays first-found is written in 18_GPU_VENDOR_APIS and LIMITATIONS. Culture races. The strings-culture collection serialized its own members but ran beside every other class; it now has a definition with DisableParallelization, and StringsTests asserts xUnit bound it. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
123 lines
5.0 KiB
C#
123 lines
5.0 KiB
C#
// SPDX-License-Identifier: GPL-3.0-only
|
|
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
|
|
|
using FluentAssertions;
|
|
using FrameLedger.Application.Telemetry;
|
|
using FrameLedger.Infrastructure.Telemetry;
|
|
|
|
namespace FrameLedger.Infrastructure.Tests.Telemetry;
|
|
|
|
/// <summary>L3's contract through a scripted bridge: unavailable is not zero, a clear bit is null, two throws disable.</summary>
|
|
public sealed class NvapiTelemetrySourceTests
|
|
{
|
|
private sealed class ManualTimeProvider : TimeProvider
|
|
{
|
|
public override DateTimeOffset GetUtcNow() => new(2026, 9, 10, 12, 0, 0, TimeSpan.Zero);
|
|
}
|
|
|
|
[Fact]
|
|
public void AFullSampleMapsEveryFieldAndTheLayerIsNvapi()
|
|
{
|
|
using var bridge = new FakeNvapiBridge { Sample = FakeNvapiBridge.Full };
|
|
using var source = new NvapiTelemetrySource(bridge, new ManualTimeProvider());
|
|
|
|
source.TryRead(out GpuSample? s).Should().BeTrue();
|
|
|
|
s!.Layer.Should().Be(TelemetryLayer.Nvapi);
|
|
s.AdapterName.Should().Be("NVIDIA GeForce RTX 5080");
|
|
s.TempCoreC.Should().Be(62);
|
|
s.TempMemoryC.Should().BeNull("the bit was clear");
|
|
s.LoadPct.Should().Be(57);
|
|
s.VramAdapterMb.Should().BeNull("this build reads no memory info");
|
|
s.CoreClockMhz.Should().Be(2610);
|
|
s.MemClockMhz.Should().Be(15001);
|
|
s.FanRpm.Should().Be(1200);
|
|
s.ThrottleReasons.Should().Be(0x2u);
|
|
s.PcieWidth.Should().Be(16);
|
|
s.PcieGen.Should().BeNull();
|
|
source.Capabilities.Should().Be(GpuCapabilities.TempCore | GpuCapabilities.Load | GpuCapabilities.CoreClock
|
|
| GpuCapabilities.MemClock | GpuCapabilities.Fan | GpuCapabilities.ThrottleReasons | GpuCapabilities.Pcie);
|
|
source.DriverVersion.Should().Be("616.64 (r616_00)");
|
|
bridge.Inits.Should().Be(1);
|
|
}
|
|
|
|
/// <summary>
|
|
/// beta.13: NVAPI reads NVIDIA's first GPU, so when the game presents on AMD's or Intel's the layer says nothing rather
|
|
/// than another card's temperature — without a fault, and back when the game's adapter is NVIDIA's.
|
|
/// </summary>
|
|
[Fact]
|
|
public void AGameOnAnotherVendorsAdapterGetsNothingFromNvapi()
|
|
{
|
|
using var bridge = new FakeNvapiBridge { Sample = FakeNvapiBridge.Full };
|
|
using var source = new NvapiTelemetrySource(bridge, new ManualTimeProvider());
|
|
|
|
source.FollowVendor(0x1002);
|
|
source.TryRead(out GpuSample? amd).Should().BeFalse();
|
|
amd.Should().BeNull();
|
|
source.IsDisabled.Should().BeFalse("nothing went wrong; it just is not the game's card");
|
|
|
|
source.FollowVendor(0x10DE);
|
|
source.TryRead(out GpuSample? nvidia).Should().BeTrue();
|
|
nvidia!.TempCoreC.Should().Be(62);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(NativeNvapiBridge.Unavailable)]
|
|
[InlineData(-6)]
|
|
[InlineData(NativeNvapiBridge.NoGpu)]
|
|
public void AnInitThatDoesNotAnswerZeroDisablesTheLayerWithoutAFault(int init)
|
|
{
|
|
using var bridge = new FakeNvapiBridge { InitResult = init, Sample = FakeNvapiBridge.Full };
|
|
using var source = new NvapiTelemetrySource(bridge, new ManualTimeProvider());
|
|
|
|
source.Start();
|
|
|
|
source.IsDisabled.Should().BeTrue();
|
|
source.Capabilities.Should().Be(GpuCapabilities.None, "unavailable is N/A, never zero");
|
|
source.Faults.Should().Be(0, "a machine without the driver is a normal condition");
|
|
source.LastFault.Should().NotBeNull();
|
|
source.TryRead(out _).Should().BeFalse();
|
|
bridge.Reads.Should().Be(0);
|
|
}
|
|
|
|
[Fact]
|
|
public void ABridgeThatThrowsTwiceIsDisabledAndAReadTheDriverRefusesIsNot()
|
|
{
|
|
int calls = 0;
|
|
using var bridge = new FakeNvapiBridge
|
|
{
|
|
Sample = () => ++calls is 2 or 4 ? throw new InvalidOperationException("driver went away") : FakeNvapiBridge.Full(),
|
|
};
|
|
using var source = new NvapiTelemetrySource(bridge, new ManualTimeProvider());
|
|
|
|
source.TryRead(out _).Should().BeTrue();
|
|
source.TryRead(out _).Should().BeFalse();
|
|
source.Faults.Should().Be(1);
|
|
source.IsDisabled.Should().BeFalse();
|
|
source.TryRead(out _).Should().BeTrue();
|
|
source.TryRead(out _).Should().BeFalse();
|
|
source.IsDisabled.Should().BeTrue();
|
|
source.Capabilities.Should().Be(GpuCapabilities.None);
|
|
source.TryRead(out _).Should().BeFalse("never retried");
|
|
}
|
|
|
|
[Fact]
|
|
public void DisposeShutsTheBridgeDownOnceAndOnlyIfItWasInitialised()
|
|
{
|
|
using var live = new FakeNvapiBridge { Sample = FakeNvapiBridge.Full };
|
|
var source = new NvapiTelemetrySource(live, new ManualTimeProvider());
|
|
source.Start();
|
|
source.Dispose();
|
|
source.Dispose();
|
|
live.Shutdowns.Should().Be(1);
|
|
live.Disposed.Should().BeTrue();
|
|
|
|
using var dead = new FakeNvapiBridge { InitResult = -6 };
|
|
var disabled = new NvapiTelemetrySource(dead, new ManualTimeProvider());
|
|
disabled.Start();
|
|
disabled.Dispose();
|
|
dead.Shutdowns.Should().Be(0, "nothing was initialised");
|
|
dead.Disposed.Should().BeTrue();
|
|
}
|
|
}
|