Skip to content

Commit afdfc4d

Browse files
komawarMylesBorins
authored andcommitted
test: Enable specifying flaky tests on fips
Adds a way to mark a specified test as 'flaky' on fips compliant systems. Earlier, the ``tools/test.py`` script supported only 'mode', 'system' and 'arch' for test environment specification. This limits the ability to specify the behavior of tests and setting pre-determined behavior of the same on other types of systems. As an example, the feature request below indicates the need to specify certain tests as 'flaky' on fips compliant systems. It hints at future possibility of a shared library, which in turn may need a specifier for running tests. This commit introduces a new item in the ``env`` dict, called ``type`` which defaults to ``simple`` type. It also adds an optional command line argument ``--type``, which inputs strings. Current functionality extends to setting ``simple`` or ``fips`` for this ``type`` variable. However, extending it to further uses is rather simple by adding "if" conditions at appropriate places in the ``tools/test.py`` script. PR-URL: #16329 Fixes: #14746 Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent b7f81ae commit afdfc4d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tools/test.py

+19
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,9 @@ def BuildOptions():
14101410
result.add_option('--abort-on-timeout',
14111411
help='Send SIGABRT instead of SIGTERM to kill processes that time out',
14121412
default=False, action="store_true", dest="abort_on_timeout")
1413+
result.add_option("--type",
1414+
help="Type of build (simple, fips)",
1415+
default=None)
14131416
return result
14141417

14151418

@@ -1559,6 +1562,21 @@ def ArgsToTestPaths(test_root, args, suites):
15591562
return paths
15601563

15611564

1565+
def get_env_type(vm, options_type):
1566+
if options_type is not None:
1567+
env_type = options_type
1568+
else:
1569+
if "fips" in subprocess.check_output([vm, "-p",
1570+
"process.versions.openssl"]):
1571+
env_type = "fips"
1572+
# NOTE(nikhil): "simple" is the default value for var 'env_type' and should
1573+
# be set last if no if/elif matches. If you plan to add more values, use
1574+
# 'elif' above.
1575+
else:
1576+
env_type = "simple"
1577+
return env_type
1578+
1579+
15621580
def Main():
15631581
parser = BuildOptions()
15641582
(options, args) = parser.parse_args()
@@ -1641,6 +1659,7 @@ def Main():
16411659
'mode': mode,
16421660
'system': utils.GuessOS(),
16431661
'arch': vmArch,
1662+
'type': get_env_type(vm, options.type),
16441663
}
16451664
test_list = root.ListTests([], path, context, arch, mode)
16461665
unclassified_tests += test_list

0 commit comments

Comments
 (0)