TensorRT-LLMs/scripts/check_test_list.py
Emma Qiao 6f626af386
[TRTLLM-4535][infra]: Add marker TIMEOUT for test level (#3905)
* Add marker for TIMEOUT

Signed-off-by: qqiao <qqiao@nvidia.com>

* Remove workspace after tests

Signed-off-by: qqiao <qqiao@nvidia.com>

* Add missed property

Signed-off-by: qqiao <qqiao@nvidia.com>

* Add some debug info

Signed-off-by: qqiao <qqiao@nvidia.com>

* Fix errors

Signed-off-by: qqiao <qqiao@nvidia.com>

* Testing

Signed-off-by: qqiao <qqiao@nvidia.com>

* Special process for unittests

Signed-off-by: qqiao <qqiao@nvidia.com>

* Move special proecessing unittests to test generating stage

Signed-off-by: qqiao <qqiao@nvidia.com>

* Process for the whole test list

Signed-off-by: qqiao <qqiao@nvidia.com>

* Test more

Signed-off-by: qqiao <qqiao@nvidia.com>

* Add another test case

Signed-off-by: qqiao <qqiao@nvidia.com>

* Change back the setting for testing

Signed-off-by: qqiao <qqiao@nvidia.com>

* Revert another config file

Signed-off-by: qqiao <qqiao@nvidia.com>

* Add descriptionf or timeout in test readme

Signed-off-by: qqiao <qqiao@nvidia.com>

---------

Signed-off-by: qqiao <qqiao@nvidia.com>
2025-05-25 23:30:40 -07:00

94 lines
3.0 KiB
Python

import argparse
import os
import subprocess
def install_python_dependencies(llm_src):
subprocess.run(
f"cd {llm_src} && pip3 install --retries 1 -r requirements-dev.txt",
shell=True,
check=True)
subprocess.run(
f"pip3 install --force-reinstall --no-deps {llm_src}/../tensorrt_llm-*.whl",
shell=True,
check=True)
subprocess.run(
"pip3 install --extra-index-url https://urm.nvidia.com/artifactory/api/pypi/sw-tensorrt-pypi/simple "
"--ignore-installed trt-test-db==1.8.5+bc6df7",
shell=True,
check=True)
def verify_l0_test_lists(llm_src):
test_db_path = f"{llm_src}/tests/integration/test_lists/test-db"
test_list = f"{llm_src}/l0_test.txt"
# Remove dynamically generated perf tests
subprocess.run(f"rm -f {test_db_path}/*perf*", shell=True, check=True)
subprocess.run(
f"trt-test-db -d {test_db_path} --test-names --output {test_list}",
shell=True,
check=True)
# Remove the duplicated test names
cleaned_lines = set()
with open(test_list, "r") as f:
lines = f.readlines()
for line in lines:
# Remove 'TIMEOUT (number)' and strip spaces
cleaned_line = line.split(" TIMEOUT ", 1)[0].strip()
cleaned_lines.add(cleaned_line)
with open(test_list, "w") as f:
f.writelines(f"{line}\n" for line in sorted(cleaned_lines))
subprocess.run(
f"cd {llm_src}/tests/integration/defs && "
f"pytest --apply-test-list-correction --test-list={test_list} --co -q",
shell=True,
check=True)
def verify_qa_test_lists(llm_src):
test_qa_path = f"{llm_src}/tests/integration/test_lists/qa"
# Remove dynamically generated perf tests
subprocess.run(f"rm -f {test_qa_path}/*perf*", shell=True, check=True)
test_def_files = subprocess.check_output(
f"ls -d {test_qa_path}/*.txt", shell=True).decode().strip().split('\n')
for test_def_file in test_def_files:
subprocess.run(
f"cd {llm_src}/tests/integration/defs && "
f"pytest --apply-test-list-correction --test-list={test_def_file} --co -q",
shell=True,
check=True)
def main():
parser = argparse.ArgumentParser(
description="Check test lists for L0 and QA.")
parser.add_argument("--l0",
action="store_true",
help="Enable L0 test list verification.")
parser.add_argument("--qa",
action="store_true",
help="Enable QA test list verification.")
args = parser.parse_args()
llm_src = os.path.realpath("TensorRT-LLM/src")
install_python_dependencies(llm_src)
# Verify L0 test lists
if args.l0:
verify_l0_test_lists(llm_src)
else:
print("Skipping L0 test list verification.")
# Verify QA test lists
if args.qa:
verify_qa_test_lists(llm_src)
else:
print("Skipping QA test list verification.")
if __name__ == "__main__":
main()