Repository navigation
Expand file tree
/
Copy pathfinalizer_test.go
More file actions
94 lines (89 loc) · 2.48 KB
/
Copy pathfinalizer_test.go
File metadata and controls
94 lines (89 loc) · 2.48 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
package main
import (
"bytes"
"os/exec"
"runtime"
"strings"
"testing"
"time"
"github.com/tinygo-org/tinygo/builder"
)
func TestBoehmFinalizerInterior(t *testing.T) {
t.Parallel()
for _, test := range []struct {
target, scheduler string
}{
{"wasm", "asyncify"},
{"wasm", "none"},
{"", "tasks"},
{"", "threads"},
{"", "none"},
} {
if test.target == "" && runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
continue
}
t.Run(test.target+"/"+test.scheduler, func(t *testing.T) {
t.Parallel()
options := optionsFromTarget(test.target, sema)
options.GC = "boehm"
options.Scheduler = test.scheduler
options.Tags = append(options.Tags, "runtime_asserts")
options.GlobalValues = map[string]map[string]string{
"main": {"finalizerTestMode": "interior"},
}
runTest("finalizer.go", options, t, nil, nil)
})
}
}
func TestBoehmFinalizerInteriorInvalid(t *testing.T) {
t.Parallel()
if runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
t.Skip("host finalizers need Linux or Darwin")
}
options := optionsFromTarget("", sema)
options.GC = "boehm"
config, err := builder.NewConfig(&options)
if err != nil {
t.Fatal(err)
}
for _, name := range []string{"interior-pointer", "interior-large"} {
t.Run(name, func(t *testing.T) {
output := &bytes.Buffer{}
_, err := buildAndRun("testdata/finalizer.go", config, output, []string{name}, nil, time.Minute, func(cmd *exec.Cmd, result builder.BuildResult) error {
cmd.Stdout = nil
cmd.Stderr = nil
data, err := cmd.CombinedOutput()
output.Write(data)
return err
})
if err == nil || !strings.Contains(output.String(), "pointer not at beginning of allocated block") {
t.Fatalf("interior registration result: %v\n%s", err, output.String())
}
})
}
}
func TestFinalizerRunnerRegistration(t *testing.T) {
t.Parallel()
for _, test := range []struct {
target, gc, scheduler string
}{
{"wasm", "boehm", "asyncify"},
{"wasm", "conservative", "asyncify"},
{"", "boehm", "tasks"},
{"", "boehm", "threads"},
} {
if test.target == "" && runtime.GOOS != "linux" && runtime.GOOS != "darwin" {
continue
}
t.Run(test.target+"/"+test.gc+"/"+test.scheduler, func(t *testing.T) {
t.Parallel()
options := optionsFromTarget(test.target, sema)
options.GC = test.gc
options.Scheduler = test.scheduler
options.GlobalValues = map[string]map[string]string{
"main": {"finalizerIdleMode": "registration"},
}
runTest("finalizeridle.go", options, t, nil, nil)
})
}
}