Skip to content

Commit 0eefc39

Browse files
committed
Merge branch 'simulator-env'
2 parents 014e2b2 + f8fabe9 commit 0eefc39

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,21 @@ cp /path/to/bitbox02-firmware/messages/*.proto api/firmware/messages/
1919
rm api/firmware/messages/backup.proto
2020
./api/firmware/messages/generate.sh
2121
```
22+
23+
## Simulator tests
24+
25+
The `TestSimulator*` tests run integration against BitBox02 simulators. They are automatically
26+
downloaded based on [api/firmware/testdata/simulators.json](api/firmware/testdata/simulators.json),
27+
and each one is tested with.
28+
29+
To run them, use:
30+
31+
go test -v -run TestSimulator ./...
32+
33+
If you want to test against a custom simulator build (e.g. when developing new firmware features),
34+
you can run:
35+
36+
SIMULATOR=/path/to/simulator go test -v -run TestSimulator ./...
37+
38+
In this case, only the given simulator will be used, and the ones defined in simulators.json will be
39+
ignored.

api/firmware/device_test.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,15 @@ func testSimulators(t *testing.T, run func(*testing.T, *Device)) {
168168
t.Skip("Skipping simulator tests: not running on linux-amd64")
169169
}
170170

171-
simulatorFilenames, err := downloadSimulatorsOnce()
172-
require.NoError(t, err)
171+
var simulatorFilenames []string
172+
envSimulator := os.Getenv("SIMULATOR")
173+
if envSimulator != "" {
174+
simulatorFilenames = []string{envSimulator}
175+
} else {
176+
var err error
177+
simulatorFilenames, err = downloadSimulatorsOnce()
178+
require.NoError(t, err)
179+
}
173180

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

0 commit comments

Comments
 (0)