MCPcopy
hub / github.com/google/gvisor / doExecuteTest

Method doExecuteTest

runsc/cmd/mitigate_test.go:129–151  ·  view source on GitHub ↗

doExecuteTest runs Execute with the mitigate operation and reverse operation.

(t *testing.T, wantEnabled bool, wantCPUs int, wantErr subcommands.ExitStatus)

Source from the content-addressed store, hash-verified

127
128// doExecuteTest runs Execute with the mitigate operation and reverse operation.
129func (m *Mitigate) doExecuteTest(t *testing.T, wantEnabled bool, wantCPUs int, wantErr subcommands.ExitStatus) {
130 subError := m.execute()
131 if subError != wantErr {
132 t.Fatalf("Mitigate error mismatch: want: %v got: %v", wantErr, subError)
133 }
134
135 // case where test should end in error or we don't care
136 // about how many cpus are returned.
137 if wantErr != subcommands.ExitSuccess {
138 log.Infof("return")
139 return
140 }
141
142 gotEnabled, _ := m.control.isEnabled()
143 if wantEnabled != gotEnabled {
144 t.Fatalf("Incorrect enabled state: want: %t got: %t", wantEnabled, gotEnabled)
145 }
146
147 gotCPUs, _ := m.control.getCPUs()
148 if len(gotCPUs) != wantCPUs {
149 t.Fatalf("Incorrect number of CPUs: want: %d got: %d", wantCPUs, len(gotCPUs))
150 }
151}

Callers 1

TestExecuteFunction · 0.95

Calls 5

executeMethod · 0.95
InfofFunction · 0.92
FatalfMethod · 0.65
isEnabledMethod · 0.65
getCPUsMethod · 0.65

Tested by

no test coverage detected