1
0
Fork 0

Treat test files as relative to build directory

master
dump_stack() 2023-02-16 10:46:24 +00:00
parent 2d6db97b43
commit 09feffb6a8
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
3 changed files with 17 additions and 12 deletions

View File

@ -227,7 +227,7 @@ func debugHandler(kcfg config.KernelConfig, workPath, kernRegex, gdb string,
return return
} }
outFile, output, err := build(tmp, ka, ki, dockerTimeout) _, outFile, output, err := build(tmp, ka, ki, dockerTimeout)
if err != nil { if err != nil {
log.Println(err, output) log.Println(err, output)
return return

25
pew.go
View File

@ -211,25 +211,25 @@ func applyPatches(src string, ka config.Artifact) (err error) {
} }
func build(tmp string, ka config.Artifact, ki config.KernelInfo, func build(tmp string, ka config.Artifact, ki config.KernelInfo,
dockerTimeout time.Duration) (outPath, output string, err error) { dockerTimeout time.Duration) (outdir, outpath, output string, err error) {
target := fmt.Sprintf("%d_%s", rand.Int(), ki.KernelRelease) target := fmt.Sprintf("%d_%s", rand.Int(), ki.KernelRelease)
tmpSourcePath := tmp + "/source" outdir = tmp + "/source"
err = copy.Copy(ka.SourcePath, tmpSourcePath) err = copy.Copy(ka.SourcePath, outdir)
if err != nil { if err != nil {
return return
} }
err = applyPatches(tmpSourcePath, ka) err = applyPatches(outdir, ka)
if err != nil { if err != nil {
return return
} }
outPath = tmpSourcePath + "/" + target outpath = outdir + "/" + target
if ka.Type == config.KernelModule { if ka.Type == config.KernelModule {
outPath += ".ko" outpath += ".ko"
} }
kernel := "/lib/modules/" + ki.KernelRelease + "/build" kernel := "/lib/modules/" + ki.KernelRelease + "/build"
@ -244,9 +244,9 @@ func build(tmp string, ka config.Artifact, ki config.KernelInfo,
if ki.ContainerName != "" { if ki.ContainerName != "" {
output, err = dockerRun(dockerTimeout, ki.ContainerName, output, err = dockerRun(dockerTimeout, ki.ContainerName,
tmpSourcePath, buildCommand+" && chmod -R 777 /work") outdir, buildCommand+" && chmod -R 777 /work")
} else { } else {
cmd := exec.Command("bash", "-c", "cd "+tmpSourcePath+" && "+ cmd := exec.Command("bash", "-c", "cd "+outdir+" && "+
buildCommand) buildCommand)
timer := time.AfterFunc(dockerTimeout, func() { timer := time.AfterFunc(dockerTimeout, func() {
cmd.Process.Kill() cmd.Process.Kill()
@ -313,6 +313,7 @@ func genOkFail(name string, ok bool) (aurv aurora.Value) {
} }
type phasesResult struct { type phasesResult struct {
BuildDir string
BuildArtifact string BuildArtifact string
Build, Run, Test struct { Build, Run, Test struct {
Output string Output string
@ -409,6 +410,9 @@ func copyArtifactAndTest(q *qemu.System, ka config.Artifact,
// Copy all test files to the remote machine // Copy all test files to the remote machine
for _, f := range ka.TestFiles { for _, f := range ka.TestFiles {
if f.Local[0] != '/' {
f.Local = res.BuildDir + "/" + f.Local
}
err = q.CopyFile(f.User, f.Local, f.Remote) err = q.CopyFile(f.User, f.Local, f.Remote)
if err != nil { if err != nil {
log.Println("error copy err:", err, f.Local, f.Remote) log.Println("error copy err:", err, f.Local, f.Remote)
@ -545,8 +549,9 @@ func whatever(swg *sizedwaitgroup.SizedWaitGroup, ka config.Artifact,
defer dumpResult(q, ka, ki, &result, dist, tag, binaryPath, db) defer dumpResult(q, ka, ki, &result, dist, tag, binaryPath, db)
if binaryPath == "" { if binaryPath == "" {
result.BuildArtifact, result.Build.Output, err = build(tmp, ka, // TODO: build should return structure
ki, dockerTimeout) result.BuildDir, result.BuildArtifact, result.Build.Output, err =
build(tmp, ka, ki, dockerTimeout)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
return return

View File

@ -111,7 +111,7 @@ func buildPreload(workPath, tmp string, ki config.KernelInfo,
dockerTimeout = ka.Docker.Timeout.Duration dockerTimeout = ka.Docker.Timeout.Duration
} }
artifact, _, err = build(tmp, ka, ki, dockerTimeout) _, artifact, _, err = build(tmp, ka, ki, dockerTimeout)
return return
} }