test: 更新分析功能和迁移测试用例

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Scottxjw
2026-08-25 11:30:16 +08:00
parent ee8ea29265
commit 7a8a1e9a87
9 changed files with 602 additions and 122 deletions

View File

@@ -2,16 +2,21 @@ namespace Gpulse.WCT.DataAnalyzer.Tests;
/// <summary>
/// 构造 CLI 测试用的日志 fixture 文件。文件名符合 FileNameParser 约定的
/// `TX面板-TX硬件-TX软件-RX类型-测试目的-日期-序号` 格式。
/// `车厂-车型-TX面板类型-TX硬件-TX软件-RX类型-异物类型-测试目的-年月日测试次数` 格式。
/// </summary>
public static class TestFixtures
{
public const string PlossFileName = "singleMold-v1.0-hex2_1-iPhone15-ploss_test-20260710-1.log";
public const string QfodFileName = "singleMold-v1.0-hex2_1-iPhone15-qfod_test-20260710-1.log";
/// <summary>
/// 新格式文件名示例:
/// 车厂-车型-TX面板类型-TX硬件-TX软件-RX类型-异物类型-测试目的-年月日测试次数
/// </summary>
public const string PlossFileName = "奇瑞-E5-singleMold-A00-V001-iPhone15-无-ploss_test-2026071001.dat";
public const string QfodFileName = "奇瑞-E5-singleMold-A00-V001-iPhone15-无-qfod_test-2026071001.dat";
/// <summary>
/// 两行 Ploss 记录header + FOD 16 字段)。
/// 默认值让恒等式成立Field5 - Field4 - PowLoss - ploss == DeltaP且余量 > 2000。
/// Field10 为功率段,默认 350。
/// </summary>
/// <param name="Field1AsHex">
/// 当不为 null 时,覆写 Field1按十六进制字面量写入日志如 "0C" = 十进制 12
@@ -30,7 +35,7 @@ public static class TestFixtures
int Field7 = 0,
int Field8 = 0,
int Field9 = 500, // ploss
int Field10 = 3000, // threshold
int Field10 = 350, // threshold/power segment (350/500/750/1000/1250/1500/1750/2000/2250)
int Field11 = 0,
int Field12 = 0, // FOD 标志
int Field13 = 0,
@@ -56,24 +61,6 @@ public static class TestFixtures
return path;
}
/// <summary>写旧单行格式 Ploss 日志14 字段),仅指定 ploss/threshold/FOD 三个关键字段。</summary>
/// <param name="rows">每行 FOD 记录关键字段ploss/threshold/FOD</param>
/// <param name="field1Hex">若非 null 则覆盖首字段为十六进制字面量(否则固定为 "1")。</param>
public static string WriteLegacyPlossLog(
string dir,
string fileName,
(int Ploss, int Threshold, int Fod)[] rows,
string? field1Hex = null)
{
var path = Path.Combine(dir, fileName);
var head = field1Hex ?? "1";
var lines = rows
.Select(r => $"FOD-> {head} 0 0 0 0 0 0 0 {r.Ploss} {r.Threshold} 0 {r.Fod} 0 0")
.ToArray();
File.WriteAllLines(path, lines);
return path;
}
/// <summary>写 Qfod 日志文件,每行 DeltaQ 一个。</summary>
public static string WriteQfodLog(string dir, string fileName, params int[] deltaQs)
{