diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2025-07-25 12:54:53 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-07-29 09:54:26 +0000 |
| commit | b14118bbe9ad644f8e16279255fed61d399b96fa (patch) | |
| tree | 0e0dfc8640ca1f4018c2f155c2fd02d595d1c4f4 /syz-cluster/pkg/controller | |
| parent | 3b4ef3a2138bc14f4a6977174967afd6070c124c (diff) | |
syz-cluster: allow finding resubmission
Permit the following scenario: a finding is first submitted without a C
reproducer and then resubmitted again, now with one.
Ensure that it's only possible as long as the session is still in
progress.
Refactor Finding repository and service and adjust the tests.
Diffstat (limited to 'syz-cluster/pkg/controller')
| -rw-r--r-- | syz-cluster/pkg/controller/api_test.go | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/syz-cluster/pkg/controller/api_test.go b/syz-cluster/pkg/controller/api_test.go index 1c1c8de9f..e64f3bc78 100644 --- a/syz-cluster/pkg/controller/api_test.go +++ b/syz-cluster/pkg/controller/api_test.go @@ -10,7 +10,9 @@ import ( "github.com/google/syzkaller/syz-cluster/pkg/api" "github.com/google/syzkaller/syz-cluster/pkg/app" + "github.com/google/syzkaller/syz-cluster/pkg/db" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestAPIGetSeries(t *testing.T) { @@ -70,17 +72,52 @@ func TestAPISaveFinding(t *testing.T) { finding := &api.NewFinding{ SessionID: ids.SessionID, TestName: "test", + Title: "title", Report: []byte("report"), Log: []byte("log"), SyzRepro: []byte("syz repro"), SyzReproOpts: []byte("syz_repro_opts"), - CRepro: []byte("C repro"), } err = client.UploadFinding(ctx, finding) assert.NoError(t, err) - // Even if the finding is reported the second time, it must still not fail. + // Even if the same finding is reported the second time, it must still not fail. + err = client.UploadFinding(ctx, finding) + assert.NoError(t, err) + }) + + t.Run("add C repro", func(t *testing.T) { + finding := &api.NewFinding{ + SessionID: ids.SessionID, + TestName: "test", + Title: "title", + Report: []byte("report"), + Log: []byte("log"), + SyzRepro: []byte("syz repro"), + SyzReproOpts: []byte("syz_repro_opts"), + CRepro: []byte("C repro"), + } err = client.UploadFinding(ctx, finding) assert.NoError(t, err) + // Verify that C repro has appeared indeed. + findingRepo := db.NewFindingRepository(env.Spanner) + findings, err := findingRepo.ListForSession(ctx, ids.SessionID, db.NoLimit) + require.NoError(t, err) + require.Len(t, findings, 1) + assert.NotEmpty(t, findings[0].CReproURI) + }) + + t.Run("session stopped", func(t *testing.T) { + MarkSessionFinished(t, env, ids.SessionID) + finding := &api.NewFinding{ + SessionID: ids.SessionID, + TestName: "test", + Title: "new title", + Report: []byte("report"), + Log: []byte("log"), + SyzRepro: []byte("syz repro"), + } + err = client.UploadFinding(ctx, finding) + assert.ErrorContains(t, err, "session is already finished") }) } |
