Skip to content

Commit 984dbc8

Browse files
committed
Fix error messages in validation cgroup tests
Symptoms: ``` ok 3 - blkio weight is set correctly # expect: 500, actual: 842352267696 ``` After the patch: ``` ok 3 - blkio weight is set correctly # expect: 500, actual: 500 ``` I found those issues by patching runc to introduce "off-by-one" bugs and checking if they are correctly caught by the validation tests: https://github.com/kinvolk/runc/commits/alban/off-by-one-bugs Signed-off-by: Alban Crequy <[email protected]>
1 parent 36e9b37 commit 984dbc8

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

validation/linux_cgroups_cpus.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ func main() {
3030
return err
3131
}
3232
if *lcd.Shares != shares {
33-
return fmt.Errorf("cpus shares limit is not set correctly, expect: %d, actual: %d", shares, lcd.Shares)
33+
return fmt.Errorf("cpus shares limit is not set correctly, expect: %d, actual: %d", shares, *lcd.Shares)
3434
}
3535
if *lcd.Quota != quota {
36-
return fmt.Errorf("cpus quota is not set correctly, expect: %d, actual: %d", quota, lcd.Quota)
36+
return fmt.Errorf("cpus quota is not set correctly, expect: %d, actual: %d", quota, *lcd.Quota)
3737
}
3838
if *lcd.Period != period {
39-
return fmt.Errorf("cpus period is not set correctly, expect: %d, actual: %d", period, lcd.Period)
39+
return fmt.Errorf("cpus period is not set correctly, expect: %d, actual: %d", period, *lcd.Period)
4040
}
4141
if lcd.Cpus != cpus {
4242
return fmt.Errorf("cpus cpus is not set correctly, expect: %s, actual: %s", cpus, lcd.Cpus)

validation/linux_cgroups_hugetlb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
func main() {
1212
page := "1GB"
13-
var limit uint64 = 56892210544640
13+
var limit uint64 = 52985 * 1024 * 1024 * 1024 // multiple of hugepage size
1414
g := util.GetDefaultGenerator()
1515
g.SetLinuxCgroupsPath(cgroups.AbsCgroupPath)
1616
g.AddLinuxResourcesHugepageLimit(page, limit)

validation/util/linux_resources_blkio.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ func ValidateLinuxResourcesBlockIO(config *rspec.Spec, state *rspec.State) error
3030
}
3131

3232
t.Ok(*lbd.Weight == *config.Linux.Resources.BlockIO.Weight, "blkio weight is set correctly")
33-
t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.BlockIO.Weight, lbd.Weight)
33+
t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.BlockIO.Weight, *lbd.Weight)
3434

3535
t.Ok(*lbd.LeafWeight == *config.Linux.Resources.BlockIO.LeafWeight, "blkio leafWeight is set correctly")
36-
t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.BlockIO.LeafWeight, lbd.LeafWeight)
36+
t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.BlockIO.LeafWeight, *lbd.LeafWeight)
3737

3838
for _, device := range config.Linux.Resources.BlockIO.WeightDevice {
3939
found := false

validation/util/linux_resources_network.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func ValidateLinuxResourcesNetwork(config *rspec.Spec, state *rspec.State) error
3030
}
3131

3232
t.Ok(*lnd.ClassID == *config.Linux.Resources.Network.ClassID, "network ID set correctly")
33-
t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Network.ClassID, lnd.ClassID)
33+
t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Network.ClassID, *lnd.ClassID)
3434

3535
for _, priority := range config.Linux.Resources.Network.Priorities {
3636
found := false

0 commit comments

Comments
 (0)