Debian Codegraph @

scripts/test1_make_large_warnings.pl

raw
1 #!/usr/bin/perl -w
2 ##
3 ## Copyright (c) 2013, 2014 The University of Utah
4 ## All rights reserved.
5 ##
6 ## This file is distributed under the University of Illinois Open Source
7 ## License. See the file COPYING for details.
8
9 ###############################################################################
10
11 use strict;
12
13 my $DIR = "XXDIR";
14
15 my $code;
16
17 sub desirable ($$$$) {
18 (my $sizewin, my $warnwin, my $oratio, my $nratio) = @_;
19 # return $warnwin > 0;
20 return $nratio >= $oratio;
21 }
22
23 sub get_size ($) {
24 (my $fn) = @_;
25 open INF, "<$fn" or return 0;
26 my $line = <INF>;
27 chomp $line;
28 if (!($line =~ /^([0-9]+)$/)) {
29 print "no size in size file\n";
30 return 0;
31 }
32 my $size = $1;
33 close INF;
34 print "read size of $size\n";
35 return $size;
36 }
37
38 my $res = system "( ulimit -t 60 ; ulimit -v 16252928 ; clang++ -std=c++11 -c XXFILE.cpp -o /dev/null ) 2>&1 > /dev/null | wc -c > out.txt";
39 if ($res!=0) {
40 $code = -1;
41 goto EXIT;
42 }
43 if (! -f "$DIR/out_best.txt") {
44 system "cp out.txt $DIR/out_best.txt";
45 $code = 0;
46 goto EXIT;
47 }
48
49 my $osize = -s "$DIR/XXFILE.best";
50 my $nsize = -s "XXFILE.cpp";
51 my $sizewin = $osize - $nsize;
52 print "old size = $osize, new = $nsize, win = $sizewin\n";
53
54 my $owarn = get_size ("$DIR/out_best.txt");
55 my $nwarn = get_size ("out.txt");
56 my $warnwin = $nwarn - $owarn;
57 print "old warn = $owarn, new = $nwarn, win = $warnwin\n";
58
59 my $oratio = (0.0+$owarn)/$osize;
60 my $nratio = (0.0+$nwarn)/$nsize;
61 print "old ratio = $oratio, new = $nratio\n";
62
63 if (desirable($sizewin,$warnwin,$oratio,$nratio)) {
64 system "cp out.txt $DIR/out_best.txt";
65 $code = 0;
66 goto EXIT;
67 } else {
68 $code = -1;
69 goto EXIT;
70 }
71
72 EXIT:
73 #sleep (3600);
74 exit ($code);