return
}
+ config.Path, err = h.pullCreate(j, "results")
+ if err != nil {
+ h.fail(j, fmt.Sprintf("Internal Weles error while creating a new path in ArtifactManager : %s", err.Error()))
+ return
+ }
+
for i, image := range config.Action.Deploy.Images {
if image.URI != "" {
path, err := h.push(j, AM_IMAGEFILE, fmt.Sprintf("Image_%d", i), image.URI)
"context"
"fmt"
"log"
+ "os"
"sync"
. "git.tizen.org/tools/weles"
notify chan<- DryadJobStatusChange
cancel context.CancelFunc
failReason string
+ f *os.File
}
// newDryadJobWithCancel creates an instance of dryadJob without a goroutine.
// It is intended to be used by tests and newDryadJob only.
func newDryadJobWithCancel(job JobID, changes chan<- DryadJobStatusChange,
runner DryadJobRunner, cancel context.CancelFunc) *dryadJob {
-
dJob := &dryadJob{
mutex: new(sync.Mutex),
runner: runner,
session, _ := dryad.NewSessionProvider(rusalka) // FIXME: Make use of returned error.
device := dryad.NewDeviceCommunicationProvider(session)
+ f, err := os.Create(conf.Path)
+ if err != nil {
+ panic(err)
+ }
+
ctx, cancel := context.WithCancel(context.Background())
- runner := newDryadJobRunner(ctx, session, device, conf)
+ runner := newDryadJobRunner(ctx, session, device, conf, f)
dJob := newDryadJobWithCancel(job, changes, runner, cancel)
+ dJob.f = f
go dJob.run(ctx)
return dJob
}
d.changeStatus(DJ_OK)
}()
+ defer d.f.Close()
d.executePhase(DJ_DEPLOY, d.runner.Deploy)
d.executePhase(DJ_BOOT, d.runner.Boot)
d.executePhase(DJ_TEST, d.runner.Test)
import (
"context"
+ "io"
+ "log"
"strings"
"time"
rusalka dryad.SessionProvider
device dryad.DeviceCommunicationProvider
conf weles.Config
+ log *log.Logger
}
// newDryadJobRunner prepares a new instance of dryadJobRunner
// and returns DryadJobRunner interface to it.
func newDryadJobRunner(ctx context.Context, rusalka dryad.SessionProvider,
- device dryad.DeviceCommunicationProvider, conf weles.Config) DryadJobRunner {
+ device dryad.DeviceCommunicationProvider, conf weles.Config, w io.Writer) DryadJobRunner {
return &dryadJobRunner{
ctx: ctx,
rusalka: rusalka,
device: device,
conf: conf,
+ log: log.New(w, "", log.LstdFlags),
}
}
// Deploy is part of DryadJobRunner interface.
func (d *dryadJobRunner) Deploy() (err error) {
+ d.log.Println("DEPLOY")
err = d.rusalka.TS()
if err != nil {
return
// Boot is part of DryadJobRunner interface.
func (d *dryadJobRunner) Boot() (err error) {
+ d.log.Println("BOOT")
// Attempt to start a device boot.
err = d.rusalka.DUT()
if err != nil {
// Test is part of DryadJobRunner interface.
func (d *dryadJobRunner) Test() error {
+ d.log.Println("TEST")
for _, testcase := range d.conf.Action.Test.TestCases {
+ d.log.Println("current testcase:", testcase)
for _, testaction := range testcase.TestActions {
+ d.log.Println("current testaction:", testaction)
switch action := testaction.(type) {
case weles.Push:
- d.device.CopyFilesTo([]string{action.Path}, action.Dest)
+ err := d.device.CopyFilesTo([]string{action.Path}, action.Dest)
+ if err != nil {
+ return err
+ }
case weles.Run:
// TODO: action.Name splot should smarter (shell-like) or avoided at all.
- d.device.Exec(strings.Split(action.Name, " "), defaultDeviceExecTimeout)
+ stdout, stderr, err := d.device.Exec(strings.Split(action.Name, " "), defaultDeviceExecTimeout)
+ d.log.Println("stdout:", string(stdout))
+ d.log.Println("stderr:", string(stderr))
+ d.log.Println("error", err.Error())
case weles.Pull:
- d.device.CopyFilesFrom([]string{action.Src}, action.Path)
+ err := d.device.CopyFilesFrom([]string{action.Src}, action.Path)
+ if err != nil {
+ return err
+ }
default:
panic("unknown test action type")
}