Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions syz-ci/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ func (mgr *Manager) uploadCoverReport() error {
return nil
}

func (mgr *Manager) uploadCoverJSONLToGCS(gcsClient gcs.Client, mgrSrc, gcsDest string, curTime time.Time,
func (mgr *Manager) uploadCoverJSONLToGCS(gcsClient gcs.Client, mgrSrc, gcsDest, nameSuffix string,
publish, compress bool, f func(io.Writer, *json.Decoder) error) error {
if !mgr.managercfg.Cover || gcsDest == "" {
return nil
Expand Down Expand Up @@ -934,10 +934,7 @@ func (mgr *Manager) uploadCoverJSONLToGCS(gcsClient gcs.Client, mgrSrc, gcsDest
})
eg.Go(func() error {
defer pr.Close()
fileName := fmt.Sprintf("%s/%s-%s-%d-%d.jsonl",
mgr.mgrcfg.DashboardClient,
mgr.name, curTime.Format(time.DateOnly),
curTime.Hour(), curTime.Minute())
fileName := fmt.Sprintf("%s/%s%s.jsonl", mgr.mgrcfg.DashboardClient, mgr.name, nameSuffix)
if err := uploadFile(egCtx, gcsClient, gcsDest, fileName, pr, publish); err != nil {
return fmt.Errorf("uploadFile: %w", err)
}
Expand All @@ -954,7 +951,7 @@ func (mgr *Manager) uploadCoverStat(fuzzingMinutes int) error {
if err := mgr.uploadCoverJSONLToGCS(nil,
"/cover?jsonl=1&flush=1",
mgr.cfg.CoverPipelinePath,
curTime,
time.Now().Format("-2006-01-02-15-04"),
false,
false,
func(w io.Writer, dec *json.Decoder) error {
Expand Down Expand Up @@ -986,7 +983,7 @@ func (mgr *Manager) uploadProgramsWithCoverage() error {
if err := mgr.uploadCoverJSONLToGCS(nil,
"/coverprogs?jsonl=1",
mgr.cfg.CoverProgramsPath,
time.Now(),
"",
mgr.cfg.PublishGCS,
true,
func(w io.Writer, dec *json.Decoder) error {
Expand Down
28 changes: 16 additions & 12 deletions syz-ci/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"net/http/httptest"
"strings"
"testing"
"time"

"github.com/google/syzkaller/dashboard/dashapi"
"github.com/google/syzkaller/pkg/cover"
Expand Down Expand Up @@ -122,8 +121,8 @@ func TestUploadCoverJSONLToGCS(t *testing.T) {
tests := []struct {
name string

inputJSONL string
inputTime time.Time
inputJSONL string
inputNameSuffix string

inputCompress bool
inputPublish bool
Expand All @@ -137,33 +136,37 @@ func TestUploadCoverJSONLToGCS(t *testing.T) {
{
name: "upload single object",
inputJSONL: "{}",
inputTime: time.Time{},
wantGCSFileName: "test-bucket/test-namespace/mgr-name-0001-01-01-0-0.jsonl",
wantGCSFileName: "test-bucket/test-namespace/mgr-name.jsonl",
wantGCSFileContent: "{}\n",
},
{
name: "upload single object, compress",
inputJSONL: "{}",
inputTime: time.Time{},
inputCompress: true,
wantGCSFileName: "test-bucket/test-namespace/mgr-name-0001-01-01-0-0.jsonl",
wantGCSFileName: "test-bucket/test-namespace/mgr-name.jsonl",
wantGCSFileContent: "{}\n",
wantCompressed: true,
},
{
name: "upload single object, publish",
inputJSONL: "{}",
inputTime: time.Time{},
inputPublish: true,
wantGCSFileName: "test-bucket/test-namespace/mgr-name-0001-01-01-0-0.jsonl",
wantGCSFileName: "test-bucket/test-namespace/mgr-name.jsonl",
wantGCSFileContent: "{}\n",
wantPublish: true,
},
{
name: "upload single object, unique name",
inputJSONL: "{}",
inputNameSuffix: "-suffix",
wantGCSFileName: "test-bucket/test-namespace/mgr-name-suffix.jsonl",
wantGCSFileContent: "{}\n",
},

{
name: "upload single object, error",
inputJSONL: "{",
inputTime: time.Time{},
wantGCSFileName: "test-bucket/test-namespace/mgr-name-0001-01-01-0-0.jsonl",
wantGCSFileName: "test-bucket/test-namespace/mgr-name.jsonl",
wantError: "callback: cover.ProgramCoverage: unexpected EOF",
},
}
Expand Down Expand Up @@ -200,7 +203,8 @@ func TestUploadCoverJSONLToGCS(t *testing.T) {
err := mgr.uploadCoverJSONLToGCS(gcsMock,
"/teststream&jsonl=1",
"gs://test-bucket",
time.Time{}, test.inputPublish, test.inputCompress, func(w io.Writer, dec *json.Decoder) error {
test.inputNameSuffix,
test.inputPublish, test.inputCompress, func(w io.Writer, dec *json.Decoder) error {
var v any
if err := dec.Decode(&v); err != nil {
return fmt.Errorf("cover.ProgramCoverage: %w", err)
Expand Down