Skip to content

Commit eaf3e64

Browse files
committed
overlord/devicestate: make tests run without cgroups
These tests do not need to fail in containers where /sys/fs/cgroup is not available.
1 parent 89c2bd8 commit eaf3e64

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

overlord/devicestate/devicestate_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import (
6363
"github.com/snapcore/snapd/overlord/state"
6464
"github.com/snapcore/snapd/overlord/storecontext"
6565
"github.com/snapcore/snapd/release"
66+
"github.com/snapcore/snapd/sandbox/cgroup"
6667
"github.com/snapcore/snapd/secboot"
6768
"github.com/snapcore/snapd/secboot/keys"
6869
"github.com/snapcore/snapd/seed"
@@ -716,6 +717,7 @@ func (s *deviceMgrSuite) TestDeviceManagerEnsureBootOkBootloaderHappy(c *C) {
716717
}
717718

718719
func (s *deviceMgrSuite) TestDeviceManagerEnsureBootOkUpdateBootRevisionsHappy(c *C) {
720+
defer cgroup.MockVersion(cgroup.V2, nil)()
719721
s.setPCModelInState(c)
720722

721723
// simulate that we have a new core_2, tried to boot it but that failed

overlord/devicestate/firstboot20_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import (
4646
"github.com/snapcore/snapd/overlord/snapstate"
4747
"github.com/snapcore/snapd/overlord/state"
4848
"github.com/snapcore/snapd/release"
49+
"github.com/snapcore/snapd/sandbox/cgroup"
4950
"github.com/snapcore/snapd/seed/seedtest"
5051
"github.com/snapcore/snapd/snap"
5152
"github.com/snapcore/snapd/snap/channel"
@@ -1533,6 +1534,8 @@ func (s *firstBoot20Suite) TestPopulateFromSeedCore20ValidationSetTrackingNotAdd
15331534
}
15341535

15351536
func (s *firstBoot20Suite) TestPopulateFromSeedCore20ValidationSetTrackingFailsUnmetCriterias(c *C) {
1537+
defer cgroup.MockVersion(cgroup.V2, nil)()
1538+
15361539
vsb, err := s.StoreSigning.Sign(asserts.ValidationSetType, map[string]any{
15371540
"type": "validation-set",
15381541
"authority-id": "canonical",

overlord/devicestate/firstboot_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import (
5858
"github.com/snapcore/snapd/overlord/snapstate/snapstatetest"
5959
"github.com/snapcore/snapd/overlord/state"
6060
"github.com/snapcore/snapd/release"
61+
"github.com/snapcore/snapd/sandbox/cgroup"
6162
"github.com/snapcore/snapd/seed/seedtest"
6263
"github.com/snapcore/snapd/snap"
6364
"github.com/snapcore/snapd/snap/snaptest"
@@ -2489,6 +2490,8 @@ func (s *firstBoot16Suite) TestPopulateFromSeedCore18ValidationSetTrackingHappy(
24892490
}
24902491

24912492
func (s *firstBoot16Suite) TestPopulateFromSeedCore18ValidationSetTrackingUnmetCriteria(c *C) {
2493+
defer cgroup.MockVersion(cgroup.V2, nil)()
2494+
24922495
a, err := s.StoreSigning.Sign(asserts.ValidationSetType, map[string]any{
24932496
"type": "validation-set",
24942497
"authority-id": "canonical",

0 commit comments

Comments
 (0)