github.com/opencontainers/runc@v1.2.0-rc.1.0.20240520010911-492dc558cdd6/libcontainer/intelrdt/cmt_test.go (about) 1 package intelrdt 2 3 import ( 4 "path/filepath" 5 "testing" 6 ) 7 8 func TestGetCMTNumaNodeStats(t *testing.T) { 9 mocksNUMANodesToCreate := []string{"mon_l3_00", "mon_l3_01"} 10 11 mocksFilesToCreate := map[string]uint64{ 12 "llc_occupancy": 9123911, 13 } 14 15 mockedL3_MON := mockResctrlL3_MON(t, mocksNUMANodesToCreate, mocksFilesToCreate) 16 17 t.Run("Gather mbm", func(t *testing.T) { 18 enabledMonFeatures.llcOccupancy = true 19 20 stats := make([]CMTNumaNodeStats, 0, len(mocksNUMANodesToCreate)) 21 for _, numa := range mocksNUMANodesToCreate { 22 other, err := getCMTNumaNodeStats(filepath.Join(mockedL3_MON, "mon_data", numa)) 23 if err != nil { 24 t.Fatal(err) 25 } 26 stats = append(stats, *other) 27 } 28 29 expectedStats := CMTNumaNodeStats{ 30 LLCOccupancy: mocksFilesToCreate["llc_occupancy"], 31 } 32 33 checkCMTStatCorrection(stats[0], expectedStats, t) 34 checkCMTStatCorrection(stats[1], expectedStats, t) 35 }) 36 } 37 38 func checkCMTStatCorrection(got CMTNumaNodeStats, expected CMTNumaNodeStats, t *testing.T) { 39 if got.LLCOccupancy != expected.LLCOccupancy { 40 t.Fatalf("Wrong value of `llc_occupancy`. Expected: %v but got: %v", 41 expected.LLCOccupancy, 42 got.LLCOccupancy) 43 } 44 }