Files
runc/libcontainer/intelrdt/mbm_test.go
Kir Kolyshkin dbb9fc03ae libct/*: remove linux build tag from some pkgs
Only some libcontainer packages can be built on non-linux platforms
(not that it make sense, but at least go build succeeds). Let's call
these "good" packages.

For all other packages (i.e. ones that fail to build with GOOS other
than linux), it does not make sense to have linux build tag (as they
are broken already, and thus are not and can not be used on anything
other than Linux).

Remove linux build tag for all non-"good" packages.

This was mostly done by the following script, with just a few manual
fixes on top.

function list_good_pkgs() {
	for pkg in $(find . -type d -print); do
		GOOS=freebsd go build $pkg 2>/dev/null \
		&& GOOS=solaris go build $pkg 2>/dev/null \
		&& echo $pkg
	done | sed -e 's|^./||' | tr '\n' '|' | sed -e 's/|$//'
}

function remove_tag() {
	sed -i -e '\|^// +build linux$|d' $1
	go fmt $1
}

SKIP="^("$(list_good_pkgs)")"
for f in $(git ls-files . | grep .go$); do
	if echo $f | grep -qE "$SKIP"; then
		echo skip $f
		continue
	fi
	echo proc $f
	remove_tag $f
done

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-08-30 20:52:07 -07:00

54 lines
1.4 KiB
Go

package intelrdt
import (
"path/filepath"
"testing"
)
func TestGetMBMNumaNodeStats(t *testing.T) {
mocksNUMANodesToCreate := []string{"mon_l3_00", "mon_l3_01"}
mocksFilesToCreate := map[string]uint64{
"mbm_total_bytes": 9123911,
"mbm_local_bytes": 2361361,
}
mockedL3_MON := mockResctrlL3_MON(t, mocksNUMANodesToCreate, mocksFilesToCreate)
t.Run("Gather mbm", func(t *testing.T) {
enabledMonFeatures.mbmTotalBytes = true
enabledMonFeatures.mbmLocalBytes = true
stats := make([]MBMNumaNodeStats, 0, len(mocksNUMANodesToCreate))
for _, numa := range mocksNUMANodesToCreate {
other, err := getMBMNumaNodeStats(filepath.Join(mockedL3_MON, "mon_data", numa))
if err != nil {
t.Fatal(err)
}
stats = append(stats, *other)
}
expectedStats := MBMNumaNodeStats{
MBMTotalBytes: mocksFilesToCreate["mbm_total_bytes"],
MBMLocalBytes: mocksFilesToCreate["mbm_local_bytes"],
}
checkMBMStatCorrection(stats[0], expectedStats, t)
checkMBMStatCorrection(stats[1], expectedStats, t)
})
}
func checkMBMStatCorrection(got MBMNumaNodeStats, expected MBMNumaNodeStats, t *testing.T) {
if got.MBMTotalBytes != expected.MBMTotalBytes {
t.Fatalf("Wrong value of mbm_total_bytes. Expected: %v but got: %v",
expected.MBMTotalBytes,
got.MBMTotalBytes)
}
if got.MBMLocalBytes != expected.MBMLocalBytes {
t.Fatalf("Wrong value of mbm_local_bytes. Expected: %v but got: %v",
expected.MBMLocalBytes,
got.MBMLocalBytes)
}
}