libct/cg/fs/stats_util_test: fix errors

1. No \n needed in t.Errorf/t.Fatalf.

2. Some cosmetic changes.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2021-06-08 17:40:06 -07:00
parent 563225d55f
commit 4e33094277
+26 -26
View File
@@ -18,7 +18,7 @@ func blkioStatEntryEquals(expected, actual []cgroups.BlkioStatEntry) error {
for i, expValue := range expected {
actValue := actual[i]
if expValue != actValue {
return fmt.Errorf("Expected blkio stat entry %v but found %v", expValue, actValue)
return fmt.Errorf("expected: %v, actual: %v", expValue, actValue)
}
}
return nil
@@ -27,49 +27,49 @@ func blkioStatEntryEquals(expected, actual []cgroups.BlkioStatEntry) error {
func expectBlkioStatsEquals(t *testing.T, expected, actual cgroups.BlkioStats) {
t.Helper()
if err := blkioStatEntryEquals(expected.IoServiceBytesRecursive, actual.IoServiceBytesRecursive); err != nil {
t.Errorf("blkio IoServiceBytesRecursive do not match - %s\n", err)
t.Errorf("blkio IoServiceBytesRecursive do not match: %s", err)
}
if err := blkioStatEntryEquals(expected.IoServicedRecursive, actual.IoServicedRecursive); err != nil {
t.Errorf("blkio IoServicedRecursive do not match - %s\n", err)
t.Errorf("blkio IoServicedRecursive do not match: %s", err)
}
if err := blkioStatEntryEquals(expected.IoQueuedRecursive, actual.IoQueuedRecursive); err != nil {
t.Errorf("blkio IoQueuedRecursive do not match - %s\n", err)
t.Errorf("blkio IoQueuedRecursive do not match: %s", err)
}
if err := blkioStatEntryEquals(expected.SectorsRecursive, actual.SectorsRecursive); err != nil {
t.Errorf("blkio SectorsRecursive do not match - %s\n", err)
t.Errorf("blkio SectorsRecursive do not match: %s", err)
}
if err := blkioStatEntryEquals(expected.IoServiceTimeRecursive, actual.IoServiceTimeRecursive); err != nil {
t.Errorf("blkio IoServiceTimeRecursive do not match - %s\n", err)
t.Errorf("blkio IoServiceTimeRecursive do not match: %s", err)
}
if err := blkioStatEntryEquals(expected.IoWaitTimeRecursive, actual.IoWaitTimeRecursive); err != nil {
t.Errorf("blkio IoWaitTimeRecursive do not match - %s\n", err)
t.Errorf("blkio IoWaitTimeRecursive do not match: %s", err)
}
if err := blkioStatEntryEquals(expected.IoMergedRecursive, actual.IoMergedRecursive); err != nil {
t.Errorf("blkio IoMergedRecursive do not match - %v vs %v\n", expected.IoMergedRecursive, actual.IoMergedRecursive)
t.Errorf("blkio IoMergedRecursive do not match: expcted: %v, actual: %v", expected.IoMergedRecursive, actual.IoMergedRecursive)
}
if err := blkioStatEntryEquals(expected.IoTimeRecursive, actual.IoTimeRecursive); err != nil {
t.Errorf("blkio IoTimeRecursive do not match - %s\n", err)
t.Errorf("blkio IoTimeRecursive do not match: %s", err)
}
}
func expectThrottlingDataEquals(t *testing.T, expected, actual cgroups.ThrottlingData) {
t.Helper()
if expected != actual {
t.Errorf("Expected throttling data %v but found %v\n", expected, actual)
t.Errorf("Expected throttling data: %v, actual: %v", expected, actual)
}
}
func expectHugetlbStatEquals(t *testing.T, expected, actual cgroups.HugetlbStats) {
t.Helper()
if expected != actual {
t.Errorf("Expected hugetlb stats %v but found %v\n", expected, actual)
t.Errorf("Expected hugetlb stats: %v, actual: %v", expected, actual)
}
}
@@ -81,16 +81,16 @@ func expectMemoryStatEquals(t *testing.T, expected, actual cgroups.MemoryStats)
expectPageUsageByNUMAEquals(t, expected.PageUsageByNUMA, actual.PageUsageByNUMA)
if expected.UseHierarchy != actual.UseHierarchy {
t.Errorf("Expected memory use hierarchy %v, but found %v\n", expected.UseHierarchy, actual.UseHierarchy)
t.Errorf("Expected memory use hierarchy: %v, actual: %v", expected.UseHierarchy, actual.UseHierarchy)
}
for key, expValue := range expected.Stats {
actValue, ok := actual.Stats[key]
if !ok {
t.Errorf("Expected memory stat key %s not found\n", key)
t.Errorf("Expected memory stat key %s not found", key)
}
if expValue != actValue {
t.Errorf("Expected memory stat value %d but found %d\n", expValue, actValue)
t.Errorf("Expected memory stat value: %d, actual: %d", expValue, actValue)
}
}
}
@@ -98,43 +98,43 @@ func expectMemoryStatEquals(t *testing.T, expected, actual cgroups.MemoryStats)
func expectMemoryDataEquals(t *testing.T, expected, actual cgroups.MemoryData) {
t.Helper()
if expected.Usage != actual.Usage {
t.Errorf("Expected memory usage %d but found %d\n", expected.Usage, actual.Usage)
t.Errorf("Expected memory usage: %d, actual: %d", expected.Usage, actual.Usage)
}
if expected.MaxUsage != actual.MaxUsage {
t.Errorf("Expected memory max usage %d but found %d\n", expected.MaxUsage, actual.MaxUsage)
t.Errorf("Expected memory max usage: %d, actual: %d", expected.MaxUsage, actual.MaxUsage)
}
if expected.Failcnt != actual.Failcnt {
t.Errorf("Expected memory failcnt %d but found %d\n", expected.Failcnt, actual.Failcnt)
t.Errorf("Expected memory failcnt %d, actual: %d", expected.Failcnt, actual.Failcnt)
}
if expected.Limit != actual.Limit {
t.Errorf("Expected memory limit %d but found %d\n", expected.Limit, actual.Limit)
t.Errorf("Expected memory limit: %d, actual: %d", expected.Limit, actual.Limit)
}
}
func expectPageUsageByNUMAEquals(t *testing.T, expected, actual cgroups.PageUsageByNUMA) {
t.Helper()
if !reflect.DeepEqual(expected.Total, actual.Total) {
t.Errorf("Expected total page usage by NUMA %#v but found %#v", expected.Total, actual.Total)
t.Errorf("Expected total page usage by NUMA: %#v, actual: %#v", expected.Total, actual.Total)
}
if !reflect.DeepEqual(expected.File, actual.File) {
t.Errorf("Expected file page usage by NUMA %#v but found %#v", expected.File, actual.File)
t.Errorf("Expected file page usage by NUMA: %#v, actual: %#v", expected.File, actual.File)
}
if !reflect.DeepEqual(expected.Anon, actual.Anon) {
t.Errorf("Expected anon page usage by NUMA %#v but found %#v", expected.Anon, actual.Anon)
t.Errorf("Expected anon page usage by NUMA: %#v, actual: %#v", expected.Anon, actual.Anon)
}
if !reflect.DeepEqual(expected.Unevictable, actual.Unevictable) {
t.Errorf("Expected unevictable page usage by NUMA %#v but found %#v", expected.Unevictable, actual.Unevictable)
t.Errorf("Expected unevictable page usage by NUMA: %#v, actual: %#v", expected.Unevictable, actual.Unevictable)
}
if !reflect.DeepEqual(expected.Hierarchical.Total, actual.Hierarchical.Total) {
t.Errorf("Expected hierarchical total page usage by NUMA %#v but found %#v", expected.Hierarchical.Total, actual.Hierarchical.Total)
t.Errorf("Expected hierarchical total page usage by NUMA: %#v, actual: %#v", expected.Hierarchical.Total, actual.Hierarchical.Total)
}
if !reflect.DeepEqual(expected.Hierarchical.File, actual.Hierarchical.File) {
t.Errorf("Expected hierarchical file page usage by NUMA %#v but found %#v", expected.Hierarchical.File, actual.Hierarchical.File)
t.Errorf("Expected hierarchical file page usage by NUMA: %#v, actual: %#v", expected.Hierarchical.File, actual.Hierarchical.File)
}
if !reflect.DeepEqual(expected.Hierarchical.Anon, actual.Hierarchical.Anon) {
t.Errorf("Expected hierarchical anon page usage by NUMA %#v but found %#v", expected.Hierarchical.Anon, actual.Hierarchical.Anon)
t.Errorf("Expected hierarchical anon page usage by NUMA: %#v, actual: %#v", expected.Hierarchical.Anon, actual.Hierarchical.Anon)
}
if !reflect.DeepEqual(expected.Hierarchical.Unevictable, actual.Hierarchical.Unevictable) {
t.Errorf("Expected hierarchical total page usage by NUMA %#v but found %#v", expected.Hierarchical.Unevictable, actual.Hierarchical.Unevictable)
t.Errorf("Expected hierarchical total page usage by NUMA: %#v, actual: %#v", expected.Hierarchical.Unevictable, actual.Hierarchical.Unevictable)
}
}