分析进程退出状态
(rst *commonStructs.TestCaseResult, pinfo *ProcessInfo, judger bool)
| 54 | |
| 55 | // 分析进程退出状态 |
| 56 | func (session *JudgeSession) analysisExitStatus(rst *commonStructs.TestCaseResult, pinfo *ProcessInfo, judger bool) { |
| 57 | status := pinfo.Status |
| 58 | |
| 59 | // 特判 |
| 60 | if judger { |
| 61 | if status.Signaled() { |
| 62 | sig := status.Signal() |
| 63 | if session.JudgeConfig.SpecialJudge.Mode != constants.SpecialJudgeModeInteractive { |
| 64 | // 检查判题程序是否超时 |
| 65 | if sig == syscall.SIGXCPU || sig == syscall.SIGALRM { |
| 66 | rst.JudgeResult = constants.JudgeFlagSpecialJudgeTimeout |
| 67 | rst.ReInfo = fmt.Sprintf("special judger time limit exceed, unix singal: %d", sig) |
| 68 | } else { |
| 69 | rst.JudgeResult = constants.JudgeFlagSpecialJudgeError |
| 70 | rst.ReInfo = fmt.Sprintf("special judger caused an error, unix singal: %d", sig) |
| 71 | } |
| 72 | } else { |
| 73 | // 交互特判时,如果选手程序让判题程序挂了,视作RE |
| 74 | rst.JudgeResult = constants.JudgeFlagRE |
| 75 | rst.ReInfo = fmt.Sprintf("special judger caused an error, unix singal: %d", sig) |
| 76 | } |
| 77 | } else if status.Exited() { |
| 78 | // 如果特判程序正常退出 |
| 79 | exitcode := status.ExitStatus() |
| 80 | rst.SPJExitCode = exitcode |
| 81 | if session.JudgeConfig.SpecialJudge.UseTestlib { |
| 82 | // 如果是Testlib的checker,则退出代码要按照他们的规则去判定 |
| 83 | msg, err := ioutil.ReadFile(path.Join(session.SessionDir, rst.CheckerReport)) |
| 84 | if err != nil { |
| 85 | rst.JudgeResult = constants.JudgeFlagSpecialJudgeError |
| 86 | rst.SPJMsg = fmt.Sprintf("read checker report file error: %s", err.Error()) |
| 87 | } else { |
| 88 | tr := commonStructs.TestlibCheckerResult{} |
| 89 | ok := utils.XMLStringObject(string(msg), &tr) |
| 90 | if ok { |
| 91 | rst.SPJMsg = tr.Description |
| 92 | if flag, ok := constants.TestlibOutcomeMapping[tr.Outcome]; ok { |
| 93 | rst.JudgeResult = flag |
| 94 | } else { |
| 95 | rst.JudgeResult = constants.JudgeFlagSpecialJudgeError |
| 96 | } |
| 97 | if tr.Outcome == "partially-correct" { |
| 98 | rst.PartiallyScore, _ = strconv.Atoi(tr.PcType) |
| 99 | } |
| 100 | } else { |
| 101 | rst.JudgeResult = constants.JudgeFlagSpecialJudgeError |
| 102 | rst.SPJMsg = fmt.Sprintf("parsee checker report file error:\n%s", string(msg)) |
| 103 | } |
| 104 | } |
| 105 | } else { |
| 106 | // 判断退出代码是否正确 |
| 107 | if exitcode == constants.JudgeFlagAC || exitcode == constants.JudgeFlagPE || |
| 108 | exitcode == constants.JudgeFlagWA || exitcode == constants.JudgeFlagOLE || |
| 109 | exitcode == constants.JudgeFlagSpecialJudgeRequireChecker { |
| 110 | rst.JudgeResult = exitcode |
| 111 | } else { |
| 112 | rst.JudgeResult = constants.JudgeFlagSpecialJudgeError |
| 113 | rst.SPJMsg = fmt.Sprintf("special judger return with a wrong exitcode: %d", exitcode) |
no test coverage detected