ldd: lib paths resolve function
All checks were successful
Test / Create distribution (push) Successful in 24s
Test / Fortify (push) Successful in 2m37s
Test / Fpkg (push) Successful in 3m37s
Test / Data race detector (push) Successful in 3m50s
Test / Flake checks (push) Successful in 56s

This is what always happens right after a ldd call, so implement it here.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2025-03-16 01:20:09 +09:00
parent 891316d924
commit 273d97af85
4 changed files with 59 additions and 80 deletions

View File

@@ -7,8 +7,6 @@ import (
"log"
"os"
"os/exec"
"path"
"slices"
"syscall"
"testing"
"time"
@@ -94,23 +92,10 @@ func TestContainer(t *testing.T) {
}, os.Args[0]); err != nil {
log.Fatalf("ldd: %v", err)
} else {
libPathsM := make(map[string]struct{}, len(entries))
for _, ent := range entries {
if path.IsAbs(ent.Path) {
libPathsM[path.Dir(ent.Path)] = struct{}{}
}
if path.IsAbs(ent.Name) {
libPathsM[path.Dir(ent.Name)] = struct{}{}
}
}
libPaths = make([]string, 0, len(libPathsM))
for name := range libPathsM {
libPaths = append(libPaths, name)
}
slices.Sort(libPaths)
for _, name := range libPaths {
container.Bind(name, name, 0)
}
libPaths = ldd.Path(entries)
}
for _, name := range libPaths {
container.Bind(name, name, 0)
}
mnt := make([]*check.Mntent, 0, 3+len(libPaths))