Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master-post-microsoft' into HEAD
Browse files Browse the repository at this point in the history
New test updating programs.  I may have to redo this merge.
  • Loading branch information
mattmccutchen-cci committed Dec 11, 2020
2 parents c0a8bc2 + 9f36276 commit 9a8a7b2
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 17 deletions.
35 changes: 35 additions & 0 deletions clang/test/3C/find_bin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Set bin_path to the path that should be prepended to '3c', etc. to run them.
# bin_path will be empty (so $PATH is used) or have a trailing slash.
#
# TODO: Do we have other tools that should use this?

import sys
import os
os.chdir(os.path.dirname(__file__))
# Relative paths are now relative to clang/test/3C/ .

sys.path.insert(0, '../../../llvm/utils/lit')
import lit.util
sys.path.pop(0)

def die(msg):
sys.stderr.write('Error: %s\n' % msg)
sys.exit(1)

llvm_obj_maybe = os.environ.get('LLVM_OBJ')
standard_build_dir = '../../../build'
if llvm_obj_maybe is not None:
bin_path = llvm_obj_maybe + '/bin/'
if not os.path.isfile(bin_path + '3c'):
die('$LLVM_OBJ is set but the bin directory does not contain 3c.')
elif os.path.isdir(standard_build_dir):
bin_path = standard_build_dir + '/bin/'
if not os.path.isfile(bin_path + '3c'):
die('The standard build directory exists but does not contain 3c.')
elif lit.util.which('3c') is not None:
# TODO: To help prevent mistakes, validate that the `3c` we found is under a
# build directory linked to the current source tree? Or might users want to
# do unusual things?
bin_path = ''
else:
die('Could not find 3c via $LLVM_OBJ, the standard build directory, or $PATH.')
10 changes: 6 additions & 4 deletions clang/test/3C/processor.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env python
import fileinput
import sys
import os

path_to_monorepo = "/Users/shilpa-roy/checkedc-clang/build/bin/"
import find_bin
bin_path = find_bin.bin_path

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

file = open(filename, "w+")
file.write('\n\n'.join(test))
file.write('\n\n'.join(test) + '\n')
file.close()

os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {}".format(path_to_monorepo, filename))
os.system("{}3c -addcr -output-postfix=checkedNOALL {}".format(path_to_monorepo, filename))
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {}".format(bin_path, filename))
os.system("{}3c -addcr -output-postfix=checkedNOALL {}".format(bin_path, filename))

process_file_smart(filename, cnameNOALL, cnameALL)
return
Expand Down
8 changes: 5 additions & 3 deletions clang/test/3C/test_updater.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env python
import fileinput
import sys
import os

path_to_monorepo = "/Users/shilpa-roy/checkedc-clang/build/bin/"
import find_bin
bin_path = find_bin.bin_path

structs = """
struct np {
Expand Down Expand Up @@ -82,8 +84,8 @@ def process_smart(filename, diff):
cnameNOALL = filename + "heckedNOALL.c"
cnameALL = filename + "heckedALL.c"

os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {}".format(path_to_monorepo, filename))
os.system("{}3c -addcr -output-postfix=checkedNOALL {}".format(path_to_monorepo, filename))
os.system("{}3c -alltypes -addcr -output-postfix=checkedALL {}".format(bin_path, filename))
os.system("{}3c -addcr -output-postfix=checkedNOALL {}".format(bin_path, filename))

process_file_smart(filename, cnameNOALL, cnameALL, diff)
return
Expand Down
19 changes: 9 additions & 10 deletions clang/test/3C/testgenerator.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/usr/bin/env python
# Author: Shilpa Roy
# Last updated: June 16, 2020

import itertools as it
import os
import subprocess

#### USERS PUT YOUR INFO HERE #####

# Please remember to add a '/' at the very end!
path_to_monorepo = "/Users/shilpa-roy/checkedc/checkedc-clang/build/bin/"
import find_bin
bin_path = find_bin.bin_path



Expand Down Expand Up @@ -726,23 +725,23 @@ def annot_gen_smart(prefix, proto, suffix):

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

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

0 comments on commit 9a8a7b2

Please sign in to comment.