Skip to content

Commit 9a8a7b2

Browse files
Merge remote-tracking branch 'origin/master-post-microsoft' into HEAD
New test updating programs. I may have to redo this merge.
2 parents c0a8bc2 + 9f36276 commit 9a8a7b2

File tree

4 files changed

+55
-17
lines changed

4 files changed

+55
-17
lines changed

clang/test/3C/find_bin.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Set bin_path to the path that should be prepended to '3c', etc. to run them.
2+
# bin_path will be empty (so $PATH is used) or have a trailing slash.
3+
#
4+
# TODO: Do we have other tools that should use this?
5+
6+
import sys
7+
import os
8+
os.chdir(os.path.dirname(__file__))
9+
# Relative paths are now relative to clang/test/3C/ .
10+
11+
sys.path.insert(0, '../../../llvm/utils/lit')
12+
import lit.util
13+
sys.path.pop(0)
14+
15+
def die(msg):
16+
sys.stderr.write('Error: %s\n' % msg)
17+
sys.exit(1)
18+
19+
llvm_obj_maybe = os.environ.get('LLVM_OBJ')
20+
standard_build_dir = '../../../build'
21+
if llvm_obj_maybe is not None:
22+
bin_path = llvm_obj_maybe + '/bin/'
23+
if not os.path.isfile(bin_path + '3c'):
24+
die('$LLVM_OBJ is set but the bin directory does not contain 3c.')
25+
elif os.path.isdir(standard_build_dir):
26+
bin_path = standard_build_dir + '/bin/'
27+
if not os.path.isfile(bin_path + '3c'):
28+
die('The standard build directory exists but does not contain 3c.')
29+
elif lit.util.which('3c') is not None:
30+
# TODO: To help prevent mistakes, validate that the `3c` we found is under a
31+
# build directory linked to the current source tree? Or might users want to
32+
# do unusual things?
33+
bin_path = ''
34+
else:
35+
die('Could not find 3c via $LLVM_OBJ, the standard build directory, or $PATH.')

clang/test/3C/processor.py

100644100755
+6-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
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+
import find_bin
7+
bin_path = find_bin.bin_path
68

79
structs = """
810
struct np {
@@ -131,11 +133,11 @@ def process_smart(filename):
131133
elif susproto != "": test = [header, susproto, foo, bar, sus]
132134

133135
file = open(filename, "w+")
134-
file.write('\n\n'.join(test))
136+
file.write('\n\n'.join(test) + '\n')
135137
file.close()
136138

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))
139+
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {}".format(bin_path, filename))
140+
os.system("{}3c -addcr -output-postfix=checkedNOALL {}".format(bin_path, filename))
139141

140142
process_file_smart(filename, cnameNOALL, cnameALL)
141143
return

clang/test/3C/test_updater.py

100644100755
+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
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+
import find_bin
7+
bin_path = find_bin.bin_path
68

79
structs = """
810
struct np {
@@ -82,8 +84,8 @@ def process_smart(filename, diff):
8284
cnameNOALL = filename + "heckedNOALL.c"
8385
cnameALL = filename + "heckedALL.c"
8486

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))
87+
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {}".format(bin_path, filename))
88+
os.system("{}3c -addcr -output-postfix=checkedNOALL {}".format(bin_path, filename))
8789

8890
process_file_smart(filename, cnameNOALL, cnameALL, diff)
8991
return

clang/test/3C/testgenerator.py

100644100755
+9-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
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+
import find_bin
10+
bin_path = find_bin.bin_path
1211

1312

1413

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

727726
# run the porting tool on the file(s)
728727
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))
728+
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {} {}".format(bin_path, name, name2))
729+
os.system("{}3c -addcr -output-postfix=checkedNOALL {} {}".format(bin_path, name, name2))
731730
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))
731+
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {}".format(bin_path, name))
732+
os.system("{}3c -addcr -output-postfix=checkedNOALL {}".format(bin_path, name))
734733

735734
# compile the files and if it doesn't compile, then let's indicate that a bug was generated for this file
736735
bug_generated = False
737736
if proto != "multi":
738-
out = subprocess.Popen(['{}clang'.format(path_to_monorepo), '-c', cnameNOALL], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
737+
out = subprocess.Popen(['{}clang'.format(bin_path), '-c', cnameNOALL], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
739738
stdout, stderr = out.communicate()
740739
stdout = str(stdout)
741740
if "error:" in stdout:
742741
bug_generated = True
743742
# name = prefix + proto + suffix + "_BUG.c"
744743
else:
745-
out = subprocess.Popen(['{}clang'.format(path_to_monorepo), '-c', cnameNOALL, cname2NOALL], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
744+
out = subprocess.Popen(['{}clang'.format(bin_path), '-c', cnameNOALL, cname2NOALL], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
746745
stdout, stderr = out.communicate()
747746
stdout = str(stdout)
748747
if "error:" in stdout:

0 commit comments

Comments
 (0)