| 39 | RLIMIT_AS_PATTERN = re.compile(r"//\s+RLIMIT_AS:\s*(\d+)") |
| 40 | |
| 41 | class SimpleTestCase(test.TestCase): |
| 42 | |
| 43 | def __init__(self, path, file, arch, mode, context, config, additional=None): |
| 44 | super(SimpleTestCase, self).__init__(context, path, arch, mode) |
| 45 | self.file = file |
| 46 | self.config = config |
| 47 | self.arch = arch |
| 48 | self.mode = mode |
| 49 | if additional is not None: |
| 50 | self.additional_flags = additional |
| 51 | else: |
| 52 | self.additional_flags = [] |
| 53 | |
| 54 | def _parse_source_env(self, source): |
| 55 | env_match = ENV_PATTERN.search(source) |
| 56 | env = {} |
| 57 | if env_match: |
| 58 | for env_pair in env_match.group(1).strip().split(): |
| 59 | var, value = env_pair.split('=') |
| 60 | env[var] = value |
| 61 | return env |
| 62 | |
| 63 | def GetLabel(self): |
| 64 | return "%s %s" % (self.mode, self.GetName()) |
| 65 | |
| 66 | def GetName(self): |
| 67 | return self.path[-1] |
| 68 | |
| 69 | def GetRunConfiguration(self): |
| 70 | result = [self.config.context.GetVm(self.arch, self.mode)] |
| 71 | source = open(self.file, encoding='utf8').read() |
| 72 | flags_match = FLAGS_PATTERN.search(source) |
| 73 | envs = self._parse_source_env(source) |
| 74 | if flags_match: |
| 75 | flags = flags_match.group(1).strip().split() |
| 76 | # The following block reads config.gypi to extract the v8_enable_inspector |
| 77 | # value. This is done to check if the inspector is disabled in which case |
| 78 | # the '--inspect' flag cannot be passed to the node process as it will |
| 79 | # cause node to exit and report the test as failed. The use case |
| 80 | # is currently when Node is configured --without-ssl and the tests should |
| 81 | # still be runnable but skip any tests that require ssl (which includes the |
| 82 | # inspector related tests). Also, if there is no ssl support the options |
| 83 | # '--use-bundled-ca', '--use-system-ca' and '--use-openssl-ca' will also |
| 84 | # cause a similar failure so such tests are also skipped. |
| 85 | if (any(flag.startswith('--inspect') for flag in flags) and |
| 86 | not self.context.v8_enable_inspector): |
| 87 | print(': Skipping as node was compiled without inspector support') |
| 88 | elif (('--use-bundled-ca' in flags or |
| 89 | '--use-openssl-ca' in flags or |
| 90 | '--use-system-ca' in flags or |
| 91 | '--no-use-bundled-ca' in flags or |
| 92 | '--no-use-openssl-ca' in flags or |
| 93 | '--no-use-system-ca' in flags or |
| 94 | '--tls-v1.0' in flags or |
| 95 | '--tls-v1.1' in flags) and |
| 96 | not self.context.node_has_crypto): |
| 97 | # TODO(joyeecheung): add this to the status file variables so that we can |
| 98 | # list the crypto dependency in the status files explicitly instead. |