From dcaedad707afbfb9d6f60cb1a0b7e5d02701f1b6 Mon Sep 17 00:00:00 2001 From: Loko Kung Date: Tue, 9 May 2023 12:26:47 +0000 Subject: [PATCH] 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 Commit-Queue: Ben Clayton Kokoro: Kokoro Reviewed-by: Ben Clayton --- tools/src/cmd/run-cts/main.go | 39 +++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/tools/src/cmd/run-cts/main.go b/tools/src/cmd/run-cts/main.go index d69a49ee7e..4762ea8be6 100644 --- a/tools/src/cmd/run-cts/main.go +++ b/tools/src/cmd/run-cts/main.go @@ -100,6 +100,31 @@ func (f *dawnNodeFlags) Set(value string) error { 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 { ctx, cancel := context.WithCancel(context.Background()) 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. - disableDawnFeaturesFound := false - 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") - } + flags.Set("enable-dawn-features=allow_unsafe_apis") if dumpShaders { - flags = append(flags, "enable-dawn-features=dump_shaders,disable_symbol_renaming") verbose = true + flags.Set("enable-dawn-features=dump_shaders,disable_symbol_renaming") } + flags.GlobListFlags("enable-dawn-features=", ",") r := runner{ query: query,