fix: profile compilation.

This commit is contained in:
Alexandre Pujol 2024-06-15 22:28:37 +01:00
parent da3717991e
commit a2c6580725
Failed to generate hash of commit
2 changed files with 10 additions and 2 deletions

View file

@ -67,4 +67,4 @@
@{user_torrents_dirs}=@{HOME}/@{XDG_TORRENTS_DIR} @{MOUNTS}/@{XDG_TORRENTS_DIR} @{user_torrents_dirs}=@{HOME}/@{XDG_TORRENTS_DIR} @{MOUNTS}/@{XDG_TORRENTS_DIR}
@{user_vm_dirs}=@{HOME}/@{XDG_VM_DIR} @{MOUNTS}/@{XDG_VM_DIR} @{user_vm_dirs}=@{HOME}/@{XDG_VM_DIR} @{MOUNTS}/@{XDG_VM_DIR}
# vim:syntax=apparmor # vim:syntax=apparmor

View file

@ -6,6 +6,7 @@ package aa
import ( import (
"reflect" "reflect"
"strings"
"testing" "testing"
"github.com/roddhjav/apparmor.d/pkg/paths" "github.com/roddhjav/apparmor.d/pkg/paths"
@ -17,6 +18,13 @@ var (
intData = paths.New("../../apparmor.d") intData = paths.New("../../apparmor.d")
) )
// mustReadProfileFile read a file and return its content as a slice of string.
// It panics if an error occurs. It removes the last comment line.
func mustReadProfileFile(path *paths.Path) string {
res := strings.Split(util.MustReadFile(path), "\n")
return strings.Join(res[:len(res)-2], "\n")
}
func TestAppArmorProfileFile_String(t *testing.T) { func TestAppArmorProfileFile_String(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
@ -230,7 +238,7 @@ func TestAppArmorProfileFile_Integration(t *testing.T) {
}, },
}}, }},
}, },
want: util.MustReadFile(intData.Join("profiles-a-f/aa-status")), want: mustReadProfileFile(intData.Join("profiles-a-f/aa-status")),
}, },
} }
for _, tt := range tests { for _, tt := range tests {