test runtime v2 CPU settings

Signed-off-by: fahedouch <fahed.dorgaa@gmail.com>
This commit is contained in:
fahedouch 2019-11-24 00:40:04 +01:00
parent 383f4a77ee
commit 486d33631e

View File

@ -18,9 +18,30 @@ package shim
import ( import (
"context" "context"
"os"
"runtime"
"testing" "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) { func TestShimOptWithValue(t *testing.T) {
ctx := context.TODO() ctx := context.TODO()
ctx = context.WithValue(ctx, OptsKey{}, Opts{Debug: true}) ctx = context.WithValue(ctx, OptsKey{}, Opts{Debug: true})