Repository navigation
Expand file tree
/
Copy pathbuild_test.go
More file actions
715 lines (665 loc) · 21 KB
/
Copy pathbuild_test.go
File metadata and controls
715 lines (665 loc) · 21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
package main
import (
"bytes"
"fmt"
"os/exec"
"regexp"
"runtime"
"slices"
"strings"
"testing"
"github.com/tinygo-org/tinygo/builder"
"github.com/tinygo-org/tinygo/compileopts"
"github.com/tinygo-org/tinygo/diagnostics"
"github.com/tinygo-org/tinygo/goenv"
)
func TestBuild(t *testing.T) {
t.Parallel()
tests := []string{
"alias.go",
"atomic.go",
"binop.go",
"buildinfo.go",
"calls.go",
"cgo/",
"channel.go",
"chanrecover.go",
"coreassign.go",
"embed/",
"finalizer.go",
"finalizerbits.go",
"finalizeridle.go",
"finalizerinvariants.go",
"finalizerlarge.go",
"float.go",
"gc.go",
"gcstacks.go",
"generics.go",
"go1.21.go",
"go1.22/",
"go1.23/",
"goroutines.go",
"init.go",
"init_multi.go",
"interface-blank.go",
"interface.go",
"json.go",
"localtypes/",
"localtypes.go",
"map.go",
"map_bigkey.go",
"math.go",
"oldgo/",
"print.go",
"promoted.go",
"reflect.go",
"signal.go",
"signalnotify.go",
"slice.go",
"sort.go",
"stdlib.go",
"string.go",
"stringfrombytes.go",
"stringfrombytes_stress.go",
"structs.go",
"testing.go",
"timers.go",
"typealias.go",
"zeroalloc.go",
}
if *testTarget != "" {
// This makes it possible to run one specific test (instead of all),
// which is especially useful to quickly check whether some changes
// affect a particular target architecture.
options := optionsFromTarget(*testTarget, sema)
runPlatTests(options, tests, t)
if *testTarget == "wasip1" {
t.Run("cgo-realloc", func(t *testing.T) {
runTest("cgo-realloc/", options, t, nil, nil)
})
}
return
}
t.Run("Host", func(t *testing.T) {
t.Parallel()
hostOptions := optionsFromTarget("", sema)
runPlatTests(hostOptions, tests, t)
for _, name := range gcStackNativeTests {
t.Run(name, func(t *testing.T) {
if runtime.GOOS == "windows" && (name == "gcstacks-stale.go" || name == "gcstacks-blocked.go") {
t.Skip("boehm scans whole goroutine stacks with the tasks scheduler")
}
t.Parallel()
runTest(name, hostOptions, t, nil, nil)
})
}
for _, skipped := range gcStackNativeSkipped {
t.Run(skipped.name, func(t *testing.T) {
t.Skip(skipped.reason)
})
}
t.Run("testing.go-verbose", func(t *testing.T) {
t.Parallel()
runTest("testing-verbose.go", hostOptions, t, nil, nil)
})
// scheduler.threads needs threadID, which exists only on Linux and Darwin.
// scheduler.none does not link on Windows.
switch runtime.GOOS {
case "darwin", "linux":
for _, scheduler := range []string{"threads", "none"} {
t.Run("finalizerinvariants.go-gc-conservative-scheduler-"+scheduler, func(t *testing.T) {
t.Parallel()
options := compileopts.Options(hostOptions)
options.GC = "conservative"
options.Scheduler = scheduler
options.Tags = append(append([]string(nil), hostOptions.Tags...), "runtime_asserts")
runTest("finalizerinvariants.go", options, t, nil, nil)
})
}
}
})
t.Run("boehm-finalizers", func(t *testing.T) {
t.Parallel()
options := optionsFromTarget("wasm", sema)
options.GC = "boehm"
t.Run("finalizerlarge.go-graph", func(t *testing.T) {
t.Parallel()
testOptions := compileopts.Options(options)
testOptions.GlobalValues = map[string]map[string]string{
"main": {"finalizerLargeMode": "graph"},
}
runTest("finalizerlarge.go", testOptions, t, nil, nil)
})
for _, name := range []string{
"finalizer.go",
"finalizerbits.go",
"finalizeridle.go",
"finalizerlarge.go",
"finalizerinvariants.go",
} {
name := name
t.Run(name, func(t *testing.T) {
t.Parallel()
testOptions := compileopts.Options(options)
if name == "finalizerlarge.go" {
testOptions.GlobalValues = map[string]map[string]string{
"main": {"finalizerLargeMode": "runner-payload"},
}
}
runTest(name, testOptions, t, nil, nil)
})
}
})
// Test a few build options.
t.Run("build-options", func(t *testing.T) {
t.Parallel()
// Test with few optimizations enabled (no inlining, etc).
t.Run("opt=1", func(t *testing.T) {
t.Parallel()
opts := optionsFromTarget("", sema)
opts.Opt = "1"
runTestWithConfig("stdlib.go", t, opts, nil, nil)
})
// Test with only the bare minimum of optimizations enabled.
// TODO: fix this for stdlib.go, which currently fails.
t.Run("opt=0", func(t *testing.T) {
t.Parallel()
opts := optionsFromTarget("", sema)
opts.Opt = "0"
runTestWithConfig("print.go", t, opts, nil, nil)
})
t.Run("opt=0-gc=boehm", func(t *testing.T) {
t.Parallel()
opts := optionsFromTarget("", sema)
opts.Opt = "0"
opts.GC = "boehm"
runTestWithConfig("gc-boehm-opt0.go", t, opts, nil, nil)
})
// Regression test: at -opt=0 the compiler does not always remove a
// local escaping through a pointer cast, so printitf used to
// allocate on the panic path. printitf is //go:noheap, so a
// regression here makes the build fail with a linker error.
t.Run("opt=0-printitf-cortex-m-qemu", func(t *testing.T) {
t.Parallel()
opts := optionsFromTarget("cortex-m-qemu", sema)
opts.Opt = "0"
config, err := builder.NewConfig(&opts)
if err != nil {
t.Fatal(err)
}
err = Build("testdata/panic-value.go", t.TempDir()+"/panic-value", config)
if err != nil {
w := &bytes.Buffer{}
diagnostics.CreateDiagnostics(err).WriteTo(w, "")
t.Fatal(w.String())
}
})
// Regression test: at -opt=0 the compiler does not always remove a
// local escaping through Queue.Push, so runGC used to allocate while
// marking the runqueue. runGC is //go:noheap, so a regression here
// makes the build fail with a linker error instead of silently
// hanging like it used to.
t.Run("opt=0-gc-cortex-m-qemu", func(t *testing.T) {
t.Parallel()
opts := optionsFromTarget("cortex-m-qemu", sema)
opts.Opt = "0"
emuCheck(t, opts)
runTestWithConfig("gc.go", t, opts, nil, nil)
})
t.Run("gc=none-runtime-panic", func(t *testing.T) {
t.Parallel()
opts := optionsFromTarget("cortex-m-qemu", sema)
opts.GC = "none"
opts.Scheduler = "none"
config, err := builder.NewConfig(&opts)
if err != nil {
t.Fatal(err)
}
err = Build("testdata/trivialpanic.go", t.TempDir()+"/trivialpanic", config)
if err != nil {
w := &bytes.Buffer{}
diagnostics.CreateDiagnostics(err).WriteTo(w, "")
t.Fatal(w.String())
}
})
t.Run("scheduler=none-uefi", func(t *testing.T) {
t.Parallel()
opts := optionsFromTarget("uefi-amd64", sema)
opts.Scheduler = "none"
config, err := builder.NewConfig(&opts)
if err != nil {
t.Fatal(err)
}
err = Build("testdata/trivialpanic.go", t.TempDir()+"/trivialpanic", config)
if err != nil {
w := &bytes.Buffer{}
diagnostics.CreateDiagnostics(err).WriteTo(w, "")
t.Fatal(w.String())
}
})
t.Run("ldflags", func(t *testing.T) {
t.Parallel()
opts := optionsFromTarget("", sema)
opts.GlobalValues = map[string]map[string]string{
"main": {
"someGlobal": "foobar",
},
}
runTestWithConfig("ldflags.go", t, opts, nil, nil)
})
// Same as ldflags, but the global has a default value in source.
// -ldflags -X must override it, matching standard Go behaviour.
t.Run("ldflags-initialized", func(t *testing.T) {
t.Parallel()
opts := optionsFromTarget("", sema)
opts.GlobalValues = map[string]map[string]string{
"main": {
"someGlobal": "foobar",
},
}
runTestWithConfig("ldflags-initialized.go", t, opts, nil, nil)
})
})
// Short mode skips the targets that every host can test. Linux CI tests
// them without -short.
if !testing.Short() {
t.Run("EmulatedCortexM3", func(t *testing.T) {
t.Parallel()
runPlatTests(optionsFromTarget("cortex-m-qemu", sema), tests, t)
})
t.Run("EmulatedRISCV", func(t *testing.T) {
t.Parallel()
for _, scheduler := range []string{"cores", "tasks"} {
t.Run(scheduler, func(t *testing.T) {
t.Parallel()
opts := optionsFromTarget("riscv-qemu", sema)
opts.Scheduler = scheduler
runPlatTests(opts, tests, t)
})
}
})
t.Run("AVR", func(t *testing.T) {
t.Parallel()
runPlatTests(optionsFromTarget("simavr", sema), tests, t)
})
t.Run("WebAssembly", func(t *testing.T) {
t.Parallel()
runPlatTests(optionsFromTarget("wasm", sema), tests, t)
runGCLivenessTest(optionsFromTarget("wasm", sema), t)
runGCStackTests(t, optionsFromTarget("wasm", sema))
t.Run("gcstacks-finalizer.go", func(t *testing.T) {
t.Parallel()
runTest("gcstacks-finalizer.go", optionsFromTarget("wasm", sema), t, nil, nil)
})
// Test with -gc=boehm.
t.Run("gc.go-boehm", func(t *testing.T) {
t.Parallel()
optionsBoehm := optionsFromTarget("wasm", sema)
optionsBoehm.GC = "boehm"
runTest("gc.go", optionsBoehm, t, nil, nil)
runTest("gc-boehm.go", optionsBoehm, t, nil, nil)
})
})
t.Run("WASIp1", func(t *testing.T) {
t.Parallel()
options := optionsFromTarget("wasip1", sema)
runPlatTests(options, tests, t)
runGCLivenessTest(options, t)
runGCStackTests(t, options)
runGCStackSizeTests(t, options)
t.Run("gcstacks-finalizer.go", func(t *testing.T) {
t.Skip("finalizers only run deterministically on the wasm target")
})
t.Run("cgo-realloc", func(t *testing.T) {
runTest("cgo-realloc/", options, t, nil, nil)
})
// Test that -gc=leaking reuses the stacks of exited goroutines.
t.Run("goroutines-leaking", func(t *testing.T) {
t.Parallel()
optionsLeaking := optionsFromTarget("wasip1", sema)
optionsLeaking.GC = "leaking"
runTest("goroutines-leaking.go", optionsLeaking, t, nil, nil)
})
// Test with -gc=boehm.
t.Run("gc.go-boehm", func(t *testing.T) {
t.Parallel()
optionsBoehm := optionsFromTarget("wasip1", sema)
optionsBoehm.GC = "boehm"
runTest("gc.go", optionsBoehm, t, nil, nil)
runTest("gc-boehm.go", optionsBoehm, t, nil, nil)
})
})
t.Run("WASIp2", func(t *testing.T) {
t.Parallel()
runPlatTests(optionsFromTarget("wasip2", sema), tests, t)
runGCLivenessTest(optionsFromTarget("wasip2", sema), t)
runGCStackTests(t, optionsFromTarget("wasip2", sema))
})
}
// Linux CI also tests the other Linux architectures without -short, so
// short mode skips them. Windows CI runs only in short mode, so
// Windows386 continues to run.
if runtime.GOOS == "linux" && !testing.Short() {
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("MIPS little-endian", func(t *testing.T) {
// Run a single test for GOARCH=mipsle to see whether it works at
// all. It is already mostly tested because GOARCH=mips and
// GOARCH=mipsle are so similar, but it's good to have an extra test
// to be sure.
t.Parallel()
options := optionsFromOSARCH("linux/mipsle/softfloat", sema)
emuCheck(t, options)
runTest("cgo/", options, t, nil, nil)
})
t.Run("glibc", func(t *testing.T) {
// Link against the system glibc, dynamically, instead of the
// musl that TinyGo builds. This needs the glibc development
// files (crt1.o, libc.so and the headers).
t.Parallel()
if _, err := compileopts.GlibcLibDir(runtime.GOARCH); err != nil {
t.Skip(err)
}
options := optionsFromTarget("", sema)
options.Libc = "glibc"
runTest("glibc/", options, t, nil, nil)
})
} else if runtime.GOOS == "windows" {
if runtime.GOARCH != "386" {
t.Run("Windows386", func(t *testing.T) {
t.Parallel()
runPlatTests(optionsFromOSARCH("windows/386", sema), tests, t)
})
}
}
}
func TestESP32QEMU(t *testing.T) {
t.Parallel()
options := optionsFromTarget("esp32-qemu", sema)
emuCheck(t, options)
machines, err := exec.Command("qemu-system-xtensa", "-machine", "help").Output()
if err != nil {
t.Fatal("failed to list qemu-system-xtensa machines:", err)
}
if !regexp.MustCompile(`(?m)^esp32\s`).Match(machines) {
t.Skip("qemu-system-xtensa does not support the ESP32 machine")
}
for _, name := range []string{"print.go", "recover.go"} {
t.Run(name, func(t *testing.T) {
t.Parallel()
runTest(name, options, t, nil, nil)
})
}
}
// gcStackNativeTests stress goroutine stacks and the GC. They run on the host
// and on the wasm targets. gcstacks.go is part of the main list of tests.
var gcStackNativeTests = []string{
"gcdiff.go",
"gcstacks-blocked.go",
"gcstacks-exit.go",
"gcstacks-panics.go",
"gcstacks-queues.go",
"gcstacks-stale.go",
}
// gcStackNativeSkipped are stack tests that do not work with the boehm GC and
// the schedulers the host uses.
var gcStackNativeSkipped = []struct{ name, reason string }{
{"gcstacks-soak.go", "the host does not free the stacks of leaked goroutines"},
{"gcstacks-scale.go", "collection time on the host depends on its scheduler"},
{"gcstacks-finalizer.go", "finalizers do not run with the boehm GC"},
}
// gcStackTests are the tests for the wasm targets, where leaked goroutines can
// be freed.
var gcStackTests = append(slices.Clone(gcStackNativeTests), "gcstacks-soak.go")
func runGCStackTests(t *testing.T, options compileopts.Options) {
t.Helper()
for _, name := range gcStackTests {
t.Run(name, func(t *testing.T) {
t.Parallel()
runTest(name, options, t, nil, nil)
})
}
// The collector must find the same live objects as one that never frees.
t.Run("gcdiff.go-leaking", func(t *testing.T) {
t.Parallel()
leaking := options
leaking.GC = "leaking"
runTest("gcdiff.go", leaking, t, nil, nil)
})
// This one measures time, so it does not run in parallel with the others.
t.Run("gcstacks-scale.go", func(t *testing.T) {
runTest("gcstacks-scale.go", options, t, nil, nil)
})
}
// runGCStackSizeTests runs the stack scanning test with goroutine stack sizes
// that are not multiples of the block size.
func runGCStackSizeTests(t *testing.T, options compileopts.Options) {
t.Helper()
for _, size := range []uint64{9001, 16393, 33333, 65545, 100003} {
t.Run(fmt.Sprintf("gcstacks.go-stack-size-%d", size), func(t *testing.T) {
t.Parallel()
sized := options
sized.StackSize = size
runTest("gcstacks.go", sized, t, nil, nil)
})
}
}
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)
}
scheduler := options.Scheduler
if scheduler == "" {
scheduler = spec.Scheduler
}
// FIXME: this should really be:
// isWebAssembly := strings.HasPrefix(spec.Triple, "wasm")
isWASI := strings.HasPrefix(options.Target, "wasi")
isWebAssembly := isWASI || strings.HasPrefix(options.Target, "wasm") || (options.Target == "" && strings.HasPrefix(options.GOARCH, "wasm"))
isBaremetal := options.Target == "simavr" || options.Target == "cortex-m-qemu" || options.Target == "riscv-qemu"
_, goMinor, err := goenv.GetGorootVersion()
if err != nil {
t.Fatal("could not get version:", goMinor)
}
for _, name := range tests {
if name == "goroutines.go" && (scheduler == "threads" || scheduler == "cores") {
// This test intentionally checks concurrent scheduling by comparing
// output order, so only run it with non-threaded schedulers.
continue
}
if name == "coreassign.go" && scheduler != "cores" {
// Core assignment needs the cores scheduler.
continue
}
if options.GOOS == "linux" && (options.GOARCH == "arm" || options.GOARCH == "386") {
switch name {
case "timers.go":
// Timer tests do not work because syscall.seek is implemented
// as Assembly in mainline Go and causes linker failure
continue
}
}
if options.GOOS == "linux" && (options.GOARCH == "mips" || options.GOARCH == "mipsle") {
if name == "atomic.go" || name == "timers.go" {
// 64-bit atomic operations aren't currently supported on MIPS.
continue
}
}
if options.GOOS == "linux" && options.GOARCH == "mips" {
if name == "cgo/" {
// CGo isn't supported yet on big-endian systems (needs updates
// to bitfield access methods).
continue
}
}
if options.Target == "cortex-m-qemu" && goMinor >= 27 && name == "json.go" {
// Go 1.27 jsonv2 exceeds the LM3S6965's 256KiB flash. json.go
// is still covered by larger targets such as riscv-qemu.
continue
}
if options.Target == "cortex-m-qemu" && name == "gcstacks.go" {
// Too many goroutines for the LM3S6965's RAM.
continue
}
if options.Target == "riscv-qemu" && name == "gcstacks.go" {
// The cores scheduler crashes with timers and runtime.GC, see #6047.
continue
}
if options.Target == "simavr" {
// Not all tests are currently supported on AVR.
// Skip the ones that aren't.
switch name {
case "reflect.go":
// Reflect tests do not run correctly, probably because of the
// limited amount of memory.
continue
case "stringfrombytes_stress.go":
// Needs more RAM than AVR has.
continue
case "map_bigkey.go":
// Compiler generates many large stack temporaries for [256]byte
// map keys, overflowing the goroutine stack (384 bytes).
continue
case "gc.go":
// Does not pass due to high mark false positive rate.
continue
case "chanrecover.go":
// runtime.GC in testdata/chanrecover.go crashes in the AVR stack scanner.
continue
case "gcstacks.go":
// Too many goroutines for the available RAM.
continue
case "buildinfo.go", "json.go", "stdlib.go", "testing.go":
// Too big for AVR. Doesn't fit in flash/RAM.
continue
case "cgo/":
// CGo function pointers don't work on AVR (needs LLVM 16 and
// some compiler changes).
continue
case "timers.go":
// Crashes starting with Go 1.23.
// Bug: https://github.com/llvm/llvm-project/issues/104032
continue
default:
}
}
if options.Target == "wasip2" {
switch name {
case "cgo/":
// waisp2 use our own libc; cgo tests fail
continue
}
}
if options.GOOS == "windows" {
switch name {
case "signal.go", "signalnotify.go":
// os/signal does not link on Windows.
continue
}
}
if isWebAssembly || isBaremetal {
switch name {
case "signal.go":
// Signals only work on POSIX-like systems.
continue
}
}
if options.Target != "wasm" {
switch name {
case "finalizer.go", "finalizerbits.go", "finalizeridle.go", "finalizerlarge.go":
// These tests require deterministic finalization on target wasm.
// finalizerinvariants.go covers other block GC targets.
continue
}
}
if options.Target == "simavr" {
switch name {
case "finalizerinvariants.go":
// Skip because runtime.GC does not return. See the gc.go exclusion above.
continue
}
}
name := name // redefine to avoid race condition
t.Run(name, func(t *testing.T) {
t.Parallel()
testOptions := compileopts.Options(options)
switch name {
case "chanrecover.go", "finalizerinvariants.go", "finalizerlarge.go", "interface.go", "interface-blank.go":
testOptions.Tags = append(append([]string(nil), options.Tags...), "runtime_asserts")
}
if testOptions.Target == "simavr" && (name == "math.go" || name == "string.go") {
// These tests exceed simavr's default 384-byte goroutine stack.
testOptions.StackSize = 512
}
runTest(name, testOptions, t, nil, nil)
})
}
if !strings.HasPrefix(spec.Emulator, "simavr ") {
t.Run("env.go", func(t *testing.T) {
t.Parallel()
runTest("env.go", options, t, []string{"first", "second"}, []string{"ENV1=VALUE1", "ENV2=VALUE2"})
})
}
if isWebAssembly {
t.Run("alias.go-scheduler-none", func(t *testing.T) {
t.Parallel()
options := compileopts.Options(options)
options.Scheduler = "none"
runTest("alias.go", options, t, nil, nil)
})
}
if options.Target == "" || isWASI {
t.Run("filesystem.go", func(t *testing.T) {
t.Parallel()
runTest("filesystem.go", options, t, nil, nil)
})
}
if options.Target == "wasm" || isBaremetal {
t.Run("devnull.go", func(t *testing.T) {
t.Parallel()
runTest("devnull.go", options, t, nil, nil)
})
}
if options.Target == "" || options.Target == "wasm" || isWASI {
t.Run("rand.go", func(t *testing.T) {
t.Parallel()
runTest("rand.go", options, t, nil, nil)
})
}
t.Run("recover.go", func(t *testing.T) {
t.Parallel()
runTest("recover.go", options, t, nil, nil)
})
if isWebAssembly {
t.Run("recover-explicit.go", func(t *testing.T) {
t.Parallel()
options := compileopts.Options(options)
options.Scheduler = "none"
options.PanicUnwind = "explicit"
runTest("recover-explicit.go", options, t, nil, nil)
})
t.Run("calls.go-unwind-none", func(t *testing.T) {
t.Parallel()
options := compileopts.Options(options)
options.PanicUnwind = "none"
runTest("calls.go", options, t, nil, nil)
})
}
}
// runGCLivenessTest runs testdata/gc-liveness-repro.go. Only targets with
// stack objects can lose a GC root the way it reproduces, so it is registered
// per wasm target instead of being part of the shared test list.
func runGCLivenessTest(options compileopts.Options, t *testing.T) {
t.Run("gc-liveness-repro.go", func(t *testing.T) {
t.Parallel()
runTest("gc-liveness-repro.go", options, t, nil, nil)
})
}