...
1 package sysfs_test
2
3 import (
4 "io/fs"
5 "testing/fstest"
6
7 "github.com/tetratelabs/wazero"
8 "github.com/tetratelabs/wazero/experimental/sysfs"
9 )
10
11 var moduleConfig wazero.ModuleConfig
12
13
14 func ExampleAdaptFS() {
15 m := fstest.MapFS{
16 "a/b.txt": &fstest.MapFile{Mode: 0o666},
17 ".": &fstest.MapFile{Mode: 0o777 | fs.ModeDir},
18 }
19 root := &sysfs.AdaptFS{FS: m}
20
21 moduleConfig = wazero.NewModuleConfig().
22 WithFSConfig(wazero.NewFSConfig().(sysfs.FSConfig).WithSysFSMount(root, "/"))
23 }
24
25
26 func ExampleDirFS() {
27 root := sysfs.DirFS(".")
28
29 moduleConfig = wazero.NewModuleConfig().
30 WithFSConfig(wazero.NewFSConfig().(sysfs.FSConfig).WithSysFSMount(root, "/"))
31 }
32
33
34 func ExampleReadFS() {
35 root := sysfs.DirFS(".")
36 readOnly := &sysfs.ReadFS{FS: root}
37
38 moduleConfig = wazero.NewModuleConfig().
39 WithFSConfig(wazero.NewFSConfig().(sysfs.FSConfig).WithSysFSMount(readOnly, "/"))
40 }
41
View as plain text