Code Review
/
src
/
xds
/
xds-server.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
test exec: waiting exit event after exec cmd
[src/xds/xds-server.git]
/
test
/
exec_test.go
diff --git
a/test/exec_test.go
b/test/exec_test.go
index
1ab781a
..
884ba87
100644
(file)
--- a/
test/exec_test.go
+++ b/
test/exec_test.go
@@
-22,7
+22,6
@@
import (
"os/exec"
"path"
"testing"
"os/exec"
"path"
"testing"
- "time"
"gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xsapiv1"
"github.com/stretchr/testify/assert"
"gerrit.automotivelinux.org/gerrit/src/xds/xds-server/lib/xsapiv1"
"github.com/stretchr/testify/assert"
@@
-44,17
+43,6
@@
func InitExec(t *testing.T) string {
return helloworldDir
}
return helloworldDir
}
-/*flush channel with timeout*/
-func flushChannelExec(channel chan xsapiv1.ExecOutMsg, ms time.Duration) {
- timeoutB := false
- for !timeoutB {
- select {
- case <-channel:
- case <-time.After(ms * time.Millisecond):
- timeoutB = true
- }
- }
-}
func TestExec(t *testing.T) {
helloworldDir := InitExec(t)
/*channel for SDK events*/
func TestExec(t *testing.T) {
helloworldDir := InitExec(t)
/*channel for SDK events*/
@@
-88,10
+76,10
@@
func TestExec(t *testing.T) {
assert.NotNil(t, cfg)
/*channel for ExecOutMsg*/
assert.NotNil(t, cfg)
/*channel for ExecOutMsg*/
- chExec := make(chan xsapiv1.Exec
Ou
tMsg)
+ chExec := make(chan xsapiv1.Exec
Exi
tMsg)
defer close(chExec)
/*connect to ExecOutEvent*/
defer close(chExec)
/*connect to ExecOutEvent*/
- sCli.Conn.On(xsapiv1.Exec
OutEvent, func(ev xsapiv1.ExecOu
tMsg) {
+ sCli.Conn.On(xsapiv1.Exec
ExitEvent, func(ev xsapiv1.ExecExi
tMsg) {
chExec <- ev
})
chExec <- ev
})
@@
-117,7
+105,8
@@
func TestExec(t *testing.T) {
var execRes xsapiv1.ExecArgs
Debugf(t, "exec cmake cmd(%v)", cmd)
assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes))
var execRes xsapiv1.ExecArgs
Debugf(t, "exec cmake cmd(%v)", cmd)
assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes))
- flushChannelExec(chExec, 1000) //waiting for execOutMsg
+ exitMsg := <-chExec
+ assert.Equal(t, exitMsg.Code, 0)
/*make helloworld project with fake sdk*/
cmd = "source " + sdkSourceFile
/*make helloworld project with fake sdk*/
cmd = "source " + sdkSourceFile
@@
-133,7
+122,8
@@
func TestExec(t *testing.T) {
/*post exec cmd make*/
Debugf(t, "exec make cmd(%v)", cmd)
assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes))
/*post exec cmd make*/
Debugf(t, "exec make cmd(%v)", cmd)
assert.Nil(t, HTTPCli.Post("/exec", exec, &execRes))
- flushChannelExec(chExec, 1000) //waiting for execOutMsg
+ exitMsg = <-chExec
+ assert.Equal(t, exitMsg.Code, 0)
/*check if helloworld.so exists*/
Debug(t, "check that helloworld.so exists")
/*check if helloworld.so exists*/
Debug(t, "check that helloworld.so exists")