func runCmd(cmdStr string) string {
	parts := strings.Split(cmdStr, " ")
	cmdCmd := parts[0]
	cmdArgs := parts[1:]
	cmd := exec.Command(cmdCmd, cmdArgs...)
	out, err := cmd.Output()
	if err != nil {
		log.Fatal(err)
	}
	return string(out)
}
---- tools func ----------------------------
starts the specified command and wait for it to complete
package main
import (
	"fmt"
	"log"
	"math"
	"os"
	"os/exec"
	"runtime"
	"strconv"
	"strings"
	"testing"
)
func Test_allCores(t *testing.T) {
	exeFilePath := "test_tmp\\go-cpu-load.exe"
	if exist, _ := Exists(exeFilePath); exist {
		runCmd("cmd /C del " + exeFilePath)
	}
	runCmd("go build -o " + exeFilePath)
	coresCount := runtime.NumCPU() 
	percentage := 33
	pid := startCmd(fmt.Sprintf("%s -c %d -p %d ", exeFilePath, coresCount, percentage))
	var sum float64
	count := 5
	t.Logf("coresCount: %d, percentage: %d", coresCount, percentage)
	usageExpect := float64(coresCount*percentage) / float64(runtime.NumCPU()*100) * 100
	var tolerance float64 = 3
	for i := 0; i < count; i++ {
		usageStr := runCmd(fmt.Sprintf("test_bin\\cpu_usage\\cpu_usage_win.exe %d", pid))
		usage, _ := strconv.Atoi(string(usageStr))
		usageF := float64(usage)
		sum += math.Pow(float64(math.Abs(usageExpect-usageF)), 2)
		t.Logf("usage: %s", usageStr)
	}
	runCmd(fmt.Sprintf("taskkill /f /pid %d", pid))
	t.Logf("usageExpect: %f", usageExpect)
	usageVariance := sum / float64(count)
	t.Logf("usageDelta %f", usageVariance)
	if usageVariance > tolerance {
		t.Errorf("usageVariance %f > tolerance %f", usageVariance, tolerance)
	}
}