Merge pull request #3845 from fahedouch/v2_shim_test

v2 runtime shim test
This commit is contained in:
Michael Crosby
2020-04-13 12:26:05 -04:00
committed by GitHub

View File

@@ -18,9 +18,30 @@ package shim
import (
"context"
"os"
"runtime"
"testing"
)
func TestRuntimeWithEmptyMaxEnvProcs(t *testing.T) {
os.Setenv("GOMAXPROCS", "")
setRuntime()
var oldGoMaxProcs = runtime.GOMAXPROCS(0)
if oldGoMaxProcs != 2 {
t.Fatal("the max number of procs should be 2")
}
}
func TestRuntimeWithNonEmptyMaxEnvProcs(t *testing.T) {
os.Setenv("GOMAXPROCS", "not_empty")
setRuntime()
var oldGoMaxProcs2 = runtime.GOMAXPROCS(0)
if oldGoMaxProcs2 != runtime.NumCPU() {
t.Fatal("the max number CPU should be equal to available CPUs")
}
}
func TestShimOptWithValue(t *testing.T) {
ctx := context.TODO()
ctx = context.WithValue(ctx, OptsKey{}, Opts{Debug: true})