From c76ae27ffb5c6be662a91105ed388c117815914c Mon Sep 17 00:00:00 2001 From: Szymon Scharmach Date: Mon, 25 Sep 2017 15:26:06 +0200 Subject: [PATCH] Improve HT detection --- test/e2e_node/cpu_manager_test.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/e2e_node/cpu_manager_test.go b/test/e2e_node/cpu_manager_test.go index 155cc333a68..859c13b7f0a 100644 --- a/test/e2e_node/cpu_manager_test.go +++ b/test/e2e_node/cpu_manager_test.go @@ -19,6 +19,8 @@ package e2e_node import ( "fmt" "os/exec" + "strconv" + "strings" "time" "k8s.io/api/core/v1" @@ -115,11 +117,13 @@ func waitForContainerRemoval(ctnPartName string) { } func isHTEnabled() bool { - err := exec.Command("/bin/sh", "-c", "if [[ $(lscpu | grep \"Thread(s) per core:\" | cut -c24) != \"2\" ]]; then exit 1; fi").Run() - if err != nil { - return false - } - return true + outData, err := exec.Command("/bin/sh", "-c", "lscpu | grep \"Thread(s) per core:\" | cut -d \":\" -f 2").Output() + framework.ExpectNoError(err) + + threadsPerCore, err := strconv.Atoi(strings.TrimSpace(string(outData))) + framework.ExpectNoError(err) + + return threadsPerCore > 1 } func getCPUSiblingList(cpuRes int64) string {