From a94e03eff26792effe80ec3accb8c251d165681e Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 4 May 2022 22:15:26 +0200 Subject: [PATCH] avr: get `go test -target=simavr` to work This patch changes two things: 1. It changes the default stack size. Without this change, the goroutine.go test doesn't pass (apparently there's some memory corruption). 2. It moves the excluded tests so that they are skipped with a regular `-target=simavr`, not just when running all tests (without `-target`). --- main_test.go | 89 +++++++++++++++++++++++++-------------------- targets/simavr.json | 2 +- 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/main_test.go b/main_test.go index 3b088ada..6139b74b 100644 --- a/main_test.go +++ b/main_test.go @@ -146,46 +146,7 @@ func TestBuild(t *testing.T) { // LIBCLANG FATAL ERROR: Cannot select: t3: i16 = JumpTable<0> // This bug is non-deterministic. t.Skip("skipped due to non-deterministic backend bugs") - - var avrTests []string - for _, t := range tests { - switch t { - case "atomic.go": - // Requires GCC 11.2.0 or above for interface comparison. - // https://github.com/gcc-mirror/gcc/commit/f30dd607669212de135dec1f1d8a93b8954c327c - - case "reflect.go": - // Reflect tests do not work due to type code issues. - - case "gc.go": - // Does not pass due to high mark false positive rate. - - case "json.go", "stdlib.go", "testing.go": - // Breaks interp. - - case "map.go": - // Reflect size calculation crashes. - - case "binop.go": - // Interface comparison results are inverted. - - case "channel.go": - // Freezes after recv from closed channel. - - case "float.go", "math.go", "print.go": - // Stuck in runtime.printfloat64. - - case "interface.go": - // Several comparison tests fail. - - case "cgo/": - // CGo does not work on AVR. - - default: - avrTests = append(avrTests, t) - } - } - runPlatTests(optionsFromTarget("simavr", sema), avrTests, t) + runPlatTests(optionsFromTarget("simavr", sema), tests, t) }) if runtime.GOOS == "linux" { @@ -217,6 +178,54 @@ func runPlatTests(options compileopts.Options, tests []string, t *testing.T) { } for _, name := range tests { + if options.Target == "simavr" { + // Not all tests are currently supported on AVR. + // Skip the ones that aren't. + switch name { + case "atomic.go": + // Requires GCC 11.2.0 or above for interface comparison. + // https://github.com/gcc-mirror/gcc/commit/f30dd607669212de135dec1f1d8a93b8954c327c + continue + + case "reflect.go": + // Reflect tests do not work due to type code issues. + continue + + case "gc.go": + // Does not pass due to high mark false positive rate. + continue + + case "json.go", "stdlib.go", "testing.go", "testing_go118.go": + // Breaks interp. + continue + + case "map.go": + // Reflect size calculation crashes. + continue + + case "binop.go": + // Interface comparison results are inverted. + continue + + case "channel.go": + // Freezes after recv from closed channel. + continue + + case "float.go", "math.go", "print.go": + // Stuck in runtime.printfloat64. + continue + + case "interface.go": + // Several comparison tests fail. + continue + + case "cgo/": + // CGo does not work on AVR. + continue + + default: + } + } name := name // redefine to avoid race condition t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/targets/simavr.json b/targets/simavr.json index de40d524..012f2d94 100644 --- a/targets/simavr.json +++ b/targets/simavr.json @@ -1,5 +1,5 @@ { "inherits": ["atmega1284p"], "scheduler": "tasks", - "default-stack-size": 512 + "default-stack-size": 384 }