MCPcopy Index your code
hub / github.com/opencontainers/runc / TestLexicallyCleanPath

Function TestLexicallyCleanPath

internal/pathrs/path_test.go:55–85  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestLexicallyCleanPath(t *testing.T) {
56 path := LexicallyCleanPath("")
57 if path != "" {
58 t.Errorf("expected to receive empty string and received %s", path)
59 }
60
61 path = LexicallyCleanPath("rootfs")
62 if path != "rootfs" {
63 t.Errorf("expected to receive 'rootfs' and received %s", path)
64 }
65
66 path = LexicallyCleanPath("../../../var")
67 if path != "var" {
68 t.Errorf("expected to receive 'var' and received %s", path)
69 }
70
71 path = LexicallyCleanPath("/../../../var")
72 if path != "/var" {
73 t.Errorf("expected to receive '/var' and received %s", path)
74 }
75
76 path = LexicallyCleanPath("/foo/bar/")
77 if path != "/foo/bar" {
78 t.Errorf("expected to receive '/foo/bar' and received %s", path)
79 }
80
81 path = LexicallyCleanPath("/foo/bar/../")
82 if path != "/foo" {
83 t.Errorf("expected to receive '/foo' and received %s", path)
84 }
85}
86
87func TestLexicallyStripRoot(t *testing.T) {
88 for _, test := range []struct {

Callers

nothing calls this directly

Calls 1

LexicallyCleanPathFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…