Bug 1072024 - Disable sandbox during gtests on linux - r=ted
authorEdwin Flores <eflores@mozilla.com>
Tue, 14 Oct 2014 11:04:59 +1300
changeset 210241 bdba7bcc32dcd68b647bfe997cdd0c917d347b00
parent 210240 282fb5ca6310148bfbbdd4e47220c0033f849e13
child 210242 7600cd87ae2091c4d599520bba48fa5e2dd6d5ae
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersted
bugs1072024
milestone35.0a1
Bug 1072024 - Disable sandbox during gtests on linux - r=ted
testing/gtest/rungtests.py
testing/mozbase/mozinfo/mozinfo/mozinfo.py
--- a/testing/gtest/rungtests.py
+++ b/testing/gtest/rungtests.py
@@ -69,16 +69,24 @@ class GTests(object):
         env["MOZ_XRE_DIR"] = self.xre_path
         env["MOZ_GMP_PATH"] = os.path.join(self.xre_path, "gmp-fake", "1.0")
         env["XPCOM_DEBUG_BREAK"] = "stack-and-abort"
         env["MOZ_CRASHREPORTER_NO_REPORT"] = "1"
         env["MOZ_CRASHREPORTER"] = "1"
         env["MOZ_RUN_GTEST"] = "1"
         # Normally we run with GTest default output, override this to use the TBPL test format.
         env["MOZ_TBPL_PARSER"] = "1"
+
+        if not mozinfo.has_sandbox:
+          # Bug 1082193 - This is horrible. Our linux build boxes run CentOS 6,
+          # which is too old to support sandboxing. Disable sandbox for gtests
+          # on machines which don't support sandboxing until they can be
+          # upgraded, or gtests are run on test machines instead.
+          env["MOZ_DISABLE_GMP_SANDBOX"] = "1"
+
         return env
 
     def build_environment(self):
         """
         Create and return a dictionary of all the appropriate env variables and values.
         On a remote system, we overload this to set different values and are missing things like os.environ and PATH.
         """
         if not os.path.isdir(self.xre_path):
--- a/testing/mozbase/mozinfo/mozinfo/mozinfo.py
+++ b/testing/mozbase/mozinfo/mozinfo/mozinfo.py
@@ -3,16 +3,18 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # TODO: it might be a good idea of adding a system name (e.g. 'Ubuntu' for
 # linux) to the information; I certainly wouldn't want anyone parsing this
 # information and having behaviour depend on it
 
+import ctypes
+import errno
 import json
 import os
 import platform
 import re
 import sys
 
 import mozfile
 
@@ -27,17 +29,18 @@ class unknown(object):
         return 'UNKNOWN'
 unknown = unknown() # singleton
 
 # get system information
 info = {'os': unknown,
         'processor': unknown,
         'version': unknown,
         'os_version': unknown,
-        'bits': unknown }
+        'bits': unknown,
+        'has_sandbox': unknown }
 (system, node, release, version, machine, processor) = platform.uname()
 (bits, linkage) = platform.architecture()
 
 # get os information and related data
 if system in ["Microsoft", "Windows"]:
     info['os'] = 'win'
     # There is a Python bug on Windows to determine platform values
     # http://bugs.python.org/issue7860
@@ -88,16 +91,24 @@ elif processor.upper() == "AMD64":
     processor = "x86_64"
 elif processor == "Power Macintosh":
     processor = "ppc"
 bits = re.search('(\d+)bit', bits).group(1)
 info.update({'processor': processor,
              'bits': int(bits),
             })
 
+if info['os'] == 'linux':
+    PR_SET_SECCOMP = 22
+    SECCOMP_MODE_FILTER = 2
+    ctypes.CDLL("libc.so.6", use_errno=True).prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, 0)
+    info['has_sandbox'] = ctypes.get_errno() == errno.EFAULT
+else:
+    info['has_sandbox'] = True
+
 # standard value of choices, for easy inspection
 choices = {'os': ['linux', 'bsd', 'win', 'mac', 'unix'],
            'bits': [32, 64],
            'processor': ['x86', 'x86_64', 'ppc']}
 
 
 def sanitize(info):
     """Do some sanitization of input values, primarily