Skip to content

Commit b0c0dee

Browse files
committed
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. Fixes: issue 14746
1 parent c3ae57f commit b0c0dee

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tools/test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,9 @@ def BuildOptions():
14271427
result.add_option('--abort-on-timeout',
14281428
help='Send SIGABRT instead of SIGTERM to kill processes that time out',
14291429
default=False, action="store_true", dest="abort_on_timeout")
1430+
result.add_option("--type",
1431+
help="Type of build (simple, fips)",
1432+
default=None)
14301433
return result
14311434

14321435

@@ -1576,6 +1579,21 @@ def ArgsToTestPaths(test_root, args, suites):
15761579
return paths
15771580

15781581

1582+
def get_env_type(vm, options_type):
1583+
if options_type is not None:
1584+
env_type = options_type
1585+
else:
1586+
if "fips" in subprocess.check_output([vm, "-p",
1587+
"process.versions.openssl"]):
1588+
env_type = "fips"
1589+
# NOTE(nikhil): "simple" is the default value for var 'env_type' and should
1590+
# be set last if no if/elif matches. If you plan to add more values, use
1591+
# 'elif' above.
1592+
else:
1593+
env_type = "simple"
1594+
return env_type
1595+
1596+
15791597
def Main():
15801598
parser = BuildOptions()
15811599
(options, args) = parser.parse_args()
@@ -1659,6 +1677,7 @@ def Main():
16591677
'mode': mode,
16601678
'system': utils.GuessOS(),
16611679
'arch': vmArch,
1680+
'type': get_env_type(vm, options.type),
16621681
}
16631682
test_list = root.ListTests([], path, context, arch, mode)
16641683
unclassified_tests += test_list

0 commit comments

Comments
 (0)