...
1 package wazero_test
2
3 import (
4 "context"
5 _ "embed"
6 "log"
7
8 "github.com/tetratelabs/wazero"
9 "github.com/tetratelabs/wazero/api"
10 )
11
12
13 func Example_runtimeConfig_WithCustomSections() {
14 ctx := context.Background()
15 config := wazero.NewRuntimeConfig().WithCustomSections(true)
16
17 r := wazero.NewRuntimeWithConfig(ctx, config)
18 defer r.Close(ctx)
19
20 m, err := r.CompileModule(ctx, addWasm)
21 if err != nil {
22 log.Panicln(err)
23 }
24
25 if m.CustomSections() == nil {
26 log.Panicln("Custom sections should not be nil")
27 }
28
29 mustContain(m.CustomSections(), "producers")
30 mustContain(m.CustomSections(), "target_features")
31
32
33
34 }
35
36 func mustContain(ss []api.CustomSection, name string) {
37 for _, s := range ss {
38 if s.Name() == name {
39 return
40 }
41 }
42 log.Panicf("Could not find section named %s\n", name)
43 }
44
View as plain text