-
Notifications
You must be signed in to change notification settings - Fork 267
/
Copy pathconfig_example_test.go
40 lines (31 loc) · 1.01 KB
/
config_example_test.go
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
package sysfs_test
import (
"io/fs"
"testing/fstest"
"github.com/tetratelabs/wazero"
"github.com/tetratelabs/wazero/experimental/sysfs"
)
var moduleConfig wazero.ModuleConfig
// This example shows how to adapt a fs.FS to a sys.FS
func ExampleAdaptFS() {
m := fstest.MapFS{
"a/b.txt": &fstest.MapFile{Mode: 0o666},
".": &fstest.MapFile{Mode: 0o777 | fs.ModeDir},
}
root := &sysfs.AdaptFS{FS: m}
moduleConfig = wazero.NewModuleConfig().
WithFSConfig(wazero.NewFSConfig().(sysfs.FSConfig).WithSysFSMount(root, "/"))
}
// This example shows how to configure a sysfs.DirFS
func ExampleDirFS() {
root := sysfs.DirFS(".")
moduleConfig = wazero.NewModuleConfig().
WithFSConfig(wazero.NewFSConfig().(sysfs.FSConfig).WithSysFSMount(root, "/"))
}
// This example shows how to configure a sysfs.ReadFS
func ExampleReadFS() {
root := sysfs.DirFS(".")
readOnly := &sysfs.ReadFS{FS: root}
moduleConfig = wazero.NewModuleConfig().
WithFSConfig(wazero.NewFSConfig().(sysfs.FSConfig).WithSysFSMount(readOnly, "/"))
}