Skip to content

Commit d99b526

Browse files
committed
Add prepare.py script to allow legacy CI to run
1 parent a25d121 commit d99b526

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

test/cbmc/proofs/prepare.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
7+
"""Prepare the source tree for proofs in continuous integration."""
8+
9+
10+
import os
11+
import subprocess
12+
13+
14+
MAKEFILE = "Makefile"
15+
CBMC_BATCH_YAML = "cbmc-batch.yaml"
16+
17+
18+
def create_cbmc_batch_yaml(folder):
19+
"""Run make to create cbmc-batch.yaml in folder."""
20+
21+
try:
22+
subprocess.run(
23+
["make", "-B", CBMC_BATCH_YAML],
24+
cwd=folder,
25+
stdout=subprocess.PIPE,
26+
stderr=subprocess.PIPE,
27+
universal_newlines=True,
28+
check=True
29+
)
30+
except subprocess.CalledProcessError as error:
31+
raise UserWarning("Failed to create {} in {}: "
32+
"command was '{}': "
33+
"error was '{}'"
34+
.format(CBMC_BATCH_YAML, folder,
35+
' '.join(error.cmd),
36+
error.stderr.strip())) from None
37+
38+
39+
def create_cbmc_batch_yaml_files(root='.'):
40+
"""Create cbmc-batch.yaml in all directories under root."""
41+
42+
for folder, _, files in os.walk(root):
43+
if CBMC_BATCH_YAML in files and MAKEFILE in files:
44+
create_cbmc_batch_yaml(folder)
45+
46+
47+
def prepare():
48+
"""Prepare the source tree for proofs in continuous integration."""
49+
50+
create_cbmc_batch_yaml_files()
51+
52+
53+
if __name__ == "__main__":
54+
prepare()

0 commit comments

Comments
 (0)