aboutsummaryrefslogtreecommitdiffhomepage
path: root/main_test.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2022-05-04 22:15:26 +0200
committerRon Evans <[email protected]>2022-05-18 15:20:09 +0200
commita94e03eff26792effe80ec3accb8c251d165681e (patch)
tree6ee461199eaaacec5abaa6e4d072f89d74fc7d79 /main_test.go
parenteb3d6261b4a496824d18b0394c11830e4f789ec5 (diff)
downloadtinygo-a94e03eff26792effe80ec3accb8c251d165681e.tar.gz
tinygo-a94e03eff26792effe80ec3accb8c251d165681e.zip
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`).
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go83
1 files changed, 46 insertions, 37 deletions
diff --git a/main_test.go b/main_test.go
index 3b088ada8..6139b74b7 100644
--- a/main_test.go
+++ b/main_test.go
@@ -146,77 +146,86 @@ 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")
+ runPlatTests(optionsFromTarget("simavr", sema), tests, t)
+ })
- var avrTests []string
- for _, t := range tests {
- switch t {
+ if runtime.GOOS == "linux" {
+ for name, osArch := range supportedLinuxArches {
+ options := optionsFromOSARCH(osArch, sema)
+ if options.GOARCH != runtime.GOARCH { // Native architecture already run above.
+ t.Run(name, func(t *testing.T) {
+ runPlatTests(options, tests, t)
+ })
+ }
+ }
+ t.Run("WebAssembly", func(t *testing.T) {
+ t.Parallel()
+ runPlatTests(optionsFromTarget("wasm", sema), tests, t)
+ })
+ t.Run("WASI", func(t *testing.T) {
+ t.Parallel()
+ runPlatTests(optionsFromTarget("wasi", sema), tests, t)
+ })
+ }
+}
+
+func runPlatTests(options compileopts.Options, tests []string, t *testing.T) {
+ emuCheck(t, options)
+
+ spec, err := compileopts.LoadTarget(&options)
+ if err != nil {
+ t.Fatal("failed to load target spec:", err)
+ }
+
+ 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":
+ 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:
- avrTests = append(avrTests, t)
}
}
- runPlatTests(optionsFromTarget("simavr", sema), avrTests, t)
- })
-
- if runtime.GOOS == "linux" {
- for name, osArch := range supportedLinuxArches {
- options := optionsFromOSARCH(osArch, sema)
- if options.GOARCH != runtime.GOARCH { // Native architecture already run above.
- t.Run(name, func(t *testing.T) {
- runPlatTests(options, tests, t)
- })
- }
- }
- t.Run("WebAssembly", func(t *testing.T) {
- t.Parallel()
- runPlatTests(optionsFromTarget("wasm", sema), tests, t)
- })
- t.Run("WASI", func(t *testing.T) {
- t.Parallel()
- runPlatTests(optionsFromTarget("wasi", sema), tests, t)
- })
- }
-}
-
-func runPlatTests(options compileopts.Options, tests []string, t *testing.T) {
- emuCheck(t, options)
-
- spec, err := compileopts.LoadTarget(&options)
- if err != nil {
- t.Fatal("failed to load target spec:", err)
- }
-
- for _, name := range tests {
name := name // redefine to avoid race condition
t.Run(name, func(t *testing.T) {
t.Parallel()