Skip to content

Commit a7ad648

Browse files
committed
ProcessState.ExitCode() is added in Go 1.12
But we still want to support Go 1.11. Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent 191f50d commit a7ad648

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

runtime/service_integ_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,13 @@ func TestUpdateVMMetadata_Isolated(t *testing.T) {
11051105
assert.Equalf(t, "45", stdout, "container %q did not emit expected stdout", containerName)
11061106
}
11071107

1108+
func exitCode(err *exec.ExitError) int {
1109+
if status, ok := err.Sys().(syscall.WaitStatus); ok {
1110+
return int(status)
1111+
}
1112+
return -1
1113+
}
1114+
11081115
// TestRandomness validates that there is a reasonable amount of entropy available to the VM and thus
11091116
// randomness available to containers (test reads about 2.5MB from /dev/random w/ an overall test
11101117
// timeout of 60 seconds). It also validates that the quality of the randomness passes the rngtest
@@ -1201,9 +1208,11 @@ func TestRandomness_Isolated(t *testing.T) {
12011208
// Even though we have a failure tolerance, the test still provides some
12021209
// value in that we can be aware if a change to the rootfs results in a
12031210
// regression.
1204-
require.EqualValues(t, 1, rngtestCmd.ProcessState.ExitCode())
1205-
const failureTolerance = 4
1211+
exitErr, ok := err.(*exec.ExitError)
1212+
require.True(t, ok, "the error is not ExitError")
1213+
require.EqualValues(t, 1, exitCode(exitErr))
12061214

1215+
const failureTolerance = 4
12071216
for _, outputLine := range strings.Split(rngtestStderr.String(), "\n") {
12081217
var failureCount int
12091218
_, err := fmt.Sscanf(strings.TrimSpace(outputLine), "rngtest: FIPS 140-2 failures: %d", &failureCount)

0 commit comments

Comments
 (0)