diff options
| author | Taras Madan <tarasmadan@google.com> | 2024-07-26 13:33:42 +0200 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2024-07-26 11:55:49 +0000 |
| commit | 389c3e9cea0e1f2b34d475e858942ae9c6f12e05 (patch) | |
| tree | d7dacbe33f60e68113ce585768c9f03a5c83d2f8 | |
| parent | 2b4812a472dc793e954fa71a1b61773a428bdf88 (diff) | |
all: make coverage-merger client name configurable
| -rw-r--r-- | dashboard/app/config.go | 3 | ||||
| -rw-r--r-- | dashboard/app/coverage_batch.go | 11 | ||||
| -rwxr-xr-x | tools/syz-bq.sh | 4 | ||||
| -rw-r--r-- | tools/syz-covermerger/syz_covermerger.go | 23 |
4 files changed, 27 insertions, 14 deletions
diff --git a/dashboard/app/config.go b/dashboard/app/config.go index 5f4461f91..c19ae8040 100644 --- a/dashboard/app/config.go +++ b/dashboard/app/config.go @@ -125,12 +125,15 @@ type Config struct { Coverage *CoverageConfig } +const defaultDashboardClientName = "coverage-merger" + type CoverageConfig struct { BatchProject string BatchServiceAccount string BatchScopes []string JobInitScript string SyzEnvInitScript string + DashboardClientName string } // DiscussionEmailConfig defines the correspondence between an email and a DiscussionSource. diff --git a/dashboard/app/coverage_batch.go b/dashboard/app/coverage_batch.go index 8a88efa80..1e4b59d0f 100644 --- a/dashboard/app/coverage_batch.go +++ b/dashboard/app/coverage_batch.go @@ -55,7 +55,10 @@ func handleBatchCoverage(w http.ResponseWriter, r *http.Request) { ctx, nsCovConfig.BatchProject, nsCovConfig.BatchServiceAccount, - batchScript(ns, repo, branch, 7, dates, nsCovConfig.JobInitScript, nsCovConfig.SyzEnvInitScript), + batchScript(ns, repo, branch, 7, dates, + nsCovConfig.JobInitScript, + nsCovConfig.SyzEnvInitScript, + nsCovConfig.DashboardClientName), nsCovConfig.BatchScopes); err != nil { log.Errorf(ctx, "failed to batchScript: %s", err.Error()) } @@ -63,7 +66,10 @@ func handleBatchCoverage(w http.ResponseWriter, r *http.Request) { } func batchScript(ns, repo, branch string, days int, datesTo []civil.Date, - jobInitScript, syzEnvInitScript string) string { + jobInitScript, syzEnvInitScript, clientName string) string { + if clientName == "" { + clientName = defaultDashboardClientName + } script := jobInitScript + "\n" script += "git clone --depth 1 --branch master --single-branch https://github.com/google/syzkaller\n" + "cd syzkaller\n" + @@ -80,6 +86,7 @@ func batchScript(ns, repo, branch string, days int, datesTo []civil.Date, " -b " + branch + " -d " + strconv.Itoa(days) + " -t " + dateTo.String() + + " -c " + clientName + " 2>&1; " // we don't want stderr output to be logged as errors } script += "\"" diff --git a/tools/syz-bq.sh b/tools/syz-bq.sh index cc45be917..f15de82cf 100755 --- a/tools/syz-bq.sh +++ b/tools/syz-bq.sh @@ -5,7 +5,7 @@ set -e # exit on any problem set -o pipefail -while getopts w:d:t:n:r:b: option +while getopts w:d:t:n:r:b:c: option do case "${option}" in @@ -15,6 +15,7 @@ do n)namespace=${OPTARG};; r)repo=${OPTARG};; b)branch=${OPTARG};; + c)client_name=${OPTARG};; esac done @@ -128,6 +129,7 @@ go run ./tools/syz-covermerger/ -workdir $workdir \ -branch $branch \ -commit $base_commit \ -to-dashapi https://syzkaller.appspot.com \ + -dashboard-client-name $client_name \ -namespace $namespace \ -duration $duration \ -date-to $to_date \ diff --git a/tools/syz-covermerger/syz_covermerger.go b/tools/syz-covermerger/syz_covermerger.go index b2d10cc1e..2f2d820a7 100644 --- a/tools/syz-covermerger/syz_covermerger.go +++ b/tools/syz-covermerger/syz_covermerger.go @@ -22,14 +22,15 @@ import ( var ( flagWorkdir = flag.String("workdir", "workdir-cover-aggregation", "[optional] used to clone repos") - flagRepo = flag.String("repo", "", "[required] repo to be used as an aggregation point") - flagBranch = flag.String("branch", "", "[required] branch to be used as an aggregation point") - flagCommit = flag.String("commit", "", "[required] commit hash to be used as an aggregation point") - flagNamespace = flag.String("namespace", "upstream", "[optional] target namespace") - flagDuration = flag.Int64("duration", 0, "[optional] used to mark DB records") - flagDateTo = flag.String("date-to", "", "[optional] used to mark DB records") - flagTotalRows = flag.Int64("total-rows", 0, "[optional] source size, is used for version contol") - flagToDashAPI = flag.String("to-dashapi", "", "[optional] dashapi address") + flagRepo = flag.String("repo", "", "[required] repo to be used as an aggregation point") + flagBranch = flag.String("branch", "", "[required] branch to be used as an aggregation point") + flagCommit = flag.String("commit", "", "[required] commit hash to be used as an aggregation point") + flagNamespace = flag.String("namespace", "upstream", "[optional] target namespace") + flagDuration = flag.Int64("duration", 0, "[optional] used to mark DB records") + flagDateTo = flag.String("date-to", "", "[optional] used to mark DB records") + flagTotalRows = flag.Int64("total-rows", 0, "[optional] source size, is used for version contol") + flagToDashAPI = flag.String("to-dashapi", "", "[optional] dashapi address") + flagDashboardClientName = flag.String("dashboard-client-name", "coverage-merger", "[optional]") ) func main() { @@ -55,7 +56,7 @@ func main() { } coverage, _, _ := mergeResultsToCoverage(mergeResult) if *flagToDashAPI != "" { - if err := saveCoverage(*flagToDashAPI, &dashapi.MergedCoverage{ + if err := saveCoverage(*flagToDashAPI, *flagDashboardClientName, &dashapi.MergedCoverage{ Namespace: *flagNamespace, Repo: *flagRepo, Commit: *flagCommit, @@ -69,8 +70,8 @@ func main() { } } -func saveCoverage(dashboard string, d *dashapi.MergedCoverage) error { - dash, err := dashapi.New("coverage-merger", dashboard, "") +func saveCoverage(dashboard, clientName string, d *dashapi.MergedCoverage) error { + dash, err := dashapi.New(clientName, dashboard, "") if err != nil { log.Panicf("failed dashapi.New(): %v", err) } |
