mirror of
https://github.com/golang/go
synced 2024-11-20 06:04:52 -07:00
cmd/go: add test case for cgo coverage
This is a test case for CL 34680044. Fixes #6333. LGTM=bradfitz R=golang-codereviews, bradfitz, minux.ma CC=golang-codereviews https://golang.org/cl/71230049
This commit is contained in:
parent
da1bea0ef0
commit
9abcd53eda
@ -568,6 +568,16 @@ TEST coverage runs
|
||||
./testgo test -short -coverpkg=strings strings regexp || ok=false
|
||||
./testgo test -short -cover strings math regexp || ok=false
|
||||
|
||||
TEST coverage with cgo
|
||||
d=$(TMPDIR=/var/tmp mktemp -d -t testgoXXX)
|
||||
./testgo test -short -cover ./testdata/cgocover >$d/cgo.out 2>&1 || ok=false
|
||||
cat $d/cgo.out
|
||||
if grep 'coverage: 0.0%' $d/cgo.out >/dev/null; then
|
||||
ok=false
|
||||
echo no coverage for cgo package
|
||||
ok=false
|
||||
fi
|
||||
|
||||
TEST cgo depends on syscall
|
||||
rm -rf $GOROOT/pkg/*_race
|
||||
d=$(TMPDIR=/var/tmp mktemp -d -t testgoXXX)
|
||||
|
19
src/cmd/go/testdata/cgocover/p.go
vendored
Normal file
19
src/cmd/go/testdata/cgocover/p.go
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
package p
|
||||
|
||||
/*
|
||||
void
|
||||
f(void)
|
||||
{
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
|
||||
var b bool
|
||||
|
||||
func F() {
|
||||
if b {
|
||||
for {
|
||||
}
|
||||
}
|
||||
C.f()
|
||||
}
|
7
src/cmd/go/testdata/cgocover/p_test.go
vendored
Normal file
7
src/cmd/go/testdata/cgocover/p_test.go
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
package p
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestF(t *testing.T) {
|
||||
F()
|
||||
}
|
Loading…
Reference in New Issue
Block a user