test_phase_details_parser.py 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. """Detail events from captured BIOS output, including its misleading labels.
  2. Examples come from the live UIP/AMEMDIAG fixtures and the supplied
  3. minicom_20261008_04.log RMT capture. They do not imply fixed CPU step numbers,
  4. fixed algorithm totals, or a passing margin threshold.
  5. """
  6. from stl_backend.parsers import IncrementalSolParser
  7. BANNER = "[SYS_BIOS]Version:TEST, Release Date:20261026, Vendor: AMI\n"
  8. def parse(text, chunk=7):
  9. parser = IncrementalSolParser()
  10. raw = text.encode()
  11. events = []
  12. for offset in range(0, len(raw), chunk):
  13. events.extend(parser.feed(raw[offset:offset + chunk]))
  14. events.extend(parser.flush())
  15. return events
  16. def test_uip_stage2_continue_keeps_its_cpu_and_stage_despite_training_words():
  17. events = parse(
  18. "[0][CxmtDdrTest]Current stage is 2\n"
  19. "[1][CxmtDdrTest]Current stage is 1\n"
  20. "[BIOS][Training][ScktId: 1][145]Enable CA Scrambling -- SUCCEEDED,Time=8 ms\n"
  21. "[0][CxmtDdrTest]Please input your command:\n"
  22. "[0][CxmtDdrTest]User input command is errhandle disable\n"
  23. "[0][CxmtDdrTest]No command input or timeout, so go on training\n"
  24. "[1][CxmtDdrTest]Please input your command:", chunk=1)
  25. continued = next(e for e in events if e["details"].get("state") == "continued")
  26. assert continued["phase"] == "uip"
  27. assert continued["details"]["detail_id"] == "uip2_continued"
  28. assert continued["details"]["stage"] == 2
  29. assert continued["details"]["cpu"] == 0
  30. echo = next(e for e in events if e["kind"] == "command_echo")
  31. assert echo["details"]["detail_id"] == "uip2_command_echo"
  32. prompts = [e for e in events if e["kind"] == "prompt"]
  33. assert [(e["details"]["cpu"], e["details"]["uip_stage"]) for e in prompts] == [(0, 2), (1, 1)]
  34. def test_real_boot_banner_clears_old_uip_stage_and_echo_keeps_its_menu():
  35. events = parse(
  36. "[0][CxmtDdrTest]Current stage is 2\n" + BANNER +
  37. "[0][CxmtDdrTest]Please input your command:\n"
  38. "[0][CxmtDdrTest]User input command is errhandle disable\n"
  39. "[1][AMEMDIAG #][1][AMEMDIG]User input command is show\n")
  40. prompt = next(e for e in events if e["kind"] == "prompt")
  41. assert "stage" not in prompt["details"]
  42. assert prompt["details"]["detail_id"] == "uip_waiting"
  43. echoes = [e for e in events if e["kind"] == "command_echo"]
  44. assert [(e["phase"], e["details"]["menu_kind"]) for e in echoes] == [("uip", "uip"), ("amt", "amt")]
  45. assert "stage" not in echoes[0]["details"]
  46. def test_rmt_result_block_does_not_create_a_second_execution_start():
  47. events = parse(
  48. "[ScktId: 1] Rank Margin Tool -- Started\n"
  49. "Starting RMT test v3.22.0.0\n"
  50. "Testing IoLevel=HostLevel MarginGroup=RxDqsDelay\n"
  51. "START_RMT_N1\nTurnaround Rank Margin\nRxDqs- RxDqs+\n"
  52. "N1.C00.SC0.R01: -18 19\nSTOP_RMT_N1\n"
  53. "MMA metadata: BusFreq=2800 MHz\nRMT test v3.22.0.0 complete\n"
  54. "[BIOS][Training][ScktId: 1][126]Rank Margin Tool -- SUCCEEDED,Time=149873 ms\n")
  55. block = next(e for e in events if e["raw_line"] == "START_RMT_N1")
  56. assert block["kind"] == "stage"
  57. assert block["details"]["state"] == "reporting"
  58. assert block["details"]["detail_id"] == "report_block_started"
  59. assert block["details"]["report_only"] is True
  60. assert len([e for e in events if e["message"] == "RMT started"]) == 1
  61. table = next(e for e in events if e["message"] == "RMT result table observed")
  62. assert table["details"]["detail_id"] == "reporting_turnaround"
  63. assert table["details"]["cpu"] == 1
  64. row = next(e for e in events if e["kind"] == "rmt_margin")
  65. assert row["details"]["rank_token"] == "01"
  66. complete = next(e for e in events if e["details"].get("detail_id") == "program_completed")
  67. assert complete["kind"] == "stage_detail" and complete["details"]["cpu"] == 1
  68. assert complete["details"]["completion_is_not_pass"] is True
  69. def test_rmt_scan_details_preserve_combinations_and_do_not_guess_cpu():
  70. events = parse(
  71. "[ScktId: 0] Rank Margin Tool -- Started\n"
  72. "Testing same rank traffic for rank combination 1 of 2.\n"
  73. "Skip. Only the first rank is tested in CA training mode.\n"
  74. "[ScktId: 1] Rank Margin Tool -- Started\n"
  75. "Starting turnaround RMT test\n"
  76. "Testing IoLevel=HostLevel MarginGroup=TxVref\n"
  77. "Testing turnaround traffic between rank1 and rank0, 2 of 2.\n")
  78. same = next(e for e in events if e["details"].get("detail_id") == "same_rank_scan")
  79. assert same["details"]["cpu"] == 0
  80. assert (same["details"]["combination"], same["details"]["combinations"]) == (1, 2)
  81. skipped = next(e for e in events if e["details"].get("detail_id") == "combination_skipped")
  82. assert skipped["details"]["state"] == "skipped"
  83. group = next(e for e in events if e["details"].get("detail_id") == "margin_group")
  84. assert "cpu" not in group["details"]
  85. assert group["details"]["scan_mode"] == "turnaround"
  86. combo = events[-1]["details"]
  87. assert "cpu" not in combo
  88. assert (combo["rank_from"], combo["rank_to"], combo["combination"]) == (1, 0, 2)
  89. def test_unscoped_detail_does_not_change_legacy_parser_phase_or_claim_pass():
  90. parser = IncrementalSolParser()
  91. parser.feed(b"[0][AMEMDIAG #]\n")
  92. events = parser.feed(b"Starting turnaround RMT test\nRMT test v3.22.0.0 complete\n")
  93. assert parser.phase == "amemdiag"
  94. assert all(e["kind"] == "stage_detail" and e["phase"] == "rmt" for e in events)
  95. assert all("cpu" not in e["details"] for e in events)
  96. assert not any(e["details"].get("test_failure") for e in events)
  97. def test_mrc_container_and_post_details_do_not_manufacture_boot_markers():
  98. events = parse(
  99. BANNER + "START_MRC_RUN\n"
  100. "[BIOS][Training][ScktId: 0][5]Security check reset request -- SUCCEEDED,Time=8 ms\n"
  101. "[BIOS][Training][ScktId: 0][183]DDR Reset Loop -- SUCCEEDED,Time=15 ms\n"
  102. "Performance statistics for socket 1\nSTOP_MRC_RUN\n"
  103. "0x4F : DXE IPL Start\n0x33 : CPU Cache initialization\n"
  104. "0x90 : BDS Started.\nUEFI Interactive Shell v2.2\nShell> ")
  105. boot = [e for e in events if e["message"] == "System BIOS boot banner observed"]
  106. assert len(boot) == 1
  107. details = {e["details"].get("detail_id"): e["details"] for e in events}
  108. assert details["mrc_entry"]["container_only"] is True
  109. assert details["mrc_completed"]["state"] == "completed"
  110. assert details["mrc_statistics"]["historical"] is True
  111. assert details["post_4f"]["boot_stage"] == "dxe"
  112. assert details["post_33"]["post_code"] == "0x33"
  113. assert details["post_90"]["boot_stage"] == "bds"
  114. assert details["uefi_banner"]["state"] == "starting"
  115. assert details["uefi_ready"]["state"] == "ready"
  116. def test_amt_details_keep_algorithm_identity_and_zero_execution_verdict():
  117. events = parse(
  118. "[0] AMEMDIAG Version GNR-4.3.0 (Mar 3 2026)\n[0][AMEMDIAG #]\n"
  119. "[0] AMEMDIAG Test Start\n"
  120. "[0][AMEMDIAG 1/1 1/1 1/19] Algo B-WRUP Done\n"
  121. "[0][AMEMDIAG 1/1 1/1 1/19] Algo B-WRUP End by time 252 sec!\n"
  122. "[0] AMEMDIAG Test Result: pass\n[0] AMEMDIAG Test Algo Count: 0\n"
  123. "[0] AMEMDIAG Test Time: 0 sec\nAMEMDIAG Test Result Summary: pass\n")
  124. algorithms = [e for e in events if e["details"].get("detail_id") == "amt_algorithm"]
  125. assert len(algorithms) == 2
  126. assert all(e["details"]["algorithm_index"] == 1 for e in algorithms)
  127. assert algorithms[1]["details"]["duration_s"] == 252
  128. summary = next(e for e in events if e["details"].get("detail_id") == "amt_summary_result")
  129. assert summary["details"]["algorithms_executed"] == 0
  130. assert summary["details"]["verdict_supported"] is False
  131. assert all(e["details"].get("detail_label") for e in events)
  132. def test_amt_and_mt_error_detail_coordinates_keep_valid_ddr5_bank_0_to_31():
  133. events = parse(
  134. "N0.C02.D0.SC1.R0: Failure detected - Advanced Memtest Type 20, Checkpoint 0x000000B0\n"
  135. "[B-SCM_2_RS]Logical Rank = 0, Subrank = 0, Bank = 31, Row = 0x3F98, Column = 0x4C0, Chunk = 0xFFFF\n"
  136. "DQ[39:0] Error on rising strobe: 0x0000000400\n"
  137. "DQ[39:0] Error on falling strobe: 0x0000000400\n"
  138. "2026-10-08 14:18:44 - [MEM ERROR - ECC Errors] (P package,C channel,S slot,R rank): (P0,C5,S0,R0)\n"
  139. "2026-10-08 14:18:44 - [MEM ERROR - ECC Errors] (Chan,Slot,Rank,Bank,Row,Col): (5,0,0,16,24212,896)\n"
  140. )
  141. amt_details = [e["details"] for e in events if e["kind"] == "error_detail" and e["phase"] == "amt"]
  142. assert len(amt_details) == 3
  143. assert amt_details[0]["algorithm_tag"] == "B-SCM_2_RS"
  144. assert amt_details[0]["bank"] == 31
  145. assert amt_details[0]["row"] == "0x3F98"
  146. assert amt_details[0]["column"] == "0x4C0"
  147. assert amt_details[1]["dq_rising_hex"] == "0x0000000400"
  148. assert amt_details[2]["dq_falling_hex"] == "0x0000000400"
  149. mt_details = [e["details"] for e in events if e["kind"] == "error_detail" and e["phase"] == "mt"]
  150. assert len(mt_details) == 1
  151. assert mt_details[0]["channel"] == 5
  152. assert mt_details[0]["bank"] == 16
  153. assert mt_details[0]["row"] == "24212"
  154. assert mt_details[0]["column"] == "896"