aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'internal/testsuite')
-rw-r--r--internal/testsuite/testsuite.go31
1 files changed, 21 insertions, 10 deletions
diff --git a/internal/testsuite/testsuite.go b/internal/testsuite/testsuite.go
index 0b7594ba..aada7721 100644
--- a/internal/testsuite/testsuite.go
+++ b/internal/testsuite/testsuite.go
@@ -716,6 +716,17 @@ func LookupStore(cred *syscall.Credential, id hst.ID, p *hst.State) error {
return <-done
}
+const (
+ // SHScan enables startup notification and proc scanning for [StartHakurei].
+ SHScan = 1 << iota
+ // SHWait blocks [StartHakurei] on notify pipe.
+ SHWait
+ // SHVerbose enables hakurei verbose output in [StartHakurei].
+ SHVerbose
+ // SHInsecure enables insecure configuration in [StartHakurei].
+ SHInsecure
+)
+
// StartHakurei starts a hakurei container configured by c.
func StartHakurei(
ctx context.Context,
@@ -724,19 +735,19 @@ func StartHakurei(
dbusEnv string,
processCommand func(cmd *exec.Cmd),
onDone func(err error, output string),
- scan, wait, verbose, insecure bool,
+ flags int,
c *hst.Config,
) (p hst.State, pid int, err error) {
var hakureiFlags string
- if verbose {
+ if flags&SHVerbose != 0 {
hakureiFlags += " -v"
}
- if insecure {
+ if flags&SHInsecure != 0 {
hakureiFlags += " --insecure"
}
var notifySuffix string
- if wait {
+ if flags&SHWait != 0 {
notifySuffix += " 1>&3"
}
@@ -796,7 +807,7 @@ func StartHakurei(
return
}
- if !scan && len(cmd.ExtraFiles) != 3 {
+ if flags&SHScan == 0 && len(cmd.ExtraFiles) != 3 {
err = errors.Join(notify.Close(), ident.Close())
return
}
@@ -804,7 +815,7 @@ func StartHakurei(
var id hst.ID
if _, err = io.ReadFull(ident, id[:]); err != nil {
_, _ = notify.Close(), ident.Close()
- if !scan && errors.Is(err, io.EOF) {
+ if flags&SHScan == 0 && errors.Is(err, io.EOF) {
err = nil
}
return
@@ -813,12 +824,12 @@ func StartHakurei(
return
}
- if !scan {
+ if flags&SHScan == 0 {
err = notify.Close()
return
}
- if wait {
+ if flags&SHWait != 0 {
if _, err = io.ReadFull(notify, make([]byte, 8)); err != nil {
_ = notify.Close()
return
@@ -918,7 +929,7 @@ func MustStartHakurei(
cred *syscall.Credential,
dbusEnv string,
onDone func(err error, output string),
- scan, wait, verbose, insecure bool,
+ flags int,
c *hst.Config,
) (p hst.State, pid int) {
_ctx, cancel := context.WithCancel(ctx)
@@ -929,7 +940,7 @@ func MustStartHakurei(
nil, func(err error, output string) {
defer cancel()
onDone(err, output)
- }, scan, wait, verbose, insecure, c,
+ }, flags, c,
)
if err != nil {
log.Printf(