Skip to content

Commit 029e809

Browse files
committed
Add i option to calc test script
1 parent ec3e838 commit 029e809

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

AFLplusplus

tools/calc_test.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,27 @@
1717
# You should have received a copy of the GNU General Public License
1818
# along with Prophet. If not, see <http://www.gnu.org/licenses/>.
1919
from sys import argv
20-
from os import system
20+
from os import rmdir, system,mkdir,chdir,getcwd
2121
import getopt
22+
import shutil
2223

2324
if __name__ == "__main__":
2425
if len(argv) < 4:
2526
print "Usage: calc_test.py <src_dir> <test_dir> <work_dir> [cases]";
2627
exit(1);
2728

28-
opts, args = getopt.getopt(argv[1:], "p:");
29+
opts, args = getopt.getopt(argv[1:], "p:i:");
2930
profile_dir = "";
31+
temp_dir="__temp_test"
3032
for o, a in opts:
3133
if o == "-p":
3234
profile_dir = a;
35+
elif o=='-i':
36+
temp_dir=a
37+
38+
mkdir(temp_dir);
39+
orig_dir=getcwd()
40+
chdir(temp_dir)
3341

3442
src_dir = args[0];
3543
test_dir = args[1];
@@ -42,18 +50,26 @@
4250
if len(args) > 3:
4351
ids = args[3:];
4452
for i in ids:
53+
shutil.copyfile(test_dir + "/" + str(i) + ".in", "./" + str(i) + ".in")
54+
shutil.copyfile(test_dir + "/" + str(i) + ".exp", "./" + str(i) + ".exp")
55+
4556
in_file=open(test_dir+"/"+i+".in")
4657
in_arg=in_file.readline()
4758
in_file.close()
59+
4860
if (i != "0"):
4961
cmd = cur_dir +"/Calc "+in_arg+ " 1> __out";
5062
else:
5163
cmd = cur_dir + "/Calc 1> __out";
5264
ret = system(cmd);
5365
if (ret == 0):
54-
cmd = "diff __out " + test_dir + "/" + i + ".exp 1> /dev/null";
66+
cmd = "diff __out " + str(i) + ".exp 1> /dev/null";
5567
ret = system(cmd);
5668
if (ret == 0):
5769
print i,
5870
system("rm -rf __out");
71+
5972
print;
73+
74+
chdir(orig_dir)
75+
shutil.rmtree(temp_dir)

0 commit comments

Comments
 (0)