From e99d7affb0c128fa82722f9b3d79c99b5e5918cd Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 11 Aug 2025 02:52:32 +0900 Subject: 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 --- container/init_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'container/init_test.go') 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...) } -- cgit v1.3.1