parent
305c27eb7d
commit
31b5e8a948
47
main.go
47
main.go
@ -258,6 +258,7 @@ func dumpResult(q *qemu.QemuSystem, ka artifact, ki kernelInfo, build_ok, run_ok
|
|||||||
}
|
}
|
||||||
|
|
||||||
func whatever(swg *sizedwaitgroup.SizedWaitGroup, ka artifact, ki kernelInfo,
|
func whatever(swg *sizedwaitgroup.SizedWaitGroup, ka artifact, ki kernelInfo,
|
||||||
|
binaryPath, testPath string,
|
||||||
qemuTimeout, dockerTimeout time.Duration) {
|
qemuTimeout, dockerTimeout time.Duration) {
|
||||||
|
|
||||||
defer swg.Done()
|
defer swg.Done()
|
||||||
@ -286,24 +287,33 @@ func whatever(swg *sizedwaitgroup.SizedWaitGroup, ka artifact, ki kernelInfo,
|
|||||||
test_ok := false
|
test_ok := false
|
||||||
defer dumpResult(q, ka, ki, &build_ok, &run_ok, &test_ok)
|
defer dumpResult(q, ka, ki, &build_ok, &run_ok, &test_ok)
|
||||||
|
|
||||||
// TODO Write build log to file or database
|
var outFile, output string
|
||||||
outFile, output, err := build(tmp, ka, ki, dockerTimeout)
|
if binaryPath == "" {
|
||||||
if err != nil {
|
// TODO Write build log to file or database
|
||||||
log.Println(output)
|
outFile, output, err = build(tmp, ka, ki, dockerTimeout)
|
||||||
return
|
if err != nil {
|
||||||
|
log.Println(output)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
build_ok = true
|
||||||
|
} else {
|
||||||
|
outFile = binaryPath
|
||||||
|
build_ok = true
|
||||||
}
|
}
|
||||||
build_ok = true
|
|
||||||
|
|
||||||
err = cleanDmesg(q)
|
err = cleanDmesg(q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
testPath := outFile + "_test"
|
if testPath == "" {
|
||||||
|
testPath = outFile + "_test"
|
||||||
|
}
|
||||||
|
|
||||||
remoteTest := fmt.Sprintf("/tmp/test_%d", rand.Int())
|
remoteTest := fmt.Sprintf("/tmp/test_%d", rand.Int())
|
||||||
err = q.CopyFile("user", testPath, remoteTest)
|
err = q.CopyFile("user", testPath, remoteTest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Println("copy file err", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,7 +402,7 @@ func readArtifactConfig(path string) (artifactCfg artifact, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func performCI(ka artifact, kcfg kernelConfig,
|
func performCI(ka artifact, kcfg kernelConfig, binaryPath, testPath string,
|
||||||
qemuTimeout, dockerTimeout time.Duration) (err error) {
|
qemuTimeout, dockerTimeout time.Duration) (err error) {
|
||||||
|
|
||||||
swg := sizedwaitgroup.New(runtime.NumCPU())
|
swg := sizedwaitgroup.New(runtime.NumCPU())
|
||||||
@ -405,8 +415,8 @@ func performCI(ka artifact, kcfg kernelConfig,
|
|||||||
|
|
||||||
if supported {
|
if supported {
|
||||||
swg.Add()
|
swg.Add()
|
||||||
go whatever(&swg, ka, kernel, qemuTimeout,
|
go whatever(&swg, ka, kernel, binaryPath, testPath,
|
||||||
dockerTimeout)
|
qemuTimeout, dockerTimeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
swg.Wait()
|
swg.Wait()
|
||||||
@ -420,8 +430,8 @@ func exists(path string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func pewHandler(workPath, kcfgPath, ovrrdKrnl string, guess bool,
|
func pewHandler(workPath, kcfgPath, ovrrdKrnl, binaryPath, testPath string,
|
||||||
qemuTimeout, dockerTimeout time.Duration) (err error) {
|
guess bool, qemuTimeout, dockerTimeout time.Duration) (err error) {
|
||||||
|
|
||||||
ka, err := readArtifactConfig(workPath + "/.out-of-tree.toml")
|
ka, err := readArtifactConfig(workPath + "/.out-of-tree.toml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -467,7 +477,8 @@ func pewHandler(workPath, kcfgPath, ovrrdKrnl string, guess bool,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = performCI(ka, kcfg, qemuTimeout, dockerTimeout)
|
err = performCI(ka, kcfg, binaryPath, testPath, qemuTimeout,
|
||||||
|
dockerTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -503,11 +514,17 @@ func main() {
|
|||||||
pewGuessFlag := pewCommand.Flag("guess", "Try all defined kernels")
|
pewGuessFlag := pewCommand.Flag("guess", "Try all defined kernels")
|
||||||
pewGuess := pewGuessFlag.Bool()
|
pewGuess := pewGuessFlag.Bool()
|
||||||
|
|
||||||
|
pewBinaryFlag := pewCommand.Flag("binary", "Use binary, do not build")
|
||||||
|
pewBinary := pewBinaryFlag.String()
|
||||||
|
|
||||||
|
pewTestFlag := pewCommand.Flag("test", "Override path test")
|
||||||
|
pewTest := pewTestFlag.String()
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
switch kingpin.MustParse(app.Parse(os.Args[1:])) {
|
switch kingpin.MustParse(app.Parse(os.Args[1:])) {
|
||||||
case pewCommand.FullCommand():
|
case pewCommand.FullCommand():
|
||||||
err = pewHandler(*path, *kcfg, *pewKernel, *pewGuess,
|
err = pewHandler(*path, *kcfg, *pewKernel, *pewBinary,
|
||||||
*qemuTimeout, *dockerTimeout)
|
*pewTest, *pewGuess, *qemuTimeout, *dockerTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user