-
Notifications
You must be signed in to change notification settings - Fork 7
/
run-test.rb
70 lines (61 loc) · 1.67 KB
/
run-test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/ruby
#
# stoat - LLVM Based Static Analysis Tool
# Copyright (C) 2015 Mark McCurry
#
# This file is part of stoat.
#
# stoat is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# stoat is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with stoat. If not, see <http://www.gnu.org/licenses/>.
#
# Argument:
# 1 - path to run.rb
# 2 - path to libfoo.so
# 3 - compiler to use
# 4 - whitelist to use
# 4..end - path to source files
if ARGV.length < 5
$stderr.puts "Too Few Arguments"
error 1
end
deductions = ARGV[0]
llvm_lib = ARGV[1]
compiler = ARGV[2]
whitelist = ARGV[3]
blacklist = ARGV[4]
suppression = ARGV[5]
if(suppression != "nil")
suppression = "-s #{suppression}"
else
suppression = ""
end
args = ""
if(/\+\+/.match compiler)
args = "-std=c++11" #Show off inlining
else
args = "-std=c11"
end
source_files = ARGV[6...ARGV.length].join " "
`mkdir tmp-build-dir`
Dir.chdir 'tmp-build-dir'
`#{compiler} #{args} -emit-llvm -c #{source_files}`
puts `ruby #{deductions} --llvm-passes #{llvm_lib} -w #{whitelist} -b #{blacklist} #{suppression} -r .`
return_code = $?.to_i
Dir.chdir '..'
`rm -r tmp-build-dir`
puts "return code = '#{return_code}'"
if(return_code == 0)
exit(0)
else
exit(-1)
end