(configDir, vBin string, tCase *structs.TestCase)
| 43 | } |
| 44 | |
| 45 | func runTestCase(configDir, vBin string, tCase *structs.TestCase) error { |
| 46 | ctx, _ := context.WithTimeout(context.Background(), 3*time.Second) |
| 47 | var inbytes []byte |
| 48 | var err error |
| 49 | // 判断是generator还是普通input |
| 50 | if tCase.UseGenerator { |
| 51 | inbytes, err = utils.CallGenerator(ctx, tCase, configDir) |
| 52 | if err != nil { |
| 53 | return err |
| 54 | } |
| 55 | } else { |
| 56 | inbytes, err = ioutil.ReadFile(path.Join(configDir, tCase.Input)) |
| 57 | if err != nil { |
| 58 | return err |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | rel, err := utils.RunUnixShell(&structs.ShellOptions{ |
| 63 | Context: ctx, |
| 64 | Name: vBin, |
| 65 | Args: nil, |
| 66 | StdWriter: nil, |
| 67 | OnStart: func(writer io.Writer) error { |
| 68 | _, err := writer.Write(inbytes) |
| 69 | return err |
| 70 | }, |
| 71 | }) |
| 72 | if err != nil { |
| 73 | return err |
| 74 | } |
| 75 | if rel.Success { |
| 76 | tCase.ValidatorVerdict = true |
| 77 | tCase.ValidatorComment = "" |
| 78 | } else { |
| 79 | log.Printf("[validator] validator error: %s", rel.Stderr) |
| 80 | tCase.ValidatorVerdict = false |
| 81 | tCase.ValidatorComment = rel.Stderr |
| 82 | } |
| 83 | return nil |
| 84 | } |
| 85 | |
| 86 | func isValidatorExists(config *structs.JudgeConfiguration) error { |
| 87 | validator, err := utils.GetCompiledBinaryFileAbsPath("validator", config.TestLib.ValidatorName, config.ConfigDir) |
no test coverage detected