2023-04-19 18:40:40 +02:00
|
|
|
// apparmor.d - Full set of apparmor profiles
|
2024-02-07 00:16:21 +01:00
|
|
|
// Copyright (C) 2023-2024 Alexandre Pujol <alexandre@pujol.io>
|
2023-04-19 18:40:40 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"testing"
|
2023-05-06 14:01:07 +02:00
|
|
|
|
2024-10-02 17:22:46 +02:00
|
|
|
"github.com/roddhjav/apparmor.d/pkg/prebuild"
|
2023-04-19 18:40:40 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func chdirGitRoot() {
|
|
|
|
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
|
|
|
|
out, err := cmd.Output()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2024-05-30 21:10:45 +02:00
|
|
|
root := string(out[0 : len(out)-1])
|
2023-04-19 18:40:40 +02:00
|
|
|
if err := os.Chdir(root); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-02 17:22:46 +02:00
|
|
|
func Test_main(t *testing.T) {
|
2023-04-19 18:40:40 +02:00
|
|
|
tests := []struct {
|
2024-10-02 17:22:46 +02:00
|
|
|
name string
|
|
|
|
dist string
|
2023-04-19 18:40:40 +02:00
|
|
|
}{
|
|
|
|
{
|
2024-10-02 17:22:46 +02:00
|
|
|
name: "Build for Archlinux",
|
|
|
|
dist: "arch",
|
2023-04-19 18:40:40 +02:00
|
|
|
},
|
|
|
|
{
|
2024-10-02 17:22:46 +02:00
|
|
|
name: "Build for Ubuntu",
|
|
|
|
dist: "ubuntu",
|
2023-04-19 18:40:40 +02:00
|
|
|
},
|
|
|
|
{
|
2024-10-02 17:22:46 +02:00
|
|
|
name: "Build for Debian",
|
|
|
|
dist: "debian",
|
2023-04-19 18:40:40 +02:00
|
|
|
},
|
|
|
|
{
|
2024-10-02 17:22:46 +02:00
|
|
|
name: "Build for OpenSUSE Tumbleweed",
|
|
|
|
dist: "opensuse",
|
2023-04-19 18:40:40 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
chdirGitRoot()
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2024-10-02 17:22:46 +02:00
|
|
|
prebuild.Distribution = tt.dist
|
|
|
|
main()
|
2023-04-19 18:40:40 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|