Add all
This commit is contained in:
135
testGround.go
Normal file
135
testGround.go
Normal file
@@ -0,0 +1,135 @@
|
||||
|
||||
package CmpExec1
|
||||
|
||||
import (
|
||||
"log"
|
||||
)
|
||||
|
||||
func Exec1GroundTestStdOutFunc(s string) {
|
||||
if s == "" {
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("StdOut", s)
|
||||
}
|
||||
|
||||
func Exec1GroundTestStdErrFunc(s string) {
|
||||
if s == "" {
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("StdErr", s)
|
||||
}
|
||||
|
||||
func Exec1GroundTest(opt *CmpExec1GroundStruct) {
|
||||
ret := Exec1Ground(opt)
|
||||
|
||||
Exec1Print(ret)
|
||||
|
||||
if ret.Error != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if opt.Background {
|
||||
log.Println("Wait channel")
|
||||
<- ret.C
|
||||
|
||||
Exec1Print(ret)
|
||||
}
|
||||
}
|
||||
|
||||
func Exec1GroundTestErrPath(bg bool) {
|
||||
opt := &CmpExec1GroundStruct{
|
||||
Background: bg,
|
||||
LimitTime: 3000,
|
||||
StdOutFunc: Exec1GroundTestStdOutFunc,
|
||||
StdErrFunc: Exec1GroundTestStdErrFunc,
|
||||
CommandArg: []string{
|
||||
"./test.sh",
|
||||
"-a",
|
||||
},
|
||||
}
|
||||
|
||||
Exec1GroundTest(opt)
|
||||
}
|
||||
|
||||
func Exec1GroundTestErrParm(bg bool) {
|
||||
opt := &CmpExec1GroundStruct{
|
||||
Background: bg,
|
||||
LimitTime: 3000,
|
||||
StdOutFunc: Exec1GroundTestStdOutFunc,
|
||||
StdErrFunc: Exec1GroundTestStdErrFunc,
|
||||
CommandArg: []string{
|
||||
"sleep",
|
||||
"v",
|
||||
},
|
||||
}
|
||||
|
||||
Exec1GroundTest(opt)
|
||||
}
|
||||
|
||||
func Exec1GroundTestTimeout(bg bool) {
|
||||
opt := &CmpExec1GroundStruct{
|
||||
Background: bg,
|
||||
LimitTime: 2,
|
||||
StdOutFunc: Exec1GroundTestStdOutFunc,
|
||||
StdErrFunc: Exec1GroundTestStdErrFunc,
|
||||
CommandArg: []string{
|
||||
"sleep",
|
||||
"4",
|
||||
},
|
||||
}
|
||||
|
||||
Exec1GroundTest(opt)
|
||||
}
|
||||
|
||||
func Exec1GroundTestSuccess(bg bool) {
|
||||
opt := &CmpExec1GroundStruct{
|
||||
Background: bg,
|
||||
LimitTime: 3000,
|
||||
StdOutFunc: Exec1GroundTestStdOutFunc,
|
||||
StdErrFunc: Exec1GroundTestStdErrFunc,
|
||||
CommandArg: []string{
|
||||
"bash",
|
||||
"-c",
|
||||
"sleep 1 ; echo ok ; sleep 1; echo ok",
|
||||
},
|
||||
}
|
||||
|
||||
Exec1GroundTest(opt)
|
||||
}
|
||||
|
||||
func Exec1GroundTestAll() {
|
||||
log.Println("====", "Exec1GroundTestErrPath")
|
||||
|
||||
Exec1GroundTestErrPath(true)
|
||||
|
||||
log.Println("====", "Exec1GroundTestErrParm")
|
||||
|
||||
Exec1GroundTestErrParm(true)
|
||||
|
||||
log.Println("====", "Exec1GroundTestTimeout")
|
||||
|
||||
Exec1GroundTestTimeout(true)
|
||||
|
||||
log.Println("====", "Exec1GroundTestSuccess")
|
||||
|
||||
Exec1GroundTestSuccess(true)
|
||||
|
||||
|
||||
log.Println("====", "Exec1GroundTestErrPath")
|
||||
|
||||
Exec1GroundTestErrPath(false)
|
||||
|
||||
log.Println("====", "Exec1GroundTestErrParm")
|
||||
|
||||
Exec1GroundTestErrParm(false)
|
||||
|
||||
log.Println("====", "Exec1GroundTestTimeout")
|
||||
|
||||
Exec1GroundTestTimeout(false)
|
||||
|
||||
log.Println("====", "Exec1GroundTestSuccess")
|
||||
|
||||
Exec1GroundTestSuccess(false)
|
||||
}
|
Reference in New Issue
Block a user