f038dae646
From-SVN: r204466
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
// 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)
|
|
}
|
|
}
|