Updates CTS tooling to use new 'allow-unsafe-apis' toggle.

Bug: dawn:1685
Change-Id: Ie5dc18dfff51c6e116dd5c4ea322a41fb249ca37
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131584
Auto-Submit: Loko Kung <lokokung@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Loko Kung 2023-05-09 12:26:47 +00:00 committed by Dawn LUCI CQ
parent 13ca70fa08
commit dcaedad707
1 changed files with 28 additions and 11 deletions

View File

@ -100,6 +100,31 @@ func (f *dawnNodeFlags) Set(value string) error {
return nil return nil
} }
// Consolidates all the delimiter separated flags with a given prefix into a single flag.
// Example:
// Given the flags: ["foo=a", "bar", "foo=b,c"]
// GlobListFlags("foo=", ",") will transform the flags to: ["bar", "foo=a,b,c"]
func (f *dawnNodeFlags) GlobListFlags(prefix string, delimiter string) {
list := []string{}
i := 0
for _, flag := range *f {
if strings.HasPrefix(flag, prefix) {
// Trim the prefix.
value := flag[len(prefix):]
// Extract the deliminated values.
list = append(list, strings.Split(value, delimiter)...)
} else {
(*f)[i] = flag
i++
}
}
(*f) = (*f)[:i]
if len(list) > 0 {
// Append back the consolidated flags.
f.Set(prefix + strings.Join(list, delimiter))
}
}
func makeCtx() context.Context { func makeCtx() context.Context {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
sigs := make(chan os.Signal, 1) sigs := make(chan os.Signal, 1)
@ -223,20 +248,12 @@ func run() error {
} }
// While running the CTS, always allow unsafe APIs so they can be tested. // While running the CTS, always allow unsafe APIs so they can be tested.
disableDawnFeaturesFound := false flags.Set("enable-dawn-features=allow_unsafe_apis")
for i, flag := range flags {
if strings.HasPrefix(flag, "disable-dawn-features=") {
flags[i] = flag + ",disallow_unsafe_apis"
disableDawnFeaturesFound = true
}
}
if !disableDawnFeaturesFound {
flags = append(flags, "disable-dawn-features=disallow_unsafe_apis")
}
if dumpShaders { if dumpShaders {
flags = append(flags, "enable-dawn-features=dump_shaders,disable_symbol_renaming")
verbose = true verbose = true
flags.Set("enable-dawn-features=dump_shaders,disable_symbol_renaming")
} }
flags.GlobListFlags("enable-dawn-features=", ",")
r := runner{ r := runner{
query: query, query: query,