summaryrefslogtreecommitdiffstats
path: root/test/exec_test.go
diff options
context:
space:
mode:
authorClément Bénier <clement.benier@iot.bzh>2018-08-20 17:39:39 +0200
committerClément Bénier <clement.benier@iot.bzh>2018-08-21 11:08:36 +0200
commit72bb1c521aff5bb166db287ef426b243166d8927 (patch)
tree81c6af864f56afd365caf0930ca13e36478b1fb8 /test/exec_test.go
parent83fad88204387d196f755c718de40828c08dc7ac (diff)
tests: add comments and logs
Change-Id: I31ef0fa20a74f76b696ac9cb768fac18e2197ea5 Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
Diffstat (limited to 'test/exec_test.go')
-rw-r--r--test/exec_test.go24
1 files changed, 20 insertions, 4 deletions
diff --git a/test/exec_test.go b/test/exec_test.go
index ff67322..8759dbd 100644
--- a/test/exec_test.go
+++ b/test/exec_test.go
@@ -29,11 +29,15 @@ import (
)
func InitExec(t *testing.T) string {
+ t.Logf("Create helloworld directory with app-templates")
+ /*copy helloworld from fixtures to envRootCfgDir*/
helloworldDir := path.Join(os.Getenv(envRootCfgDir), "helloworld")
cmd := exec.Command("cp", "-r", helloworldFixturesDir, helloworldDir)
var out bytes.Buffer
cmd.Stdout = &out
assert.Nil(t, cmd.Run())
+
+ /*clone submodules app templates into helloworld*/
subHelloworldAppTemplateDir := path.Join(helloworldDir, "conf.d", "app-templates")
cmd = exec.Command("git", "clone", "https://gerrit.automotivelinux.org/gerrit/p/apps/app-templates.git", subHelloworldAppTemplateDir)
assert.Nil(t, cmd.Run())
@@ -53,6 +57,7 @@ func flushChannelExec(channel chan xsapiv1.ExecOutMsg, ms time.Duration) {
}
func TestExec(t *testing.T) {
helloworldDir := InitExec(t)
+ /*channel for SDK events*/
chSdks := make(chan xsapiv1.SDK)
defer close(chSdks)
sdk := xsapiv1.SDKInstallArgs{
@@ -63,6 +68,7 @@ func TestExec(t *testing.T) {
ConnectSDKStateChange(t, sCli, chSdks)
sdkRes := installFakeSdk(t, sdk, chSdks)
+ /*check there is no project*/
var cfgArray []xsapiv1.FolderConfig
assert.Nil(t, HTTPCli.Get("/folders", &cfgArray))
assert.Equal(t, len(cfgArray), 0)
@@ -76,16 +82,20 @@ func TestExec(t *testing.T) {
ServerPath: helloworldDir,
},
}
+ /*create project*/
var cfg xsapiv1.FolderConfig
assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg))
assert.NotNil(t, cfg)
+ /*channel for ExecOutMsg*/
chExec := make(chan xsapiv1.ExecOutMsg)
defer close(chExec)
+ /*connect to ExecOutEvent*/
sCli.Conn.On(xsapiv1.ExecOutEvent, func(ev xsapiv1.ExecOutMsg) {
chExec <- ev
})
+ /*cmake helloworld project with fake sdk*/
sdkSourceFile := path.Join(sdkRes.Path, "environment-setup-corei7-64-native-linux")
cmd := "source " + sdkSourceFile
cmd = cmd + " && "
@@ -99,14 +109,17 @@ func TestExec(t *testing.T) {
cmd = cmd + " && "
cmd = cmd + "cmake .."
+ /*post exec cmd cmake*/
exec := xsapiv1.ExecArgs{
ID: cfg.ID,
Cmd: cmd,
}
var execRes xsapiv1.ExecArgs
+ t.Logf("exec cmake cmd(%v)", cmd)
assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes))
- flushChannelExec(chExec, 1000)
+ flushChannelExec(chExec, 1000) //waiting for execOutMsg
+ /*make helloworld project with fake sdk*/
cmd = "source " + sdkSourceFile
cmd = cmd + " && "
cmd = cmd + "unset SDKTARGETSYSROOT"
@@ -117,15 +130,18 @@ func TestExec(t *testing.T) {
cmd = cmd + "&&"
cmd = cmd + "make"
exec.Cmd = cmd
+ /*post exec cmd make*/
+ t.Logf("exec make cmd(%v)", cmd)
assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes))
- flushChannelExec(chExec, 1000)
+ flushChannelExec(chExec, 1000) //waiting for execOutMsg
- /*check afb-helloworld.so exists*/
+ /*check if helloworld.so exists*/
+ t.Log("check that helloworld.so exists")
_, err := os.Stat(path.Join(fPrj.ClientPath, "build/helloworld/helloworld.so"))
assert.Nil(t, err)
+ /*deinit*/
assert.Nil(t, HTTPCli.Delete("/folders/"+cfg.ID, &cfg))
-
RemoveSdk(t, sdkRes, chSdks)
DisconnectSDKStateChange(t, sCli)
}