fixed ShimFind for aarch64

Signed-off-by: Christian Goll <cgoll@suse.com>
This commit is contained in:
Christian Goll
2024-03-18 16:18:25 +01:00
committed by Jonathon Anderson
parent 16f5b7408e
commit b192e3b5d5
5 changed files with 40 additions and 52 deletions

View File

@@ -5,8 +5,6 @@ import (
"path"
"testing"
// warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
"github.com/stretchr/testify/assert"
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config"
"github.com/warewulf/warewulf/internal/pkg/testenv"
@@ -17,10 +15,10 @@ func Test_Find_ShimX86(t *testing.T) {
testenv.New(t)
conf := warewulfconf.Get()
wwlog.SetLogLevel(wwlog.DEBUG)
os.MkdirAll(path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/lib64/efi/"), 0755)
_ = os.MkdirAll(path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/lib64/efi/"), 0755)
shimF, err := os.Create(path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/lib64/efi/shim.efi"))
assert.NoError(t, err)
shimF.WriteString("shim.efi")
_, _ = shimF.WriteString("shim.efi")
assert.FileExists(t, path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/lib64/efi/shim.efi"))
shimPath := ShimFind("suse")
assert.Equal(t, path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/lib64/efi/shim.efi"), shimPath)
@@ -29,10 +27,10 @@ func Test_Find_ShimArch64(t *testing.T) {
testenv.New(t)
conf := warewulfconf.Get()
wwlog.SetLogLevel(wwlog.DEBUG)
os.MkdirAll(path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/aarch64"), 0755)
_ = os.MkdirAll(path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/aarch64"), 0755)
shimF, err := os.Create(path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/aarch64/shim.efi"))
assert.NoError(t, err)
shimF.WriteString("shim.efi")
_, _ = shimF.WriteString("shim.efi")
assert.FileExists(t, path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/aarch64/shim.efi"))
shimPath := ShimFind("suse")
assert.Equal(t, path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/aarch64/shim.efi"), shimPath)
@@ -41,10 +39,10 @@ func Test_Find_GrubX86(t *testing.T) {
testenv.New(t)
conf := warewulfconf.Get()
wwlog.SetLogLevel(wwlog.DEBUG)
os.MkdirAll(path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/x86_64"), 0755)
_ = os.MkdirAll(path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/x86_64"), 0755)
shimF, err := os.Create(path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/x86_64/grub.efi"))
assert.NoError(t, err)
shimF.WriteString("grub.efi")
_, _ = shimF.WriteString("grub.efi")
assert.FileExists(t, path.Join(conf.Paths.WWChrootdir, "suse/rootfs//usr/share/efi/x86_64/grub.efi"))
shimPath := GrubFind("suse")
assert.Equal(t, path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/x86_64/grub.efi"), shimPath)
@@ -53,11 +51,11 @@ func Test_Find_GrubAarch64(t *testing.T) {
testenv.New(t)
conf := warewulfconf.Get()
wwlog.SetLogLevel(wwlog.DEBUG)
os.MkdirAll(path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/aarch64/"), 0755)
_ = os.MkdirAll(path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/aarch64/"), 0755)
shimF, err := os.Create(path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/aarch64/grub.efi"))
assert.NoError(t, err)
shimF.WriteString("grub.efi")
assert.FileExists(t, path.Join(conf.Paths.WWChrootdir, "suse/usr/share/efi/aarch64/grub.efi"))
_, _ = shimF.WriteString("grub.efi")
assert.FileExists(t, path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/aarch64/grub.efi"))
shimPath := GrubFind("suse")
assert.Equal(t, path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/aarch64//grub.efi"), shimPath)
assert.Equal(t, path.Join(conf.Paths.WWChrootdir, "suse/rootfs/usr/share/efi/aarch64/grub.efi"), shimPath)
}