apparmor.d/cmd/prebuild/main_test.go
Alexandre Pujol 59ac54e2fc
build: reorganise build: abi4, fallback, prebuild cli
- ABI4 by default, fallback to abi 3.
- aa-prebuild cli that can be used by other project shipping profiles.
- --file option to cli to only build one dev profile.
- add abi version filter to only & exclude directives.
2024-10-02 16:22:46 +01:00

57 lines
959 B
Go

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