Skip to content

Commit daaac0a

Browse files
Usability improvements to 3C regression test updating programs.
- Make directly executable (on Linux at least). - Chdir to the containing directory if needed. - Access the bin directory via a relative path rather than requiring the user to modify an absolute path in the program.
1 parent eeaf25a commit daaac0a

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

clang/test/3C/processor.py

100644100755
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
#!/usr/bin/env python
12
import fileinput
23
import sys
34
import os
45

5-
path_to_monorepo = "/Users/shilpa-roy/checkedc-clang/build/bin/"
6+
os.chdir(os.path.dirname(__file__))
7+
# Relative path from clang/test/3C/
8+
bin_path = "../../../build/bin/"
69

710
structs = """
811
struct np {
@@ -134,8 +137,8 @@ def process_smart(filename):
134137
file.write('\n\n'.join(test))
135138
file.close()
136139

137-
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {}".format(path_to_monorepo, filename))
138-
os.system("{}3c -addcr -output-postfix=checkedNOALL {}".format(path_to_monorepo, filename))
140+
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {}".format(bin_path, filename))
141+
os.system("{}3c -addcr -output-postfix=checkedNOALL {}".format(bin_path, filename))
139142

140143
process_file_smart(filename, cnameNOALL, cnameALL)
141144
return

clang/test/3C/test_updater.py

100644100755
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
#!/usr/bin/env python
12
import fileinput
23
import sys
34
import os
45

5-
path_to_monorepo = "/Users/shilpa-roy/checkedc-clang/build/bin/"
6+
os.chdir(os.path.dirname(__file__))
7+
# Relative path from clang/test/3C/
8+
bin_path = "../../../build/bin/"
69

710
structs = """
811
struct np {
@@ -82,8 +85,8 @@ def process_smart(filename, diff):
8285
cnameNOALL = filename + "heckedNOALL.c"
8386
cnameALL = filename + "heckedALL.c"
8487

85-
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {}".format(path_to_monorepo, filename))
86-
os.system("{}3c -addcr -output-postfix=checkedNOALL {}".format(path_to_monorepo, filename))
88+
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {}".format(bin_path, filename))
89+
os.system("{}3c -addcr -output-postfix=checkedNOALL {}".format(bin_path, filename))
8790

8891
process_file_smart(filename, cnameNOALL, cnameALL, diff)
8992
return

clang/test/3C/testgenerator.py

100644100755
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
#!/usr/bin/env python
12
# Author: Shilpa Roy
23
# Last updated: June 16, 2020
34

45
import itertools as it
56
import os
67
import subprocess
78

8-
#### USERS PUT YOUR INFO HERE #####
9-
10-
# Please remember to add a '/' at the very end!
11-
path_to_monorepo = "/Users/shilpa-roy/checkedc/checkedc-clang/build/bin/"
9+
os.chdir(os.path.dirname(__file__))
10+
# Relative path from clang/test/3C/
11+
bin_path = "../../../build/bin/"
1212

1313

1414

@@ -726,23 +726,23 @@ def annot_gen_smart(prefix, proto, suffix):
726726

727727
# run the porting tool on the file(s)
728728
if proto=="multi":
729-
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {} {}".format(path_to_monorepo, name, name2))
730-
os.system("{}3c -addcr -output-postfix=checkedNOALL {} {}".format(path_to_monorepo, name, name2))
729+
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {} {}".format(bin_path, name, name2))
730+
os.system("{}3c -addcr -output-postfix=checkedNOALL {} {}".format(bin_path, name, name2))
731731
else:
732-
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {}".format(path_to_monorepo, name))
733-
os.system("{}3c -addcr -output-postfix=checkedNOALL {}".format(path_to_monorepo, name))
732+
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {}".format(bin_path, name))
733+
os.system("{}3c -addcr -output-postfix=checkedNOALL {}".format(bin_path, name))
734734

735735
# compile the files and if it doesn't compile, then let's indicate that a bug was generated for this file
736736
bug_generated = False
737737
if proto != "multi":
738-
out = subprocess.Popen(['{}clang'.format(path_to_monorepo), '-c', cnameNOALL], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
738+
out = subprocess.Popen(['{}clang'.format(bin_path), '-c', cnameNOALL], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
739739
stdout, stderr = out.communicate()
740740
stdout = str(stdout)
741741
if "error:" in stdout:
742742
bug_generated = True
743743
# name = prefix + proto + suffix + "_BUG.c"
744744
else:
745-
out = subprocess.Popen(['{}clang'.format(path_to_monorepo), '-c', cnameNOALL, cname2NOALL], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
745+
out = subprocess.Popen(['{}clang'.format(bin_path), '-c', cnameNOALL, cname2NOALL], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
746746
stdout, stderr = out.communicate()
747747
stdout = str(stdout)
748748
if "error:" in stdout:

0 commit comments

Comments
 (0)