test-runner: Add support for GLSL

This is not included in the default for 'filter' as it is far from ready.
Also: Don't generate SKIPs in the excluded directories.

Change-Id: I02cb40c1bf8adebc77e9e5102988dd41e4b1f7a1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/68522
Kokoro: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Ben Clayton 2021-11-05 22:45:23 +00:00
parent 51aed1c732
commit e9c6a64147
1 changed files with 18 additions and 19 deletions

View File

@ -41,10 +41,11 @@ type outputFormat string
const ( const (
testTimeout = 30 * time.Second testTimeout = 30 * time.Second
wgsl = outputFormat("wgsl") glsl = outputFormat("glsl")
spvasm = outputFormat("spvasm")
msl = outputFormat("msl")
hlsl = outputFormat("hlsl") hlsl = outputFormat("hlsl")
msl = outputFormat("msl")
spvasm = outputFormat("spvasm")
wgsl = outputFormat("wgsl")
) )
func main() { func main() {
@ -75,7 +76,7 @@ func run() error {
var maxFilenameColumnWidth int var maxFilenameColumnWidth int
numCPU := runtime.NumCPU() numCPU := runtime.NumCPU()
fxc, verbose, generateExpected, generateSkip := false, false, false, false fxc, verbose, generateExpected, generateSkip := false, false, false, false
flag.StringVar(&formatList, "format", "all", "comma separated list of formats to emit. Possible values are: all, wgsl, spvasm, msl, hlsl") flag.StringVar(&formatList, "format", "wgsl,spvasm,msl,hlsl", "comma separated list of formats to emit. Possible values are: all, wgsl, spvasm, msl, hlsl, glsl")
flag.StringVar(&filter, "filter", "**.wgsl, **.spvasm, **.spv", "comma separated list of glob patterns for test files") flag.StringVar(&filter, "filter", "**.wgsl, **.spvasm, **.spv", "comma separated list of glob patterns for test files")
flag.StringVar(&dxcPath, "dxc", "", "path to DXC executable for validating HLSL output") flag.StringVar(&dxcPath, "dxc", "", "path to DXC executable for validating HLSL output")
flag.StringVar(&xcrunPath, "xcrun", "", "path to xcrun executable for validating MSL output") flag.StringVar(&xcrunPath, "xcrun", "", "path to xcrun executable for validating MSL output")
@ -147,7 +148,7 @@ func run() error {
// Parse --format into a list of outputFormat // Parse --format into a list of outputFormat
formats := []outputFormat{} formats := []outputFormat{}
if formatList == "all" { if formatList == "all" {
formats = []outputFormat{wgsl, spvasm, msl, hlsl} formats = []outputFormat{wgsl, spvasm, msl, hlsl, glsl}
} else { } else {
for _, f := range strings.Split(formatList, ",") { for _, f := range strings.Split(formatList, ",") {
switch strings.TrimSpace(f) { switch strings.TrimSpace(f) {
@ -159,6 +160,8 @@ func run() error {
formats = append(formats, msl) formats = append(formats, msl)
case "hlsl": case "hlsl":
formats = append(formats, hlsl) formats = append(formats, hlsl)
case "glsl":
formats = append(formats, glsl)
default: default:
return fmt.Errorf("unknown format '%s'", f) return fmt.Errorf("unknown format '%s'", f)
} }
@ -510,8 +513,8 @@ func (j job) run(wd, exe string, fxc bool, dxcPath, xcrunPath string, generateEx
switch j.format { switch j.format {
case wgsl: case wgsl:
validate = true validate = true
case spvasm: case spvasm, glsl:
args = append(args, "--validate") // spirv-val is statically linked, always available args = append(args, "--validate") // spirv-val and glslang are statically linked, always available
validate = true validate = true
case hlsl: case hlsl:
if fxc { if fxc {
@ -539,18 +542,7 @@ func (j job) run(wd, exe string, fxc bool, dxcPath, xcrunPath string, generateEx
matched := expected == "" || expected == out matched := expected == "" || expected == out
if ok && generateExpected && (validate || !skipped) { if ok && generateExpected && (validate || !skipped) {
// Don't generate expected results for certain directories that contain saveExpectedFile(j.file, j.format, out)
// large corpora of tests for which the generated code is uninteresting.
saveResult := true
for _, exclude := range []string{"/test/unittest/", "/test/vk-gl-cts/"} {
if strings.Contains(j.file, exclude) {
saveResult = false
}
}
if saveResult {
saveExpectedFile(j.file, j.format, out)
}
matched = true matched = true
} }
@ -620,6 +612,13 @@ func loadExpectedFile(path string, format outputFormat) string {
// saveExpectedFile writes the expected output file for the test file at 'path' // saveExpectedFile writes the expected output file for the test file at 'path'
// and the output format 'format', with the content 'content'. // and the output format 'format', with the content 'content'.
func saveExpectedFile(path string, format outputFormat, content string) error { func saveExpectedFile(path string, format outputFormat, content string) error {
// Don't generate expected results for certain directories that contain
// large corpora of tests for which the generated code is uninteresting.
for _, exclude := range []string{"/test/unittest/", "/test/vk-gl-cts/"} {
if strings.Contains(path, exclude) {
return nil
}
}
return ioutil.WriteFile(expectedFilePath(path, format), []byte(content), 0666) return ioutil.WriteFile(expectedFilePath(path, format), []byte(content), 0666)
} }