build: add test build target.

This commit is contained in:
Alexandre Pujol 2025-09-14 15:24:49 +02:00
parent b471f8359a
commit d9ff4aecd7
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
4 changed files with 21 additions and 0 deletions

View file

@ -37,6 +37,7 @@ Options:
-s, --server Set AppArmor for server.
-b, --buildir DIR Root build directory.
-F, --file Only prebuild a given file.
--test Enable test mode.
--debug Enable debug mode.
`
)
@ -48,6 +49,7 @@ var (
full bool
server bool
debug bool
test bool
abi int
version float64
file string
@ -74,6 +76,7 @@ func init() {
flag.StringVar(&buildir, "b", "", "Root build directory.")
flag.StringVar(&buildir, "buildir", "", "Root build directory.")
flag.BoolVar(&debug, "debug", false, "Enable debug mode.")
flag.BoolVar(&test, "test", false, "Enable test mode.")
}
func Configure() {
@ -118,6 +121,9 @@ func Configure() {
if debug {
builder.Register("debug")
}
if test {
prebuild.Test = true
}
} else if enforce {
builder.Register("enforce")
}

View file

@ -43,6 +43,10 @@ func filterRuleForUs(opt *Option) bool {
return true
}
if prebuild.Test && slices.Contains(opt.ArgList, "test") {
return true
}
abiStr := fmt.Sprintf("abi%d", prebuild.ABI)
if slices.Contains(opt.ArgList, abiStr) {
return true

View file

@ -19,6 +19,9 @@ var (
// Either or not RBAC is enabled
RBAC = false
// Either or not we are in test mode
Test = false
// Pkgname is the name of the package
Pkgname = "apparmor.d"