mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-09-12 10:34:24 +08:00
test: 更新报告格式
This commit is contained in:
@@ -163,8 +163,8 @@ class Reporter:
|
|||||||
"",
|
"",
|
||||||
f"- 运行编号:`{run_id}`",
|
f"- 运行编号:`{run_id}`",
|
||||||
"- 测试设备:",
|
"- 测试设备:",
|
||||||
f"- 视频设备:{markdown_inline(self.user_video_device())}",
|
f"- 视频设备:{self.user_video_device()}",
|
||||||
f"- HID设备:{markdown_inline(self.user_hid_backend())}",
|
f"- HID 设备:{markdown_inline(self.user_hid_backend())}",
|
||||||
f"- HTTP 延迟:{markdown_inline(self.user_http_latency())}",
|
f"- HTTP 延迟:{markdown_inline(self.user_http_latency())}",
|
||||||
"",
|
"",
|
||||||
"## 视频性能",
|
"## 视频性能",
|
||||||
@@ -192,7 +192,7 @@ class Reporter:
|
|||||||
lines.extend(
|
lines.extend(
|
||||||
[
|
[
|
||||||
"",
|
"",
|
||||||
"## HID性能",
|
"## HID 性能",
|
||||||
"",
|
"",
|
||||||
"| 输入方式 | 延迟统计(中位数 p50 / 95%分位 p95 / 最大值 max) |",
|
"| 输入方式 | 延迟统计(中位数 p50 / 95%分位 p95 / 最大值 max) |",
|
||||||
"| --- | --- |",
|
"| --- | --- |",
|
||||||
@@ -208,7 +208,7 @@ class Reporter:
|
|||||||
lines.extend(
|
lines.extend(
|
||||||
[
|
[
|
||||||
"",
|
"",
|
||||||
"## MSD性能",
|
"## MSD 性能",
|
||||||
"",
|
"",
|
||||||
"| 操作 | 数据 |",
|
"| 操作 | 数据 |",
|
||||||
"| --- | --- |",
|
"| --- | --- |",
|
||||||
@@ -249,7 +249,9 @@ class Reporter:
|
|||||||
continue
|
continue
|
||||||
device = str(case.get("device") or "未知设备")
|
device = str(case.get("device") or "未知设备")
|
||||||
by_device.setdefault(device, []).append(format_video_case(case))
|
by_device.setdefault(device, []).append(format_video_case(case))
|
||||||
return ";".join(f"{device}:{', '.join(items)}" for device, items in by_device.items()) or "无数据"
|
return ";".join(
|
||||||
|
f"{markdown_code(device)}({'、'.join(items)})" for device, items in by_device.items()
|
||||||
|
) or "无数据"
|
||||||
|
|
||||||
def user_hid_backend(self) -> str:
|
def user_hid_backend(self) -> str:
|
||||||
config = self.find_result("hid_msd_config")
|
config = self.find_result("hid_msd_config")
|
||||||
@@ -317,11 +319,11 @@ class Reporter:
|
|||||||
verify = result.data.get("verify") or {}
|
verify = result.data.get("verify") or {}
|
||||||
rows: list[tuple[str, str]] = []
|
rows: list[tuple[str, str]] = []
|
||||||
if "write_mib_s" in verify:
|
if "write_mib_s" in verify:
|
||||||
rows.append(("写", f"{float(verify.get('write_mib_s') or 0):.2f}MiB/s"))
|
rows.append(("写", f"{float(verify.get('write_mib_s') or 0):.2f} MiB/s"))
|
||||||
if "read_mib_s" in verify:
|
if "read_mib_s" in verify:
|
||||||
rows.append(("读", f"{float(verify.get('read_mib_s') or 0):.2f}MiB/s"))
|
rows.append(("读", f"{float(verify.get('read_mib_s') or 0):.2f} MiB/s"))
|
||||||
elif "cached_read_mib_s" in verify:
|
elif "cached_read_mib_s" in verify:
|
||||||
rows.append(("读(缓存,仅校验)", f"{float(verify.get('cached_read_mib_s') or 0):.2f}MiB/s"))
|
rows.append(("读(缓存,仅校验)", f"{float(verify.get('cached_read_mib_s') or 0):.2f} MiB/s"))
|
||||||
if rows:
|
if rows:
|
||||||
return rows
|
return rows
|
||||||
return [("MSD", f"{STATUS_TEXT.get(result.status, result.status)}:{result.message}" if result.message else STATUS_TEXT.get(result.status, result.status))]
|
return [("MSD", f"{STATUS_TEXT.get(result.status, result.status)}:{result.message}" if result.message else STATUS_TEXT.get(result.status, result.status))]
|
||||||
@@ -589,19 +591,30 @@ def display_name(name: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def format_video_case(case: dict[str, Any]) -> str:
|
def format_video_case(case: dict[str, Any]) -> str:
|
||||||
fmt = str(case.get("fmt") or "").lower()
|
fmt = format_video_codec(case.get("fmt"))
|
||||||
resolution = format_resolution(case)
|
resolution = format_resolution(case)
|
||||||
fps = format_fps_value(case.get("fps"))
|
fps = format_fps_value(case.get("fps"))
|
||||||
return " ".join(part for part in (f"{resolution}@{fps}" if resolution and fps else resolution or fps, fmt) if part)
|
return " ".join(part for part in (f"{resolution}@{fps}" if resolution and fps else resolution or fps, fmt) if part)
|
||||||
|
|
||||||
|
|
||||||
def format_video_latency_params(case: dict[str, Any], output_mode: str) -> str:
|
def format_video_latency_params(case: dict[str, Any], output_mode: str) -> str:
|
||||||
fmt = str(case.get("fmt") or "").lower()
|
fmt = format_video_codec(case.get("fmt"))
|
||||||
output = output_mode.lower() if output_mode else "unknown"
|
output = format_video_codec(output_mode) if output_mode else "UNKNOWN"
|
||||||
resolution = format_resolution(case)
|
resolution = format_resolution(case)
|
||||||
fps = format_fps_value(case.get("fps"))
|
fps = format_fps_value(case.get("fps"))
|
||||||
input_part = " ".join(part for part in (f"{resolution}@{fps}" if resolution and fps else resolution or fps, fmt) if part)
|
input_part = " ".join(part for part in (f"{resolution}@{fps}" if resolution and fps else resolution or fps, fmt) if part)
|
||||||
return f"{input_part}-->{output}" if input_part else output
|
return f"{input_part} → {output}" if input_part else output
|
||||||
|
|
||||||
|
|
||||||
|
def format_video_codec(value: Any) -> str:
|
||||||
|
codec = str(value or "").strip()
|
||||||
|
normalized = codec.lower().replace(".", "").replace("-", "").replace("_", "")
|
||||||
|
names = {
|
||||||
|
"h264": "H.264",
|
||||||
|
"h265": "H.265",
|
||||||
|
"mjpeg": "MJPEG",
|
||||||
|
}
|
||||||
|
return names.get(normalized, codec.upper())
|
||||||
|
|
||||||
|
|
||||||
def format_resolution(case: dict[str, Any]) -> str:
|
def format_resolution(case: dict[str, Any]) -> str:
|
||||||
@@ -659,6 +672,10 @@ def markdown_inline(value: str) -> str:
|
|||||||
return str(value).replace("\n", " | ").replace("`", "'")
|
return str(value).replace("\n", " | ").replace("`", "'")
|
||||||
|
|
||||||
|
|
||||||
|
def markdown_code(value: str) -> str:
|
||||||
|
return f"`{markdown_inline(value)}`"
|
||||||
|
|
||||||
|
|
||||||
def markdown_table_cell(value: str) -> str:
|
def markdown_table_cell(value: str) -> str:
|
||||||
return markdown_inline(value).replace("|", "\\|")
|
return markdown_inline(value).replace("|", "\\|")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user