-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Labels
questionFurther information is requestedFurther information is requested
Description
[root@xxx]# cat main_test.go
package main
import (
"testing"
"github.com/pingcap/failpoint"
)
func TestGetValue(t *testing.T) {
failpoint.Enable("main/failpoint-name","return(4)")
t.Log("result:", GetValue())
}
[root@xxx]# cat main.go
package main
import (
"fmt"
"github.com/pingcap/failpoint"
)
func GetValue() int {
if val, _err_ := failpoint.Eval(_curpkg_("failpoint-name")); _err_ == nil {
return val.(int)
}
return 1
}
func main() {
fmt.Println("Hello world ", GetValue())
}
[root@xxx]# GOCACHE=/tmp/failpoint-cache GO_FAILPOINTS="main/failpoint-name=return(4)" CGO_ENABLED=1 GO111MODULE=on go test-v -toolexec /usr/bin/failpoint-toolexec main_test.go main.go binding__failpoint_binding__.go
=== RUN TestGetValue
main_test.go:10: result: 1
--- PASS: TestGetValue (0.00s)
PASS
ok command-line-arguments 0.006s
expect:
[root@xxx]# GOCACHE=/tmp/failpoint-cache GO_FAILPOINTS="main/failpoint-name=return(4)" CGO_ENABLED=1 GO111MODULE=on go test-v -toolexec /usr/bin/failpoint-toolexec main_test.go main.go binding__failpoint_binding__.go
=== RUN TestGetValue
main_test.go:10: result: 4
--- PASS: TestGetValue (0.00s)
PASS
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested