github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/testing/dwarftestdata/data.go (about) 1 package dwarftestdata 2 3 import ( 4 "bytes" 5 "embed" 6 "fmt" 7 "os/exec" 8 ) 9 10 // DWARF tests are build-sensitive in the sense that 11 // whenever rebuilding the program, it is highly likely that 12 // line number, source code file, etc, can change. Therefore, 13 // even though these binaries are huge, we check them in to the repositories. 14 15 //go:embed testdata/tinygo/main.wasm 16 var TinyGoWasm []byte 17 18 //go:embed testdata/zig/main.wasm 19 var ZigWasm []byte 20 21 //go:embed testdata/zig-cc/main.wasm 22 var ZigCCWasm []byte 23 24 // RustWasm comes with huge DWARF sections, so we do not check it in directly, 25 // but instead xz-compressed one is. 26 var RustWasm []byte 27 28 //go:embed testdata/rust 29 var testRustDir embed.FS 30 31 func init() { 32 const wasmPath = "testdata/rust/main.wasm" 33 var err error 34 RustWasm, err = testRustDir.ReadFile(wasmPath) 35 if err != nil { 36 const xzPath = "testdata/rust/main.wasm.xz" 37 xzWasm, err := testRustDir.ReadFile(xzPath) 38 if err != nil { 39 panic(err) 40 } 41 cmd := exec.Command("xz", "-d") 42 cmd.Stdin = bytes.NewReader(xzWasm) 43 out := bytes.NewBuffer(nil) 44 cmd.Stdout = out 45 if err = cmd.Run(); err != nil { 46 fmt.Printf("Skipping DWARF tests for rusts as xz command failed: %v", err) 47 return 48 } 49 RustWasm = out.Bytes() 50 } 51 }