Files
o3de/scripts/ctest/ctest_driver_test.py
T
Esteban Papp 1c13b301fe SPEC-5070 Move ctest_scripts to scripts/ctest
* removing unused function and moving ctest_scripts to scripts/ctest

* Re-adding ebp-test

* Fixing typo that is making this test run in parallel with other tests

* Fixing hang when parameters are passed

* passing absolute path as a project

* small tweak to not print out during Python execution

* Moving the timeout to be in the build step

* Disable ebo_sanity_smoke_no_gpu

Co-authored-by: jackalbe <23512001+jackalbe@users.noreply.github.com>
2021-04-23 09:43:11 -07:00

88 lines
3.6 KiB
Python
Executable File

"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Self-tests for ctest_driver.py.
Expects you to have generated a folder using cmake and to pass in that folder name
as the only param
"""
import os
import subprocess
import sys
import argparse
from ctest_driver import SUITES_AND_DESCRIPTIONS
def main(build_path, ctest_executable):
script_folder = os.path.dirname(__file__)
# -N prevents tests from running, just lists them:
base_args = [sys.executable, os.path.join(script_folder,'ctest_driver.py'), "--build-path", build_path, '-N']
if ctest_executable:
base_args.append("--ctest-executable")
base_args.append(ctest_executable)
base_args.append("-R") # limit it to only the sanity tests, faster
base_args.append("pytest_sanity_.*")
for suite in SUITES_AND_DESCRIPTIONS:
for gpu_option in [None, True, False]:
args_to_send = base_args.copy()
args_to_send.append("--suite")
args_to_send.append(suite)
print(f"----- Test case: [suite = {suite}, gpu = {gpu_option}] ----")
if gpu_option is not None:
if gpu_option:
args_to_send.append("--only-gpu")
else:
args_to_send.append("--no-gpu")
result = subprocess.check_output(args_to_send, shell=False, cwd=build_path, stderr=sys.stderr)
output = result.decode('utf-8')
# ensure that the appropriate suites are filtered in and out
for suite_name in SUITES_AND_DESCRIPTIONS.keys():
if (f"pytest_sanity_{suite_name}_" in output and suite != suite_name):
print(output)
print("Test failed - executed a test not in the currently selected suite.")
return -1
gpu_test_present = "_requires_gpu" in output
non_gpu_test_present = "_no_gpu" in output
if gpu_option is not None:
if gpu_option and non_gpu_test_present:
print("Test failed - required gpu only, and a non-gpu tes was run")
print(output)
return -1
if not gpu_option and gpu_test_present:
print("Test failed - executed a gpu test when forbidden")
print(output)
return -1
else:
if not (gpu_test_present and non_gpu_test_present):
print("Test failed - expected both kinds of tests (gpu and non gpu)")
print(output)
return -1
print("All passed.")
return 0
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="CTest CLI driver self-tests.")
parser.add_argument('-x', '--ctest-executable',
help="Override path to the CTest executable (will use PATH env otherwise)")
parser.add_argument('-b', '--build-path',
required=True,
help="Path to a CMake build folder (generated by running cmake)")
args = parser.parse_args()
sys.exit(main(args.build_path, args.ctest_executable))