test: TestRuntimeWithEmptyMaxEnvProcs should cleanup
TestRuntimeWithEmptyMaxEnvProcs should restore the GoMaxProcs after test so that the temporary change of GoMaxProcs will not impact other case, like TestRuntimeWithNonEmptyMaxEnvProcs. Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
parent
b566859acc
commit
9687ba6315
@ -24,11 +24,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestRuntimeWithEmptyMaxEnvProcs(t *testing.T) {
|
func TestRuntimeWithEmptyMaxEnvProcs(t *testing.T) {
|
||||||
|
var oldGoMaxProcs = runtime.GOMAXPROCS(0)
|
||||||
|
defer runtime.GOMAXPROCS(oldGoMaxProcs)
|
||||||
|
|
||||||
os.Setenv("GOMAXPROCS", "")
|
os.Setenv("GOMAXPROCS", "")
|
||||||
setRuntime()
|
setRuntime()
|
||||||
var oldGoMaxProcs = runtime.GOMAXPROCS(0)
|
|
||||||
if oldGoMaxProcs != 2 {
|
var currentGoMaxProcs = runtime.GOMAXPROCS(0)
|
||||||
|
if currentGoMaxProcs != 2 {
|
||||||
t.Fatal("the max number of procs should be 2")
|
t.Fatal("the max number of procs should be 2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user