| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- """Detail events from captured BIOS output, including its misleading labels.
- Examples come from the live UIP/AMEMDIAG fixtures and the supplied
- minicom_20261008_04.log RMT capture. They do not imply fixed CPU step numbers,
- fixed algorithm totals, or a passing margin threshold.
- """
- from stl_backend.parsers import IncrementalSolParser
- BANNER = "[SYS_BIOS]Version:TEST, Release Date:20261026, Vendor: AMI\n"
- def parse(text, chunk=7):
- parser = IncrementalSolParser()
- raw = text.encode()
- events = []
- for offset in range(0, len(raw), chunk):
- events.extend(parser.feed(raw[offset:offset + chunk]))
- events.extend(parser.flush())
- return events
- def test_uip_stage2_continue_keeps_its_cpu_and_stage_despite_training_words():
- events = parse(
- "[0][CxmtDdrTest]Current stage is 2\n"
- "[1][CxmtDdrTest]Current stage is 1\n"
- "[BIOS][Training][ScktId: 1][145]Enable CA Scrambling -- SUCCEEDED,Time=8 ms\n"
- "[0][CxmtDdrTest]Please input your command:\n"
- "[0][CxmtDdrTest]User input command is errhandle disable\n"
- "[0][CxmtDdrTest]No command input or timeout, so go on training\n"
- "[1][CxmtDdrTest]Please input your command:", chunk=1)
- continued = next(e for e in events if e["details"].get("state") == "continued")
- assert continued["phase"] == "uip"
- assert continued["details"]["detail_id"] == "uip2_continued"
- assert continued["details"]["stage"] == 2
- assert continued["details"]["cpu"] == 0
- echo = next(e for e in events if e["kind"] == "command_echo")
- assert echo["details"]["detail_id"] == "uip2_command_echo"
- prompts = [e for e in events if e["kind"] == "prompt"]
- assert [(e["details"]["cpu"], e["details"]["uip_stage"]) for e in prompts] == [(0, 2), (1, 1)]
- def test_real_boot_banner_clears_old_uip_stage_and_echo_keeps_its_menu():
- events = parse(
- "[0][CxmtDdrTest]Current stage is 2\n" + BANNER +
- "[0][CxmtDdrTest]Please input your command:\n"
- "[0][CxmtDdrTest]User input command is errhandle disable\n"
- "[1][AMEMDIAG #][1][AMEMDIG]User input command is show\n")
- prompt = next(e for e in events if e["kind"] == "prompt")
- assert "stage" not in prompt["details"]
- assert prompt["details"]["detail_id"] == "uip_waiting"
- echoes = [e for e in events if e["kind"] == "command_echo"]
- assert [(e["phase"], e["details"]["menu_kind"]) for e in echoes] == [("uip", "uip"), ("amt", "amt")]
- assert "stage" not in echoes[0]["details"]
- def test_rmt_result_block_does_not_create_a_second_execution_start():
- events = parse(
- "[ScktId: 1] Rank Margin Tool -- Started\n"
- "Starting RMT test v3.22.0.0\n"
- "Testing IoLevel=HostLevel MarginGroup=RxDqsDelay\n"
- "START_RMT_N1\nTurnaround Rank Margin\nRxDqs- RxDqs+\n"
- "N1.C00.SC0.R01: -18 19\nSTOP_RMT_N1\n"
- "MMA metadata: BusFreq=2800 MHz\nRMT test v3.22.0.0 complete\n"
- "[BIOS][Training][ScktId: 1][126]Rank Margin Tool -- SUCCEEDED,Time=149873 ms\n")
- block = next(e for e in events if e["raw_line"] == "START_RMT_N1")
- assert block["kind"] == "stage"
- assert block["details"]["state"] == "reporting"
- assert block["details"]["detail_id"] == "report_block_started"
- assert block["details"]["report_only"] is True
- assert len([e for e in events if e["message"] == "RMT started"]) == 1
- table = next(e for e in events if e["message"] == "RMT result table observed")
- assert table["details"]["detail_id"] == "reporting_turnaround"
- assert table["details"]["cpu"] == 1
- row = next(e for e in events if e["kind"] == "rmt_margin")
- assert row["details"]["rank_token"] == "01"
- complete = next(e for e in events if e["details"].get("detail_id") == "program_completed")
- assert complete["kind"] == "stage_detail" and complete["details"]["cpu"] == 1
- assert complete["details"]["completion_is_not_pass"] is True
- def test_rmt_scan_details_preserve_combinations_and_do_not_guess_cpu():
- events = parse(
- "[ScktId: 0] Rank Margin Tool -- Started\n"
- "Testing same rank traffic for rank combination 1 of 2.\n"
- "Skip. Only the first rank is tested in CA training mode.\n"
- "[ScktId: 1] Rank Margin Tool -- Started\n"
- "Starting turnaround RMT test\n"
- "Testing IoLevel=HostLevel MarginGroup=TxVref\n"
- "Testing turnaround traffic between rank1 and rank0, 2 of 2.\n")
- same = next(e for e in events if e["details"].get("detail_id") == "same_rank_scan")
- assert same["details"]["cpu"] == 0
- assert (same["details"]["combination"], same["details"]["combinations"]) == (1, 2)
- skipped = next(e for e in events if e["details"].get("detail_id") == "combination_skipped")
- assert skipped["details"]["state"] == "skipped"
- group = next(e for e in events if e["details"].get("detail_id") == "margin_group")
- assert "cpu" not in group["details"]
- assert group["details"]["scan_mode"] == "turnaround"
- combo = events[-1]["details"]
- assert "cpu" not in combo
- assert (combo["rank_from"], combo["rank_to"], combo["combination"]) == (1, 0, 2)
- def test_unscoped_detail_does_not_change_legacy_parser_phase_or_claim_pass():
- parser = IncrementalSolParser()
- parser.feed(b"[0][AMEMDIAG #]\n")
- events = parser.feed(b"Starting turnaround RMT test\nRMT test v3.22.0.0 complete\n")
- assert parser.phase == "amemdiag"
- assert all(e["kind"] == "stage_detail" and e["phase"] == "rmt" for e in events)
- assert all("cpu" not in e["details"] for e in events)
- assert not any(e["details"].get("test_failure") for e in events)
- def test_mrc_container_and_post_details_do_not_manufacture_boot_markers():
- events = parse(
- BANNER + "START_MRC_RUN\n"
- "[BIOS][Training][ScktId: 0][5]Security check reset request -- SUCCEEDED,Time=8 ms\n"
- "[BIOS][Training][ScktId: 0][183]DDR Reset Loop -- SUCCEEDED,Time=15 ms\n"
- "Performance statistics for socket 1\nSTOP_MRC_RUN\n"
- "0x4F : DXE IPL Start\n0x33 : CPU Cache initialization\n"
- "0x90 : BDS Started.\nUEFI Interactive Shell v2.2\nShell> ")
- boot = [e for e in events if e["message"] == "System BIOS boot banner observed"]
- assert len(boot) == 1
- details = {e["details"].get("detail_id"): e["details"] for e in events}
- assert details["mrc_entry"]["container_only"] is True
- assert details["mrc_completed"]["state"] == "completed"
- assert details["mrc_statistics"]["historical"] is True
- assert details["post_4f"]["boot_stage"] == "dxe"
- assert details["post_33"]["post_code"] == "0x33"
- assert details["post_90"]["boot_stage"] == "bds"
- assert details["uefi_banner"]["state"] == "starting"
- assert details["uefi_ready"]["state"] == "ready"
- def test_amt_details_keep_algorithm_identity_and_zero_execution_verdict():
- events = parse(
- "[0] AMEMDIAG Version GNR-4.3.0 (Mar 3 2026)\n[0][AMEMDIAG #]\n"
- "[0] AMEMDIAG Test Start\n"
- "[0][AMEMDIAG 1/1 1/1 1/19] Algo B-WRUP Done\n"
- "[0][AMEMDIAG 1/1 1/1 1/19] Algo B-WRUP End by time 252 sec!\n"
- "[0] AMEMDIAG Test Result: pass\n[0] AMEMDIAG Test Algo Count: 0\n"
- "[0] AMEMDIAG Test Time: 0 sec\nAMEMDIAG Test Result Summary: pass\n")
- algorithms = [e for e in events if e["details"].get("detail_id") == "amt_algorithm"]
- assert len(algorithms) == 2
- assert all(e["details"]["algorithm_index"] == 1 for e in algorithms)
- assert algorithms[1]["details"]["duration_s"] == 252
- summary = next(e for e in events if e["details"].get("detail_id") == "amt_summary_result")
- assert summary["details"]["algorithms_executed"] == 0
- assert summary["details"]["verdict_supported"] is False
- assert all(e["details"].get("detail_label") for e in events)
- def test_amt_and_mt_error_detail_coordinates_keep_valid_ddr5_bank_0_to_31():
- events = parse(
- "N0.C02.D0.SC1.R0: Failure detected - Advanced Memtest Type 20, Checkpoint 0x000000B0\n"
- "[B-SCM_2_RS]Logical Rank = 0, Subrank = 0, Bank = 31, Row = 0x3F98, Column = 0x4C0, Chunk = 0xFFFF\n"
- "DQ[39:0] Error on rising strobe: 0x0000000400\n"
- "DQ[39:0] Error on falling strobe: 0x0000000400\n"
- "2026-10-08 14:18:44 - [MEM ERROR - ECC Errors] (P package,C channel,S slot,R rank): (P0,C5,S0,R0)\n"
- "2026-10-08 14:18:44 - [MEM ERROR - ECC Errors] (Chan,Slot,Rank,Bank,Row,Col): (5,0,0,16,24212,896)\n"
- )
- amt_details = [e["details"] for e in events if e["kind"] == "error_detail" and e["phase"] == "amt"]
- assert len(amt_details) == 3
- assert amt_details[0]["algorithm_tag"] == "B-SCM_2_RS"
- assert amt_details[0]["bank"] == 31
- assert amt_details[0]["row"] == "0x3F98"
- assert amt_details[0]["column"] == "0x4C0"
- assert amt_details[1]["dq_rising_hex"] == "0x0000000400"
- assert amt_details[2]["dq_falling_hex"] == "0x0000000400"
- mt_details = [e["details"] for e in events if e["kind"] == "error_detail" and e["phase"] == "mt"]
- assert len(mt_details) == 1
- assert mt_details[0]["channel"] == 5
- assert mt_details[0]["bank"] == 16
- assert mt_details[0]["row"] == "24212"
- assert mt_details[0]["column"] == "896"
|