dawn_node: make server mode output stdout of each test in verbose mode

This change also makes sure that all three modes (serial, isolated
parallel, and server) all output stdout of tests only if verbose mode is
enabled.

Bug: dawn:1163
Change-Id: I9e9efcfa4b73571adac15179d2792fb745255fb8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/68182
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Antonio Maiorano 2021-11-02 20:24:09 +00:00 committed by Dawn LUCI CQ
parent 3f1fb34479
commit 0a873d8eb1
2 changed files with 31 additions and 21 deletions

View File

@ -68,10 +68,10 @@ The `--flag` parameter must be passed in multiple times, once for each flag begi
For example, on Windows, to use the d3dcompiler_47.dll from a Chromium checkout, and to dump shader output, we could run the following using Git Bash: For example, on Windows, to use the d3dcompiler_47.dll from a Chromium checkout, and to dump shader output, we could run the following using Git Bash:
```sh ```sh
./src/dawn_node/tools/run-cts --j=0 --dawn-node=/c/src/dawn/build/Debug/dawn.node --cts=/c/src/gpuweb-cts --flag=dlldir="C:\src\chromium\src\out\Release" --flag=enable-dawn-features=dump_shaders 'webgpu:shader,execution,builtin,abs:integer_builtin_functions,abs_unsigned:storageClass="storage";storageMode="read_write";containerType="vector";isAtomic=false;baseType="u32";type="vec2%3Cu32%3E"' ./src/dawn_node/tools/run-cts --verbose --dawn-node=/c/src/dawn/build/Debug/dawn.node --cts=/c/src/gpuweb-cts --flag=dlldir="C:\src\chromium\src\out\Release" --flag=enable-dawn-features=dump_shaders 'webgpu:shader,execution,builtin,abs:integer_builtin_functions,abs_unsigned:storageClass="storage";storageMode="read_write";containerType="vector";isAtomic=false;baseType="u32";type="vec2%3Cu32%3E"'
``` ```
Note that we pass `--j=0` above so that all output, including the dumped shader, is written to stdout. Note that we pass `--verbose` above so that all test output, including the dumped shader, is written to stdout.
## Known issues ## Known issues
- Many WebGPU CTS tests are currently known to fail - Many WebGPU CTS tests are currently known to fail

View File

@ -220,10 +220,13 @@ func run() error {
return fmt.Errorf("failed to gather test cases: %w", err) return fmt.Errorf("failed to gather test cases: %w", err)
} }
fmt.Printf("Testing %d test cases...\n", len(r.testcases))
if isolated { if isolated {
fmt.Println("Running in parallel isolated...")
fmt.Printf("Testing %d test cases...\n", len(r.testcases))
return r.runParallelIsolated() return r.runParallelIsolated()
} }
fmt.Println("Running in parallel with server...")
fmt.Printf("Testing %d test cases...\n", len(r.testcases))
return r.runParallelWithServer() return r.runParallelWithServer()
} }
@ -439,6 +442,10 @@ func (r *runner) runParallelWithServer() error {
return nil return nil
} }
type redirectingWriter struct {
io.Writer
}
// runServer starts a test runner server instance, takes case indices from // runServer starts a test runner server instance, takes case indices from
// caseIndices, and requests the server run the test with the given index. // caseIndices, and requests the server run the test with the given index.
// The result of the test run is written to the results chan. // The result of the test run is written to the results chan.
@ -446,6 +453,7 @@ func (r *runner) runParallelWithServer() error {
// runServer returns. // runServer returns.
func (r *runner) runServer(caseIndices <-chan int, results chan<- result) error { func (r *runner) runServer(caseIndices <-chan int, results chan<- result) error {
var port int var port int
var rw redirectingWriter
stopServer := func() {} stopServer := func() {}
startServer := func() error { startServer := func() error {
@ -470,12 +478,12 @@ func (r *runner) runServer(caseIndices <-chan int, results chan<- result) error
pl := newPortListener() pl := newPortListener()
cmd.Dir = r.cts cmd.Dir = r.cts
cmd.Stdout = io.MultiWriter(serverLog, &pl) cmd.Stdout = io.MultiWriter(&rw, serverLog, &pl)
cmd.Stderr = serverLog cmd.Stderr = io.MultiWriter(&rw, serverLog)
err := cmd.Start() err := cmd.Start()
if err != nil { if err != nil {
return fmt.Errorf("failed to start test runner server:", err) return fmt.Errorf("failed to start test runner server: %v", err)
} }
select { select {
@ -495,6 +503,10 @@ func (r *runner) runServer(caseIndices <-chan int, results chan<- result) error
} }
for idx := range caseIndices { for idx := range caseIndices {
// Redirect the server log per test case
caseServerLog := &bytes.Buffer{}
rw.Writer = caseServerLog
if port == 0 { if port == 0 {
if err := startServer(); err != nil { if err := startServer(); err != nil {
return err return err
@ -528,16 +540,16 @@ func (r *runner) runServer(caseIndices <-chan int, results chan<- result) error
switch resp.Status { switch resp.Status {
case "pass": case "pass":
res.status = pass res.status = pass
res.message = resp.Message res.message = resp.Message + caseServerLog.String()
case "warn": case "warn":
res.status = warn res.status = warn
res.message = resp.Message res.message = resp.Message + caseServerLog.String()
case "fail": case "fail":
res.status = fail res.status = fail
res.message = resp.Message res.message = resp.Message + caseServerLog.String()
case "skip": case "skip":
res.status = skip res.status = skip
res.message = resp.Message res.message = resp.Message + caseServerLog.String()
default: default:
res.status = fail res.status = fail
res.error = fmt.Errorf("unknown status: '%v'", resp.Status) res.error = fmt.Errorf("unknown status: '%v'", resp.Status)
@ -581,7 +593,7 @@ func (r *runner) runParallelIsolated() error {
go func() { go func() {
defer wg.Done() defer wg.Done()
for idx := range caseIndices { for idx := range caseIndices {
res := r.runTestcase(r.testcases[idx], false) res := r.runTestcase(r.testcases[idx])
res.index = idx res.index = idx
results <- res results <- res
} }
@ -667,11 +679,14 @@ timeout: %v (%v)
// process. // process.
func (r *runner) runSerially(query string) error { func (r *runner) runSerially(query string) error {
start := time.Now() start := time.Now()
result := r.runTestcase(query, true) result := r.runTestcase(query)
timeTaken := time.Since(start) timeTaken := time.Since(start)
fmt.Println("Completed in", timeTaken) if r.verbose {
fmt.Println(result) fmt.Println(result)
}
fmt.Println("Status:", result.status)
fmt.Println("Completed in", timeTaken)
return nil return nil
} }
@ -697,7 +712,7 @@ type result struct {
// runTestcase() runs the CTS testcase with the given query, returning the test // runTestcase() runs the CTS testcase with the given query, returning the test
// result. // result.
func (r *runner) runTestcase(query string, printToStout bool) result { func (r *runner) runTestcase(query string) result {
ctx, cancel := context.WithTimeout(context.Background(), testTimeout) ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
defer cancel() defer cancel()
@ -721,13 +736,8 @@ func (r *runner) runTestcase(query string, printToStout bool) result {
cmd.Dir = r.cts cmd.Dir = r.cts
var buf bytes.Buffer var buf bytes.Buffer
if printToStout {
cmd.Stdout = io.MultiWriter(&buf, os.Stdout)
cmd.Stderr = io.MultiWriter(&buf, os.Stderr)
} else {
cmd.Stdout = &buf cmd.Stdout = &buf
cmd.Stderr = &buf cmd.Stderr = &buf
}
err := cmd.Run() err := cmd.Run()
msg := buf.String() msg := buf.String()