Files
TheRock/compiler/amd-llvm/llvm/utils/reduce_pipeline_test/test.py
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

103 lines
3.8 KiB
Python
Executable File

#!/usr/bin/env python3
# Automatically formatted with yapf (https://github.com/google/yapf)
import subprocess
import unittest
def getFinalPasses(run):
stdout = run.stdout.decode()
stdout = stdout[: stdout.rfind("\n")]
stdout = stdout[stdout.rfind("\n") + 1 :]
return stdout
class Test(unittest.TestCase):
def test_0(self):
"""Test all passes are removed except those required to crash. Verify
that PM structure is intact."""
run_args = [
"./utils/reduce_pipeline.py",
"--opt-binary=./utils/reduce_pipeline_test/fake_opt.py",
"--input=/dev/null",
"--passes=a,b,c,A(d,B(e,f),g),h,i",
"-crash-seq=b,d,f",
]
run = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.assertEqual(run.returncode, 0)
self.assertEqual(getFinalPasses(run), '-passes="b,A(d,B(f))"')
def test_1(self):
"""Test all passes are removed except those required to crash. The
required passes in this case are the first and last in that order
(a bit of a corner-case for the reduction algorithm)."""
run_args = [
"./utils/reduce_pipeline.py",
"--opt-binary=./utils/reduce_pipeline_test/fake_opt.py",
"--input=/dev/null",
"--passes=a,b,c,A(d,B(e,f),g),h,i",
"-crash-seq=a,i",
]
run = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.assertEqual(run.returncode, 0)
self.assertEqual(getFinalPasses(run), '-passes="a,i"')
def test_2_0(self):
"""Test expansion of EXPAND_a_to_f (expands into 'a,b,c,d,e,f')."""
run_args = [
"./utils/reduce_pipeline.py",
"--opt-binary=./utils/reduce_pipeline_test/fake_opt.py",
"--input=/dev/null",
"--passes=EXPAND_a_to_f",
"-crash-seq=b,e",
]
run = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.assertEqual(run.returncode, 0)
self.assertEqual(getFinalPasses(run), '-passes="b,e"')
def test_2_1(self):
"""Test EXPAND_a_to_f and the '--dont-expand-passes' option."""
run_args = [
"./utils/reduce_pipeline.py",
"--opt-binary=./utils/reduce_pipeline_test/fake_opt.py",
"--input=/dev/null",
"--passes=EXPAND_a_to_f",
"-crash-seq=EXPAND_a_to_f",
"--dont-expand-passes",
]
run = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.assertEqual(run.returncode, 0)
self.assertEqual(getFinalPasses(run), '-passes="EXPAND_a_to_f"')
def test_3(self):
"""Test that empty pass-managers get removed by default."""
run_args = [
"./utils/reduce_pipeline.py",
"--opt-binary=./utils/reduce_pipeline_test/fake_opt.py",
"--input=/dev/null",
"--passes=a,b,c,A(d,B(e,f),g),h,i",
"-crash-seq=b,d,h",
]
run = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.assertEqual(run.returncode, 0)
self.assertEqual(getFinalPasses(run), '-passes="b,A(d),h"')
def test_4(self):
"""Test the '--dont-remove-empty-pm' option."""
run_args = [
"./utils/reduce_pipeline.py",
"--opt-binary=./utils/reduce_pipeline_test/fake_opt.py",
"--input=/dev/null",
"--passes=a,b,c,A(d,B(e,f),g),h,i",
"-crash-seq=b,d,h",
"--dont-remove-empty-pm",
]
run = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.assertEqual(run.returncode, 0)
self.assertEqual(getFinalPasses(run), '-passes="b,A(d,B()),h"')
unittest.main()
exit(0)