aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/init_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-11 02:52:32 +0900
committerOphestra <cat@gensokyo.uk>2025-08-11 04:56:42 +0900
commite99d7affb0c128fa82722f9b3d79c99b5e5918cd (patch)
tree387e08d6c4363d8b9e0462f069c140fbdb15c917 /container/init_test.go
parent41ac2be9658b49c68cb793f3a6f0c5932d82e1c2 (diff)
container: use absolute for pathname
This is simultaneously more efficient and less error-prone. This change caused minor API changes in multiple other packages. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'container/init_test.go')
-rw-r--r--container/init_test.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/container/init_test.go b/container/init_test.go
index 7716458c..9e6832d1 100644
--- a/container/init_test.go
+++ b/container/init_test.go
@@ -21,6 +21,10 @@ const (
helperInnerPath = "/usr/bin/helper"
)
+var (
+ absHelperInnerPath = container.MustAbs(helperInnerPath)
+)
+
var helperCommands []func(c command.Command)
func TestMain(m *testing.M) {
@@ -46,10 +50,10 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}
-func helperNewContainerLibPaths(ctx context.Context, libPaths *[]string, args ...string) (c *container.Container) {
- c = container.NewCommand(ctx, helperInnerPath, "helper", args...)
+func helperNewContainerLibPaths(ctx context.Context, libPaths *[]*container.Absolute, args ...string) (c *container.Container) {
+ c = container.NewCommand(ctx, absHelperInnerPath, "helper", args...)
c.Env = append(c.Env, envDoCheck+"=1")
- c.Bind(os.Args[0], helperInnerPath, 0)
+ c.Bind(container.MustAbs(os.Args[0]), absHelperInnerPath, 0)
// in case test has cgo enabled
if entries, err := ldd.Exec(ctx, os.Args[0]); err != nil {
@@ -65,5 +69,5 @@ func helperNewContainerLibPaths(ctx context.Context, libPaths *[]string, args ..
}
func helperNewContainer(ctx context.Context, args ...string) (c *container.Container) {
- return helperNewContainerLibPaths(ctx, new([]string), args...)
+ return helperNewContainerLibPaths(ctx, new([]*container.Absolute), args...)
}