mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-27 14:32:13 +00:00
Write failing test case for create-symlinks hook
Signed-off-by: Christopher Desiniotis <cdesiniotis@nvidia.com>
This commit is contained in:
parent
92779e71b3
commit
a04e3ac4f7
@ -108,6 +108,31 @@ func TestCreateLinkAlreadyExistsDifferentTarget(t *testing.T) {
|
||||
require.Equal(t, "different-target", target)
|
||||
}
|
||||
|
||||
func TestCreateLinkOutOfBounds(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
hostRoot := filepath.Join(tmpDir, "/host-root/")
|
||||
containerRoot := filepath.Join(tmpDir, "/container-root")
|
||||
|
||||
require.NoError(t, makeFs(hostRoot))
|
||||
require.NoError(t,
|
||||
makeFs(containerRoot,
|
||||
dirOrLink{path: "/lib"},
|
||||
dirOrLink{path: "/lib/foo", target: hostRoot},
|
||||
),
|
||||
)
|
||||
|
||||
path, err := symlinks.Resolve(filepath.Join(containerRoot, "/lib/foo"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, hostRoot, path)
|
||||
|
||||
// nvidia-cdi-hook create-symlinks --link ../libfoo.so.1::/lib/foo/libfoo.so
|
||||
_ = getTestCommand().createLink(containerRoot, "../libfoo.so.1", "/lib/foo/libfoo.so")
|
||||
// TODO: We need to enabled this check once we have updated the implementation.
|
||||
// require.Error(t, err)
|
||||
_, err = os.Lstat(filepath.Join(hostRoot, "libfoo.so"))
|
||||
require.ErrorIs(t, err, os.ErrNotExist)
|
||||
}
|
||||
|
||||
type dirOrLink struct {
|
||||
path string
|
||||
target string
|
||||
|
Loading…
Reference in New Issue
Block a user