Skip to content

Commit

Permalink
Minor tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
regehr committed Aug 5, 2011
1 parent 00bc037 commit 98e84b6
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions scripts/test_csmith.pl
Expand Up @@ -30,7 +30,7 @@
use strict;
use File::stat;

## This is a tester for Csmith itself.
## This is a simple tester for Csmith itself.

#######################################################################

Expand All @@ -40,10 +40,12 @@
my $EXTRA_OPTIONS = "";
my $CSMITH_HOME = $ENV{"CSMITH_HOME"};
my $COMPILER = "gcc -w -O0";
my $VALGRIND = "";
#my $VALGRIND = "valgrind -q --error-exitcode=66 ";
my $RUN_PROGRAM = 0;
#my $RUN_PROGRAM = 1;

#my $VALGRIND = "";
my $VALGRIND = "valgrind -q --error-exitcode=66 ";

#my $RUN_PROGRAM = 0;
my $RUN_PROGRAM = 1;

#######################################################################

Expand All @@ -52,7 +54,7 @@
# properly parse the return value from system()
sub runit ($$) {
my ($cmd, $out) = @_;
print "before running $cmd\n";
print "about to run '$cmd'\n";
my $res = system "$cmd";
my $exit_value = $? >> 8;
$exit_value = $? & 127 if ($? & 127);
Expand All @@ -61,7 +63,7 @@ ($$)

sub yesno ($) {
(my $opt) = @_;
if (rand()<0.5) {
if (rand() < 0.5) {
return " --$opt ";
} else {
return " --no-$opt ";
Expand Down Expand Up @@ -113,25 +115,25 @@ ($)
system "rm -f $ofile";
my $cmd2 = "$COMPILER $cfile $HEADER -o $ofile";
$res = runit ($cmd2, "csmith.out");
if ($res!=0 || !(-f $ofile)) {
if ($res != 0 || !(-f $ofile)) {
print "Failed to compile program generated by $cmd\n";
exit (-1);
}

if ($RUN_PROGRAM) {
my $cmd3 = "RunSafely.sh 15 1 /dev/null out.txt $VALGRIND ./$ofile";
$res = runit ($cmd3, "out2.txt");
if ($res !=0 && $res != 137) {
if ($res != 0 && $res != 137) {
print "Compiled random program died with error code $res\n";
exit (-1);
}
if ($res==137) {
if ($res == 137) {
print "Timed out.\n";
}
}

$n_good++;
print "test case $n_good\n";
print "finished with test case $n_good.\n\n";
}
}

Expand Down

0 comments on commit 98e84b6

Please sign in to comment.