tools: Begin adding the CTS command line tool

This CL introduces the Config structure, and config file.
Used by all the sub-commands.

Bug: dawn:1342
Change-Id: Iaad5a02bc2ceba2c63265cf0d1086dc7901e7ed7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88317
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Ben Clayton 2022-04-29 19:09:17 +00:00
parent e822f5e016
commit 846e3149b7
4 changed files with 150 additions and 0 deletions

1
go.mod
View File

@ -11,6 +11,7 @@ require (
github.com/mattn/go-isatty v0.0.14
github.com/sergi/go-diff v1.2.0
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/tidwall/jsonc v0.3.2
go.chromium.org/luci v0.0.0-20220412023008-ab2409fe739a
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b
google.golang.org/protobuf v1.28.0

2
go.sum
View File

@ -456,6 +456,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/texttheater/golang-levenshtein v1.0.1/go.mod h1:PYAKrbF5sAiq9wd+H82hs7gNaen0CplQ9uvm6+enD/8=
github.com/tidwall/jsonc v0.3.2 h1:ZTKrmejRlAJYdn0kcaFqRAKlxxFIC21pYq8vLa4p2Wc=
github.com/tidwall/jsonc v0.3.2/go.mod h1:dw+3CIxqHi+t8eFSpzzMlcVYxKp08UP5CD8/uSFCyJE=
github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=

View File

@ -0,0 +1,93 @@
// Copyright 2022 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package common
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"time"
"dawn.googlesource.com/dawn/tools/src/buildbucket"
"github.com/tidwall/jsonc"
)
// Config holds the configuration data for the 'cts' command.
// Config is loaded from a JSON file stored next to the
// tools/src/cmd/cts/config.json.
type Config struct {
// Test holds configuration data for test results.
Test struct {
// The ResultDB string prefix for CTS tests.
Prefix string
// The time threshold used to classify tests as slow.
SlowThreshold time.Duration
}
// Gerrit holds configuration for Dawn's Gerrit server.
Gerrit struct {
// The host URL
Host string
// The project name
Project string
}
// Git holds configuration data for the various Git repositories.
Git struct {
// The CTS git repository.
CTS GitProject
// The Dawn git repository.
Dawn GitProject
}
// Builders is a map of builder name (as displayed in the UI) to buildbucket
// builder information.
Builders map[string]buildbucket.Builder
// TagAliases is a list of tags which are treated as equivalent.
// For example, some GPUs are similar enough to be considered equivalent.
// See crbug.com/dawn/1387 for more information.
TagAliases [][]string
// Sheets holds information about the Google Sheets document used for
// tracking CTS statistics.
Sheets struct {
ID string
}
}
// GitProject holds a git host URL and project.
type GitProject struct {
Host string
Project string
}
// HttpsURL returns the https URL of the project
func (g GitProject) HttpsURL() string {
return fmt.Sprintf("https://%v/%v", g.Host, g.Project)
}
// LoadConfig loads the JSON config file at the given path
func LoadConfig(path string) (*Config, error) {
data, err := ioutil.ReadFile(path)
if err != nil {
return nil, fmt.Errorf("failed to open '%v': %w", path, err)
}
// Remove comments, trailing commas.
data = jsonc.ToJSONInPlace(data)
cfg := Config{}
if err := json.NewDecoder(bytes.NewReader(data)).Decode(&cfg); err != nil {
return nil, fmt.Errorf("failed to load config: %w", err)
}
return &cfg, nil
}

View File

@ -0,0 +1,54 @@
{
"Test": {
"Prefix": "ninja://chrome/test:telemetry_gpu_integration_test/gpu_tests.webgpu_cts_integration_test.WebGpuCtsIntegrationTest.",
"SlowThreshold": 15000000000 // 15 seconds
},
"Gerrit": {
"Host": "https://dawn-review.googlesource.com",
"Project": "dawn"
},
"Git": {
"CTS": {
"Host": "chromium.googlesource.com",
"Project": "external/github.com/gpuweb/cts"
},
"Dawn": {
"Host": "dawn.googlesource.com",
"Project": "dawn"
}
},
"Builders": {
"Win": {
"Project": "chromium",
"Bucket": "try",
"Builder": "win-dawn-rel"
},
"Win10-x86": {
"Project": "chromium",
"Bucket": "try",
"Builder": "dawn-try-win10-x86-rel"
},
"Mac": {
"Project": "chromium",
"Bucket": "try",
"Builder": "mac-dawn-rel"
},
"Linux": {
"Project": "chromium",
"Bucket": "try",
"Builder": "linux-dawn-rel"
}
},
"TagAliases": [
[
// crbug.com/dawn/1387
"intel-0x5912",
"intel-0x3e92"
]
],
"Sheets": {
// Spreadsheet to export results data to
// https://docs.google.com/spreadsheets/d/1OFsh-r_njG5pKDwjL1HOvLJKDRC4FgO-LE9Kw7WPQcc
"ID": "1OFsh-r_njG5pKDwjL1HOvLJKDRC4FgO-LE9Kw7WPQcc"
}
}