blob: bc694ba208e9cec34f82c50d81987ac9af6dfb10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package syscallcompat
import (
"bytes"
"os"
"syscall"
"testing"
)
func TestReadlinkat(t *testing.T) {
for _, targetLen := range []int{100, 500, 4000} {
target := string(bytes.Repeat([]byte("x"), targetLen))
err := os.Symlink(target, tmpDir+"/readlinkat")
if err != nil {
t.Fatal(err)
}
target2, err := Readlinkat(tmpDirFd, "readlinkat")
if err != nil {
t.Fatal(err)
}
if target != target2 {
t.Errorf("target=%q != target2=%q", target, target2)
}
err = syscall.Unlink(tmpDir + "/readlinkat")
if err != nil {
t.Fatal(err)
}
}
}
|