def check_ibex_uvm_log(uvm_log):
    """Process Ibex UVM simulation log.

    Process the UVM simulation log produced by the test to check for
    correctness, reports failure if an explicit error or failure is seen in the
    log or there's no explicit pass.

    Args:
      uvm_log:   the uvm simulation log

    Returns:
      A tuple of (passed, log_out).
      `passed` indicates whether the test passed or failed based on the
      log.
      `log_out` a list of relevant lines from the log that may indicate the
      source of the failure, if `passed` is true it will be empty.

    """
    passed = False
    failed = False

    log_out = []

    with open(uvm_log, "r") as log:
        # Simulation log has report summary at the end, which references
        # 'UVM_ERROR' which can cause false failures. The summary appears after
        # the test result so ignore any lines after the test result is seen for
        # 'UVM_ERROR' checking. If the loop terminated immediately when a test
        # result was seen it would miss issues where the test result is
        # (erronously) repeated multiple times with different results.
        test_result_seen = False

        for line in log:
            if ('UVM_ERROR' in line or 'UVM_FATAL' in line or 'Error' in line) \
                    and not test_result_seen:
                log_out.append(line.strip())
                failed = True

            if 'RISC-V UVM TEST PASSED' in line:
                test_result_seen = True
                passed = True

            if 'RISC-V UVM TEST FAILED' in line:
                test_result_seen = True
                failed = True
                break

    # If we saw PASSED and FAILED, that's a bit odd. But we should treat the
    # test as having failed.
    if failed:
        passed = False

    return (passed, log_out)