Skip to content

Commit 80fdafc

Browse files
wasm: fixes test flake on Windows and strict mode (#3041)
Signed-off-by: Adrian Cole <[email protected]>
1 parent 46b7535 commit 80fdafc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

internal/wasm/wasm_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,14 @@ func TestNewModuleConfig(t *testing.T) {
172172
maxDuration: 50 * time.Millisecond * 5,
173173
},
174174
{
175-
name: "strictSandbox = true",
176-
metadata: &InitMetadata{StrictSandbox: true, Guest: binStrict},
177-
minDuration: 10 * time.Microsecond,
175+
name: "strictSandbox = true",
176+
metadata: &InitMetadata{StrictSandbox: true, Guest: binStrict},
177+
// In strict mode, nanosleep is implemented by an incrementing
178+
// number. The resolution of the real clock timing the wasm
179+
// invocation is lower resolution in Windows, so we can't verify a
180+
// lower bound. In any case, the important part is that we aren't
181+
// actually sleeping 50ms, which is what wasm thinks is happening.
182+
minDuration: 0,
178183
maxDuration: 1 * time.Millisecond,
179184
},
180185
}
@@ -211,7 +216,8 @@ func TestNewModuleConfig(t *testing.T) {
211216
} else {
212217
require.NotEqual(t, deterministicOut, out.String())
213218
}
214-
require.True(t, duration > tc.minDuration && duration < tc.maxDuration, duration)
219+
require.GreaterOrEqual(t, duration, tc.minDuration)
220+
require.LessOrEqual(t, duration, tc.maxDuration)
215221
})
216222
}
217223
}

0 commit comments

Comments
 (0)