diff options
Diffstat (limited to 'libgo/go/syscall/rlimit_linux_test.go')
-rw-r--r-- | libgo/go/syscall/rlimit_linux_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libgo/go/syscall/rlimit_linux_test.go b/libgo/go/syscall/rlimit_linux_test.go new file mode 100644 index 00000000000..4ec720e9360 --- /dev/null +++ b/libgo/go/syscall/rlimit_linux_test.go @@ -0,0 +1,41 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package syscall_test + +import ( + "syscall" + "testing" +) + +func TestRlimit(t *testing.T) { + var rlimit, zero syscall.Rlimit + err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlimit) + if err != nil { + t.Fatalf("Getrlimit: save failed: %v", err) + } + if zero == rlimit { + t.Fatalf("Getrlimit: save failed: got zero value %#v", rlimit) + } + set := rlimit + set.Cur = set.Max - 1 + err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &set) + if err != nil { + t.Fatalf("Setrlimit: set failed: %#v %v", set, err) + } + var get syscall.Rlimit + err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &get) + if err != nil { + t.Fatalf("Getrlimit: get failed: %v", err) + } + set = rlimit + set.Cur = set.Max - 1 + if set != get { + t.Fatalf("Rlimit: change failed: wanted %#v got %#v", set, get) + } + err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlimit) + if err != nil { + t.Fatalf("Setrlimit: restore failed: %#v %v", rlimit, err) + } +} |