aboutsummaryrefslogtreecommitdiff
path: root/internal/syscallcompat/sys_common_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/syscallcompat/sys_common_test.go')
-rw-r--r--internal/syscallcompat/sys_common_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/syscallcompat/sys_common_test.go b/internal/syscallcompat/sys_common_test.go
new file mode 100644
index 0000000..bc694ba
--- /dev/null
+++ b/internal/syscallcompat/sys_common_test.go
@@ -0,0 +1,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)
+ }
+ }
+}