X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=test%2Fexec_test.go;fp=test%2Fexec_test.go;h=8759dbd7e3ce1f29233f6e5b61bfb244da048968;hb=72bb1c521aff5bb166db287ef426b243166d8927;hp=ff67322021399d10a9241ea0e92a69f03d684f36;hpb=83fad88204387d196f755c718de40828c08dc7ac;p=src%2Fxds%2Fxds-server.git 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) }