- NOTICE: copyright, GPL-3.0-only, and three additional terms of the kinds section 7 permits - (b) preserve the notices and the attribution in the program's legal notices, (c) mark a modified version as different and do not call it "FrameLedger" alone, (e) no trademark rights in the name. Shipped as licenses\NOTICE.txt; release.yml refuses a published tree without it. - Section 7 wants additional terms named in the source files: every first-party .cs .cpp .h .inl .ps1 .xaml file (1,053; src/native/third_party excluded) opens with the SPDX line and a pointer to NOTICE. tools/notice-check.ps1 is the gate (six self-test cases, both directions; -Fix writes a missing header) and tools/resx-gen.ps1 generates the string accessors with the header. - The native VERSIONINFO LegalCopyright said GPL-3.0-or-later; it now names the real licence. - CONTRIBUTING.md, FORKING.md, CODE_OF_CONDUCT.md (Contributor Covenant 2.1 by reference), legal/TRADEMARKS.md. - 12_BUILD gate list, CLAUDE.md layout and conventions. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
2.5 KiB
C#
84 lines
2.5 KiB
C#
// SPDX-License-Identifier: GPL-3.0-only
|
|
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
|
|
|
using FrameLedger.Infrastructure.Telemetry;
|
|
|
|
namespace FrameLedger.Infrastructure.Tests.Telemetry;
|
|
|
|
/// <summary>A scripted <see cref="INvapiBridge"/>: what Init answers, what each read answers.</summary>
|
|
internal sealed class FakeNvapiBridge : INvapiBridge
|
|
{
|
|
public int InitResult { get; set; }
|
|
|
|
public Func<NvapiSample>? Sample { get; set; }
|
|
|
|
public Func<int, NvapiNgxWords>? Ngx { get; set; }
|
|
|
|
public uint Driver { get; set; } = 61664;
|
|
|
|
/// <summary>What <see cref="DriverProfile"/> answers for a path and the ids asked; null answers DEGRADED.</summary>
|
|
public Func<string, IReadOnlyList<uint>, NvapiDriverProfile>? Profile { get; set; }
|
|
|
|
public List<string> ProfilesRead { get; } = [];
|
|
|
|
public int Inits { get; private set; }
|
|
|
|
public int Shutdowns { get; private set; }
|
|
|
|
public int Reads { get; private set; }
|
|
|
|
public bool Disposed { get; private set; }
|
|
|
|
public int Init()
|
|
{
|
|
Inits++;
|
|
return InitResult;
|
|
}
|
|
|
|
public int ReadSample(out NvapiSample sample)
|
|
{
|
|
Reads++;
|
|
sample = Sample is null ? default : Sample();
|
|
return Sample is null ? -1 : 0;
|
|
}
|
|
|
|
public int NgxState(uint pid, out NvapiNgxWords words)
|
|
{
|
|
words = Ngx is null ? new NvapiNgxWords { Status = NvapiNgxWords.Unanswered, NvapiStatus = -121 } : Ngx((int)pid);
|
|
return 0;
|
|
}
|
|
|
|
public int DriverProfile(string exePath, IReadOnlyList<uint> ids, out NvapiDriverProfile profile)
|
|
{
|
|
ProfilesRead.Add(exePath);
|
|
profile = Profile is null
|
|
? new NvapiDriverProfile { Status = NvapiDriverProfile.Degraded, NvapiStatus = -1000, ProfileName = string.Empty, Settings = [] }
|
|
: Profile(exePath, ids);
|
|
return 0;
|
|
}
|
|
|
|
public int DriverVersion(out uint version, out string branch)
|
|
{
|
|
version = Driver;
|
|
branch = "r616_00";
|
|
return 0;
|
|
}
|
|
|
|
public void Shutdown() => Shutdowns++;
|
|
|
|
public void Dispose() => Disposed = true;
|
|
|
|
public static NvapiSample Full() => new()
|
|
{
|
|
Present = (uint)(NvapiField.TempCore | NvapiField.Load | NvapiField.CoreClock | NvapiField.MemClock | NvapiField.Fan | NvapiField.Throttle | NvapiField.PcieWidth | NvapiField.Name),
|
|
TempCoreC = 62,
|
|
LoadPct = 57,
|
|
CoreClockMhz = 2610,
|
|
MemClockMhz = 15001,
|
|
FanRpm = 1200,
|
|
ThrottleReasons = 0x2,
|
|
PcieWidth = 16,
|
|
Name = "NVIDIA GeForce RTX 5080",
|
|
};
|
|
}
|