Skip to content

Commit

Permalink
Adapt bootentry tests
Browse files Browse the repository at this point in the history
Signed-off-by: Itxaka <itxaka@kairos.io>
  • Loading branch information
Itxaka committed Nov 20, 2024
1 parent e0b4755 commit 4b56395
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions pkg/action/bootentries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(err.Error()).To(ContainSubstring("does not exist"))
})
It("selects the boot entry in a default installation", func() {
err := fs.WriteFile("/efi/loader/entries/active.conf", []byte("title kairos\nefi /EFI/kairos/active.efi\n"), os.ModePerm)
err := fs.WriteFile("/efi/loader/entries/active+3.conf", []byte("title kairos\nefi /EFI/kairos/active.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/entries/passive.conf", []byte("title kairos (fallback)\nefi /EFI/kairos/passive.efi\n"), os.ModePerm)
err = fs.WriteFile("/efi/loader/entries/passive+3.conf", []byte("title kairos (fallback)\nefi /EFI/kairos/passive.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/entries/recovery.conf", []byte("title kairos recovery\nefi /EFI/kairos/recovery.efi\n"), os.ModePerm)
err = fs.WriteFile("/efi/loader/entries/recovery+3.conf", []byte("title kairos recovery\nefi /EFI/kairos/recovery.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/entries/statereset.conf", []byte("title kairos state reset (auto)\nefi /EFI/kairos/statereset.efi\n"), os.ModePerm)
err = fs.WriteFile("/efi/loader/entries/statereset+3.conf", []byte("title kairos state reset (auto)\nefi /EFI/kairos/statereset.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/loader.conf", []byte(""), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
Expand All @@ -155,7 +155,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to fallback"))
reader, err := utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("passive.conf"))
Expect(reader["default"]).To(Equal("passive+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -176,7 +176,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to recovery"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("recovery.conf"))
Expect(reader["default"]).To(Equal("recovery+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -197,7 +197,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to statereset"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("statereset.conf"))
Expect(reader["default"]).To(Equal("statereset+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -218,7 +218,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to cos"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("active.conf"))
Expect(reader["default"]).To(Equal("active+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -240,7 +240,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to active"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("active.conf"))
Expect(reader["default"]).To(Equal("active+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -258,13 +258,13 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
})

It("selects the boot entry in a extend-cmdline installation with boot branding", func() {
err := fs.WriteFile("/efi/loader/entries/active_install-mode_awesomeos.conf", []byte("title awesomeos\nefi /EFI/kairos/active_install-mode_awesomeos.efi\n"), os.ModePerm)
err := fs.WriteFile("/efi/loader/entries/active_install-mode_awesomeos+3.conf", []byte("title awesomeos\nefi /EFI/kairos/active_install-mode_awesomeos.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/entries/passive_install-mode_awesomeos.conf", []byte("title awesomeos (fallback)\nefi /EFI/kairos/passive_install-mode_awesomeos.efi\n"), os.ModePerm)
err = fs.WriteFile("/efi/loader/entries/passive_install-mode_awesomeos+3.conf", []byte("title awesomeos (fallback)\nefi /EFI/kairos/passive_install-mode_awesomeos.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/entries/recovery_install-mode_awesomeos.conf", []byte("title awesomeos recovery\nefi /EFI/kairos/recovery_install-mode_awesomeos.efi\n"), os.ModePerm)
err = fs.WriteFile("/efi/loader/entries/recovery_install-mode_awesomeos+3.conf", []byte("title awesomeos recovery\nefi /EFI/kairos/recovery_install-mode_awesomeos.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/entries/statereset_install-mode_awesomeos.conf", []byte("title awesomeos state reset (auto)\nefi /EFI/kairos/statereset_install-mode_awesomeos.efi\n"), os.ModePerm)
err = fs.WriteFile("/efi/loader/entries/statereset_install-mode_awesomeos+3.conf", []byte("title awesomeos state reset (auto)\nefi /EFI/kairos/statereset_install-mode_awesomeos.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/loader.conf", []byte(""), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
Expand All @@ -274,7 +274,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to fallback"))
reader, err := utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("passive_install-mode_awesomeos.conf"))
Expect(reader["default"]).To(Equal("passive_install-mode_awesomeos+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -295,7 +295,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to recovery"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("recovery_install-mode_awesomeos.conf"))
Expect(reader["default"]).To(Equal("recovery_install-mode_awesomeos+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -316,7 +316,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to statereset"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("statereset_install-mode_awesomeos.conf"))
Expect(reader["default"]).To(Equal("statereset_install-mode_awesomeos+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -337,7 +337,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to cos"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("active_install-mode_awesomeos.conf"))
Expect(reader["default"]).To(Equal("active_install-mode_awesomeos+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -359,7 +359,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to active"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("active_install-mode_awesomeos.conf"))
Expect(reader["default"]).To(Equal("active_install-mode_awesomeos+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -377,21 +377,21 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
})

It("selects the boot entry in a extra-cmdline installation", func() {
err := fs.WriteFile("/efi/loader/entries/active.conf", []byte("title Kairos\nefi /EFI/kairos/active.efi\n"), os.ModePerm)
err := fs.WriteFile("/efi/loader/entries/active+3.conf", []byte("title Kairos\nefi /EFI/kairos/active.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/entries/active_foobar.conf", []byte("title Kairos\nefi /EFI/kairos/active_foobar.efi\n"), os.ModePerm)
err = fs.WriteFile("/efi/loader/entries/active_foobar+3.conf", []byte("title Kairos\nefi /EFI/kairos/active_foobar.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/entries/passive.conf", []byte("title Kairos (fallback)\nefi /EFI/kairos/passive.efi\n"), os.ModePerm)
err = fs.WriteFile("/efi/loader/entries/passive+3.conf", []byte("title Kairos (fallback)\nefi /EFI/kairos/passive.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/entries/passive_foobar.conf", []byte("title Kairos (fallback)\nefi /EFI/kairos/passive_foobar.efi\n"), os.ModePerm)
err = fs.WriteFile("/efi/loader/entries/passive_foobar+3.conf", []byte("title Kairos (fallback)\nefi /EFI/kairos/passive_foobar.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/entries/recovery.conf", []byte("title Kairos recovery\nefi /EFI/kairos/recovery.efi\n"), os.ModePerm)
err = fs.WriteFile("/efi/loader/entries/recovery+3.conf", []byte("title Kairos recovery\nefi /EFI/kairos/recovery.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/entries/recovery_foobar.conf", []byte("title Kairos recovery\nefi /EFI/kairos/recovery_foobar.efi\n"), os.ModePerm)
err = fs.WriteFile("/efi/loader/entries/recovery_foobar+3.conf", []byte("title Kairos recovery\nefi /EFI/kairos/recovery_foobar.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/entries/statereset.conf", []byte("title Kairos state reset (auto)\nefi /EFI/kairos/statereset.efi\n"), os.ModePerm)
err = fs.WriteFile("/efi/loader/entries/statereset+3.conf", []byte("title Kairos state reset (auto)\nefi /EFI/kairos/statereset.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/entries/statereset_foobar.conf", []byte("title Kairos state reset (auto)\nefi /EFI/kairos/state_reset_foobar.efi\n"), os.ModePerm)
err = fs.WriteFile("/efi/loader/entries/statereset_foobar+3.conf", []byte("title Kairos state reset (auto)\nefi /EFI/kairos/state_reset_foobar.efi\n"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFile("/efi/loader/loader.conf", []byte(""), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
Expand All @@ -401,7 +401,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to fallback"))
reader, err := utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("passive.conf"))
Expect(reader["default"]).To(Equal("passive+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -422,7 +422,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to fallback foobar"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("passive_foobar.conf"))
Expect(reader["default"]).To(Equal("passive_foobar+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -443,7 +443,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to recovery"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("recovery.conf"))
Expect(reader["default"]).To(Equal("recovery+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -464,7 +464,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to recovery foobar"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("recovery_foobar.conf"))
Expect(reader["default"]).To(Equal("recovery_foobar+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -485,7 +485,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to statereset"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("statereset.conf"))
Expect(reader["default"]).To(Equal("statereset+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -506,7 +506,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to statereset foobar"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("statereset_foobar.conf"))
Expect(reader["default"]).To(Equal("statereset_foobar+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -527,7 +527,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to cos"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("active.conf"))
Expect(reader["default"]).To(Equal("active+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -548,7 +548,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to cos foobar"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("active_foobar.conf"))
Expect(reader["default"]).To(Equal("active_foobar+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -570,7 +570,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to active"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("active.conf"))
Expect(reader["default"]).To(Equal("active+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand All @@ -590,7 +590,7 @@ var _ = Describe("Bootentries tests", Label("bootentry"), func() {
Expect(memLog.String()).To(ContainSubstring("Default boot entry set to active foobar"))
reader, err = utils.SystemdBootConfReader(fs, "/efi/loader/loader.conf")
Expect(err).ToNot(HaveOccurred())
Expect(reader["default"]).To(Equal("active_foobar.conf"))
Expect(reader["default"]).To(Equal("active_foobar+3.conf"))
// Should have called a remount to make it RW
Expect(syscallMock.WasMountCalledWith(
"",
Expand Down

0 comments on commit 4b56395

Please sign in to comment.