sbf: move ELFs to fixtures

This commit is contained in:
Richard Patel 2022-09-04 18:38:49 +02:00
parent 2ff0ca6127
commit c3c4f02ef1
25 changed files with 25 additions and 7 deletions

19
fixtures/sbf.go Normal file
View File

@ -0,0 +1,19 @@
package fixtures
import (
"os"
"path/filepath"
"runtime"
"testing"
"github.com/stretchr/testify/require"
)
// SBF returns the given SBF fixture.
func SBF(t *testing.T, name string) []byte {
_, file, _, ok := runtime.Caller(0)
require.True(t, ok, "runtime.Caller failed")
data, err := os.ReadFile(filepath.Join(filepath.Dir(file), "sbf", name))
require.NoError(t, err)
return data
}

View File

@ -5,16 +5,14 @@ import (
_ "embed"
"testing"
"github.com/certusone/radiance/fixtures"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
var (
//go:embed tests/noop.so
soNoop []byte
)
func TestLoader_Noop(t *testing.T) {
soNoop := fixtures.SBF(t, "noop.so")
loader, err := NewLoaderFromBytes(soNoop)
require.NoError(t, err)
@ -203,7 +201,7 @@ func isZeroBytes(b []byte) bool {
}
func TestVerifier(t *testing.T) {
loader, err := NewLoaderFromBytes(soNoop)
loader, err := NewLoaderFromBytes(fixtures.SBF(t, "noop.so"))
require.NoError(t, err)
program, err := loader.Load()

View File

@ -3,9 +3,10 @@ package loader
import (
"testing"
"github.com/certusone/radiance/pkg/sbf"
"github.com/stretchr/testify/assert"
)
func TestSymbolHash_Entrypoint(t *testing.T) {
assert.Equal(t, EntrypointHash, SymbolHash("entrypoint"))
assert.Equal(t, sbf.EntrypointHash, sbf.SymbolHash("entrypoint"))
}