aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/exec_linux_test.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2015-06-13 13:46:10 -0700
committerIan Lance Taylor <iant@golang.org>2015-06-14 01:52:54 +0000
commit6b24da6ae8321387e9dd02181ccf5b425d4c05f9 (patch)
treec91379aa9dfb6ab72d0f209ea164e9d31f9350b9 /src/syscall/exec_linux_test.go
parenta84ac5b507f5d895ca2ee300275beb73d2327f99 (diff)
downloadgo-6b24da6ae8321387e9dd02181ccf5b425d4c05f9.tar.gz
go-6b24da6ae8321387e9dd02181ccf5b425d4c05f9.zip
syscall: skip TestCloneNEWUSERAndRemapNoRootDisableSetgroups before 3.19
The test fails on Ubuntu Trusty for some reason, probably because of some set of kernel patches. Change-Id: I52f7ca50b96fea5725817c9e9198860d419f9313 Reviewed-on: https://go-review.googlesource.com/11055 Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Diffstat (limited to 'src/syscall/exec_linux_test.go')
-rw-r--r--src/syscall/exec_linux_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/syscall/exec_linux_test.go b/src/syscall/exec_linux_test.go
index a39fd58c1f..af5ae654fb 100644
--- a/src/syscall/exec_linux_test.go
+++ b/src/syscall/exec_linux_test.go
@@ -7,8 +7,11 @@
package syscall_test
import (
+ "io/ioutil"
"os"
"os/exec"
+ "regexp"
+ "strconv"
"strings"
"syscall"
"testing"
@@ -62,10 +65,33 @@ func TestCloneNEWUSERAndRemapRootEnableSetgroups(t *testing.T) {
testNEWUSERRemap(t, 0, false)
}
+// kernelVersion returns the major and minor versions of the Linux
+// kernel version. It calls t.Skip if it can't figure it out.
+func kernelVersion(t *testing.T) (int, int) {
+ bytes, err := ioutil.ReadFile("/proc/version")
+ if err != nil {
+ t.Skipf("can't get kernel version: %v", err)
+ }
+ matches := regexp.MustCompile("([0-9]+).([0-9]+)").FindSubmatch(bytes)
+ if len(matches) < 3 {
+ t.Skipf("can't get kernel version from %s", bytes)
+ }
+ major, _ := strconv.Atoi(string(matches[1]))
+ minor, _ := strconv.Atoi(string(matches[2]))
+ return major, minor
+}
+
func TestCloneNEWUSERAndRemapNoRootDisableSetgroups(t *testing.T) {
if os.Getuid() == 0 {
t.Skip("skipping unprivileged user only test")
}
+
+ // This test fails for some reason on Ubuntu Trusty.
+ major, minor := kernelVersion(t)
+ if major < 3 || (major == 3 && minor < 19) {
+ t.Skipf("skipping on kernel version before 3.19 (%d.%d)", major, minor)
+ }
+
testNEWUSERRemap(t, os.Getuid(), false)
}