Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: allow running integration tests against a custom simulator #102

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,21 @@ cp /path/to/bitbox02-firmware/messages/*.proto api/firmware/messages/
rm api/firmware/messages/backup.proto
./api/firmware/messages/generate.sh
```

## Simulator tests

The `TestSimulator*` tests run integration against BitBox02 simulators. They are automatically
downloaded based on [api/firmware/testdata/simulators.json](api/firmware/testdata/simulators.json),
and each one is tested with.

To run them, use:

go test -v -run TestSimulator ./...

If you want to test against a custom simulator build (e.g. when developing new firmware features),
you can run:

SIMULATOR=/path/to/simulator go test -v -run TestSimulator ./...

In this case, only the given simulator will be used, and the ones defined in simulators.json will be
ignored.
11 changes: 9 additions & 2 deletions api/firmware/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,15 @@ func testSimulators(t *testing.T, run func(*testing.T, *Device)) {
t.Skip("Skipping simulator tests: not running on linux-amd64")
}

simulatorFilenames, err := downloadSimulatorsOnce()
require.NoError(t, err)
var simulatorFilenames []string
envSimulator := os.Getenv("SIMULATOR")
if envSimulator != "" {
simulatorFilenames = []string{envSimulator}
} else {
var err error
simulatorFilenames, err = downloadSimulatorsOnce()
require.NoError(t, err)
}

for _, simulatorFilename := range simulatorFilenames {
t.Run(filepath.Base(simulatorFilename), func(t *testing.T) {
Expand Down
Loading