-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
efi: add tests for grubImageHandle.Prefix
- Loading branch information
1 parent
d35fb15
commit 12a3c33
Showing
16 changed files
with
113 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// -*- Mode: Go; indent-tabs-mode: t -*- | ||
|
||
/* | ||
* Copyright (C) 2023 Canonical Ltd | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 3 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
package efi_test | ||
|
||
import ( | ||
. "gopkg.in/check.v1" | ||
|
||
. "github.com/snapcore/secboot/efi" | ||
) | ||
|
||
type grubSuite struct{} | ||
|
||
var _ = Suite(&grubSuite{}) | ||
|
||
func (s *grubSuite) TestGrubImageHandlePrefix1(c *C) { | ||
image, err := OpenPeImage(NewFileImage("testdata/amd64/mockgrub.efi")) | ||
c.Assert(err, IsNil) | ||
defer image.Close() | ||
|
||
grubImage := NewGrubImageHandle(image) | ||
|
||
prefix, err := grubImage.Prefix() | ||
c.Check(err, IsNil) | ||
c.Check(prefix, Equals, "/EFI/ubuntu") | ||
} | ||
|
||
func (s *grubSuite) TestGrubImageHandlePrefix2(c *C) { | ||
image, err := OpenPeImage(NewFileImage("testdata/amd64/mockgrub_debian.efi")) | ||
c.Assert(err, IsNil) | ||
defer image.Close() | ||
|
||
grubImage := NewGrubImageHandle(image) | ||
|
||
prefix, err := grubImage.Prefix() | ||
c.Check(err, IsNil) | ||
c.Check(prefix, Equals, "/EFI/debian") | ||
} | ||
|
||
func (s *grubSuite) TestGrubImageHandlePrefixNone(c *C) { | ||
image, err := OpenPeImage(NewFileImage("testdata/amd64/mockgrub_no_prefix.efi")) | ||
c.Assert(err, IsNil) | ||
defer image.Close() | ||
|
||
grubImage := NewGrubImageHandle(image) | ||
|
||
prefix, err := grubImage.Prefix() | ||
c.Check(err, IsNil) | ||
c.Check(prefix, Equals, "") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
efi/testdata/amd64/mockshim_no_vendor_cert.efi.signed.1.1.1
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.section mods, "a", %progbits | ||
.balignl 8, 0 | ||
.Lgrub_module_info: | ||
.4byte 0x676d696d | ||
.balignl 8, 0 | ||
.8byte .Lgrub_modules_start - .Lgrub_module_info | ||
.8byte .Lgrub_modules_end - .Lgrub_module_info | ||
.Lgrub_modules_start: | ||
#ifdef GRUB_PREFIX | ||
.Lgrub_prefix_start: | ||
.4byte 3 | ||
.4byte .Lgrub_prefix_end - .Lgrub_prefix_start | ||
.ascii GRUB_PREFIX | ||
.byte 0 | ||
.Lgrub_prefix_end: | ||
#endif | ||
.Lgrub_modules_end: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters