[clang][bytecode] Fix reporting failed local constexpr initializers (#123588)
[llvm-project.git] / llvm / utils / reduce_pipeline_test / test.py
blob0ff1ede9f8c2df33c4cf98d8c00b07691be8f55c
1 #!/usr/bin/env python3
3 # Automatically formatted with yapf (https://github.com/google/yapf)
5 import subprocess
6 import unittest
9 def getFinalPasses(run):
10 stdout = run.stdout.decode()
11 stdout = stdout[: stdout.rfind("\n")]
12 stdout = stdout[stdout.rfind("\n") + 1 :]
13 return stdout
16 class Test(unittest.TestCase):
17 def test_0(self):
18 """Test all passes are removed except those required to crash. Verify
19 that PM structure is intact."""
20 run_args = [
21 "./utils/reduce_pipeline.py",
22 "--opt-binary=./utils/reduce_pipeline_test/fake_opt.py",
23 "--input=/dev/null",
24 "--passes=a,b,c,A(d,B(e,f),g),h,i",
25 "-crash-seq=b,d,f",
27 run = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
28 self.assertEqual(run.returncode, 0)
29 self.assertEqual(getFinalPasses(run), '-passes="b,A(d,B(f))"')
31 def test_1(self):
32 """Test all passes are removed except those required to crash. The
33 required passes in this case are the first and last in that order
34 (a bit of a corner-case for the reduction algorithm)."""
35 run_args = [
36 "./utils/reduce_pipeline.py",
37 "--opt-binary=./utils/reduce_pipeline_test/fake_opt.py",
38 "--input=/dev/null",
39 "--passes=a,b,c,A(d,B(e,f),g),h,i",
40 "-crash-seq=a,i",
42 run = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
43 self.assertEqual(run.returncode, 0)
44 self.assertEqual(getFinalPasses(run), '-passes="a,i"')
46 def test_2_0(self):
47 """Test expansion of EXPAND_a_to_f (expands into 'a,b,c,d,e,f')."""
48 run_args = [
49 "./utils/reduce_pipeline.py",
50 "--opt-binary=./utils/reduce_pipeline_test/fake_opt.py",
51 "--input=/dev/null",
52 "--passes=EXPAND_a_to_f",
53 "-crash-seq=b,e",
55 run = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
56 self.assertEqual(run.returncode, 0)
57 self.assertEqual(getFinalPasses(run), '-passes="b,e"')
59 def test_2_1(self):
60 """Test EXPAND_a_to_f and the '--dont-expand-passes' option."""
61 run_args = [
62 "./utils/reduce_pipeline.py",
63 "--opt-binary=./utils/reduce_pipeline_test/fake_opt.py",
64 "--input=/dev/null",
65 "--passes=EXPAND_a_to_f",
66 "-crash-seq=EXPAND_a_to_f",
67 "--dont-expand-passes",
69 run = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
70 self.assertEqual(run.returncode, 0)
71 self.assertEqual(getFinalPasses(run), '-passes="EXPAND_a_to_f"')
73 def test_3(self):
74 """Test that empty pass-managers get removed by default."""
75 run_args = [
76 "./utils/reduce_pipeline.py",
77 "--opt-binary=./utils/reduce_pipeline_test/fake_opt.py",
78 "--input=/dev/null",
79 "--passes=a,b,c,A(d,B(e,f),g),h,i",
80 "-crash-seq=b,d,h",
82 run = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
83 self.assertEqual(run.returncode, 0)
84 self.assertEqual(getFinalPasses(run), '-passes="b,A(d),h"')
86 def test_4(self):
87 """Test the '--dont-remove-empty-pm' option."""
88 run_args = [
89 "./utils/reduce_pipeline.py",
90 "--opt-binary=./utils/reduce_pipeline_test/fake_opt.py",
91 "--input=/dev/null",
92 "--passes=a,b,c,A(d,B(e,f),g),h,i",
93 "-crash-seq=b,d,h",
94 "--dont-remove-empty-pm",
96 run = subprocess.run(run_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
97 self.assertEqual(run.returncode, 0)
98 self.assertEqual(getFinalPasses(run), '-passes="b,A(d,B()),h"')
101 unittest.main()
102 exit(0)