internal/outcome: integrate pipewire server
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m37s
Test / Sandbox (race detector) (push) Successful in 4m37s
Test / Hakurei (push) Successful in 4m47s
Test / Hpkg (push) Successful in 4m57s
Test / Hakurei (race detector) (push) Successful in 6m23s
Test / Flake checks (push) Successful in 1m31s
All checks were successful
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 2m37s
Test / Sandbox (race detector) (push) Successful in 4m37s
Test / Hakurei (push) Successful in 4m47s
Test / Hpkg (push) Successful in 4m57s
Test / Hakurei (race detector) (push) Successful in 6m23s
Test / Flake checks (push) Successful in 1m31s
This is very simple and takes almost no inputs. This is not yet hooked up to anything to prevent breaking any existing behaviour. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
5785714b64
commit
c8eeb4a4d1
31
internal/outcome/sppipewire.go
Normal file
31
internal/outcome/sppipewire.go
Normal file
@ -0,0 +1,31 @@
|
||||
package outcome
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
|
||||
"hakurei.app/hst"
|
||||
"hakurei.app/internal/pipewire"
|
||||
)
|
||||
|
||||
func init() { gob.Register(spPipeWireOp{}) }
|
||||
|
||||
// spPipeWireOp exports the PipeWire server to the container via SecurityContext.
|
||||
// Runs after spRuntimeOp.
|
||||
type spPipeWireOp struct{}
|
||||
|
||||
func (s spPipeWireOp) toSystem(state *outcomeStateSys) error {
|
||||
if state.et&hst.EPipeWire == 0 {
|
||||
return errNotEnabled
|
||||
}
|
||||
|
||||
state.sys.PipeWire(state.instance().Append("pipewire"))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s spPipeWireOp) toContainer(state *outcomeStateParams) error {
|
||||
innerPath := state.runtimeDir.Append(pipewire.PW_DEFAULT_REMOTE)
|
||||
state.env[pipewire.Remote] = innerPath.String()
|
||||
state.params.Bind(state.instancePath().Append("pipewire"), innerPath, 0)
|
||||
|
||||
return nil
|
||||
}
|
||||
43
internal/outcome/sppipewire_test.go
Normal file
43
internal/outcome/sppipewire_test.go
Normal file
@ -0,0 +1,43 @@
|
||||
package outcome
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"hakurei.app/container"
|
||||
"hakurei.app/container/stub"
|
||||
"hakurei.app/hst"
|
||||
"hakurei.app/internal/pipewire"
|
||||
"hakurei.app/internal/system"
|
||||
)
|
||||
|
||||
func TestSpPipeWireOp(t *testing.T) {
|
||||
t.Parallel()
|
||||
config := hst.Template()
|
||||
|
||||
checkOpBehaviour(t, []opBehaviourTestCase{
|
||||
{"not enabled", func(bool, bool) outcomeOp {
|
||||
return spPipeWireOp{}
|
||||
}, func() *hst.Config {
|
||||
c := hst.Template()
|
||||
*c.Enablements = 0
|
||||
return c
|
||||
}, nil, nil, nil, nil, errNotEnabled, nil, nil, nil, nil, nil},
|
||||
|
||||
{"success", func(bool, bool) outcomeOp {
|
||||
return spPipeWireOp{}
|
||||
}, hst.Template, nil, []stub.Call{}, newI().
|
||||
// state.instance
|
||||
Ephemeral(system.Process, m(wantInstancePrefix), 0711).
|
||||
// toSystem
|
||||
PipeWire(
|
||||
m(wantInstancePrefix + "/pipewire"),
|
||||
), sysUsesInstance(nil), nil, insertsOps(afterSpRuntimeOp(nil)), []stub.Call{
|
||||
// this op configures the container state and does not make calls during toContainer
|
||||
}, &container.Params{
|
||||
Ops: new(container.Ops).
|
||||
Bind(m(wantInstancePrefix+"/pipewire"), m("/run/user/1000/pipewire-0"), 0),
|
||||
}, paramsWantEnv(config, map[string]string{
|
||||
pipewire.Remote: "/run/user/1000/pipewire-0",
|
||||
}, nil), nil},
|
||||
})
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user