aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/cover/report_test.go
diff options
context:
space:
mode:
authorAlexander Potapenko <glider@google.com>2024-01-17 16:35:42 +0100
committerAleksandr Nogikh <nogikh@google.com>2024-01-18 09:51:45 +0000
commit1417953aed7e2cf2915fc27de870f3229f3cb66f (patch)
tree833ec40cccbcddb5a73ca115a7f31826eb51671f /pkg/cover/report_test.go
parent915053c78aa2a0bd5050388203940fad27112b23 (diff)
Revert "pkg/cover: ensure that all PCs returned by kcov have matching callbacks"
This reverts commit 3392690e404b6ba5022825d33259bc2e9e89eb53. x86 bots are unable to generate coverage reports, because they actually have coverage PCs without matching callbacks.
Diffstat (limited to 'pkg/cover/report_test.go')
-rw-r--r--pkg/cover/report_test.go32
1 files changed, 5 insertions, 27 deletions
diff --git a/pkg/cover/report_test.go b/pkg/cover/report_test.go
index 2c07cb107..64baf3ee2 100644
--- a/pkg/cover/report_test.go
+++ b/pkg/cover/report_test.go
@@ -11,7 +11,6 @@ package cover
import (
"bytes"
"encoding/csv"
- "fmt"
"os"
"path/filepath"
"reflect"
@@ -37,10 +36,8 @@ type Test struct {
Progs []Prog
DebugInfo bool
AddCover bool
- AddBadPc bool
- // Inexact coverage generated by AddCover=true may override empty Result.
- Result string
- Supports func(target *targets.Target) bool
+ Result string
+ Supports func(target *targets.Target) bool
}
func TestReportGenerator(t *testing.T) {
@@ -77,14 +74,6 @@ func TestReportGenerator(t *testing.T) {
DebugInfo: true,
},
{
- Name: "mismatch-pcs",
- AddCover: true,
- AddBadPc: true,
- CFlags: []string{"-fsanitize-coverage=trace-pc"},
- DebugInfo: true,
- Result: `.* do not have matching coverage callbacks`,
- },
- {
Name: "good-pie",
AddCover: true,
CFlags: []string{"-fsanitize-coverage=trace-pc", "-fpie"},
@@ -143,7 +132,7 @@ func TestReportGenerator(t *testing.T) {
}
func testReportGenerator(t *testing.T, target *targets.Target, test Test) {
- rep, csv, err := generateReport(t, target, &test)
+ rep, csv, err := generateReport(t, target, test)
if err != nil {
if test.Result == "" {
t.Fatalf("expected no error, but got:\n%v", err)
@@ -188,7 +177,7 @@ void* aslr_base() { return NULL; }
void __sanitizer_cov_trace_pc() { printf("%llu", (long long)(__builtin_return_address(0) - aslr_base())); }
`
-func buildTestBinary(t *testing.T, target *targets.Target, test *Test, dir string) string {
+func buildTestBinary(t *testing.T, target *targets.Target, test Test, dir string) string {
kcovSrc := filepath.Join(dir, "kcov.c")
kcovObj := filepath.Join(dir, "kcov.o")
if err := osutil.WriteFile(kcovSrc, []byte(kcovCode)); err != nil {
@@ -268,7 +257,7 @@ func buildTestBinary(t *testing.T, target *targets.Target, test *Test, dir strin
return bin
}
-func generateReport(t *testing.T, target *targets.Target, test *Test) ([]byte, []byte, error) {
+func generateReport(t *testing.T, target *targets.Target, test Test) ([]byte, []byte, error) {
dir := t.TempDir()
bin := buildTestBinary(t, target, test, dir)
cfg := &mgrconfig.Config{
@@ -303,7 +292,6 @@ func generateReport(t *testing.T, target *targets.Target, test *Test) ([]byte, [
}
if test.AddCover {
var pcs []uint64
- Inexact := false
// Sanitizers crash when installing signal handlers with static libc.
const sanitizerOptions = "handle_segv=0:handle_sigbus=0:handle_sigfpe=0"
cmd := osutil.Command(bin)
@@ -334,16 +322,6 @@ func generateReport(t *testing.T, target *targets.Target, test *Test) ([]byte, [
pcs = append(pcs, main.Addr+uint64(off))
}
t.Logf("using inexact coverage range 0x%x-0x%x", main.Addr, main.Addr+uint64(main.Size))
- Inexact = true
- }
- // All PCs are required to have corresponding coverage callbacks. If the expected result is empty,
- // override it with an error message.
- if Inexact && test.Result == "" {
- test.Result = fmt.Sprintf("%d out of %d PCs returned by kcov do not have matching coverage callbacks",
- len(pcs)-1, len(pcs))
- }
- if test.AddBadPc {
- pcs = append(pcs, 0xdeadbeef)
}
progs = append(progs, Prog{Data: "main", PCs: pcs})
}