X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Fxds%2Fxds-server.git;a=blobdiff_plain;f=test%2Fexec_test.go;fp=test%2Fexec_test.go;h=6ffc3502bba72773ee4f7303d5c4788f51792839;hp=39f00c6562f5df2a9cf621887e3ad8fadc431da0;hb=a740425411f120ff7263f16f268e7efd7c19b311;hpb=3e3222406a6f015a9fee3720e8ba76ecf58b087f diff --git a/test/exec_test.go b/test/exec_test.go index 39f00c6..6ffc350 100644 --- a/test/exec_test.go +++ b/test/exec_test.go @@ -24,7 +24,7 @@ import ( "testing" "gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xsapiv1" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func InitExec(t *testing.T) string { @@ -34,14 +34,14 @@ func InitExec(t *testing.T) string { cmd := exec.Command("cp", "-r", helloworldFixturesDir, helloworldDir) var out bytes.Buffer cmd.Stdout = &out - assert.Nil(t, cmd.Run()) + require.Nil(t, cmd.Run()) /*clone submodules app templates into helloworld*/ subHelloworldAppTemplateDir := path.Join(helloworldDir, "conf.d", "app-templates") cmd = exec.Command("git", "clone", "-b", "flounder", "https://gerrit.automotivelinux.org/gerrit/p/apps/app-templates.git", subHelloworldAppTemplateDir) - assert.Nil(t, cmd.Run()) + require.Nil(t, cmd.Run()) return helloworldDir } @@ -60,8 +60,8 @@ func TestExec(t *testing.T) { /*check there is no project*/ var cfgArray []xsapiv1.FolderConfig - assert.Nil(t, HTTPCli.Get("/folders", &cfgArray)) - assert.Equal(t, len(cfgArray), 0) + require.Nil(t, HTTPCli.Get("/folders", &cfgArray)) + require.Equal(t, len(cfgArray), 0) fPrj := xsapiv1.FolderConfig{ Label: "testproject", @@ -74,8 +74,8 @@ func TestExec(t *testing.T) { } /*create project*/ var cfg xsapiv1.FolderConfig - assert.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) - assert.NotNil(t, cfg) + require.Nil(t, HTTPCli.Post("/folders", fPrj, &cfg)) + require.NotNil(t, cfg) /*channel for ExecExitMsg*/ chExec := make(chan xsapiv1.ExecExitMsg) @@ -99,7 +99,7 @@ func TestExec(t *testing.T) { } Debugf(t, "exec cmake cmd(%v)", cmd) cmdOut = "" - assert.NotNil(t, HTTPCli.Post("/exec", exec, &execRes)) + require.NotNil(t, HTTPCli.Post("/exec", exec, &execRes)) /*basic check: verify that environment is set correctly (use the right sdk)*/ cmd = "pwd && echo \"SDKTARGETSYSROOT=<$SDKTARGETSYSROOT>\"" @@ -110,9 +110,9 @@ func TestExec(t *testing.T) { } Debugf(t, "exec cmake cmd(%v)", cmd) cmdOut = "" - assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) + require.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) exitMsg := <-chExec - assert.Equal(t, exitMsg.Code, 0) + require.Equal(t, exitMsg.Code, 0) /*cmake helloworld project with fake sdk*/ cmd = "cd " + fPrj.ClientPath @@ -129,9 +129,9 @@ func TestExec(t *testing.T) { Cmd: cmd, } Debugf(t, "exec cmake cmd(%v)", cmd) - assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) + require.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) exitMsg = <-chExec - assert.Equal(t, exitMsg.Code, 0) + require.Equal(t, exitMsg.Code, 0) /*make helloworld project with fake sdk*/ cmd = "cd " + fPrj.ClientPath @@ -142,17 +142,17 @@ func TestExec(t *testing.T) { exec.Cmd = cmd /*post exec cmd make*/ Debugf(t, "exec make cmd(%v)", cmd) - assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) + require.Nil(t, HTTPCli.Post("/exec", exec, &execRes)) exitMsg = <-chExec - assert.Equal(t, exitMsg.Code, 0) + require.Equal(t, exitMsg.Code, 0) /*check if helloworld.so exists*/ Debug(t, "check that helloworld.so exists") _, err := os.Stat(path.Join(fPrj.ClientPath, "build/helloworld/helloworld.so")) - assert.Nil(t, err) + require.Nil(t, err) /*deinit*/ - assert.Nil(t, HTTPCli.Delete("/folders/"+cfg.ID, &cfg)) + require.Nil(t, HTTPCli.Delete("/folders/"+cfg.ID, &cfg)) RemoveSdk(t, sdkRes, chSdks) DisconnectSDKStateChange(t, sCli) }