#!/usr/bin/env perl use strict; use warnings; local $| = 1 ; # -------------------------------------------------------- # Few thing that may need to be re-cofigured # -------------------------------------------------------- my $MYHOME = "/media/sf_T2benchmark/testingtools/t2" ; my $JAVA = "java" ; my $CPseparator = ":" ; # derived paths, no need to change this my $T2JAR = $MYHOME . "/TT.2.2.1.jar" ; my $ALLJARS = $MYHOME . "/libs" ; my $OrigTestClass = $MYHOME . "/T2TestSuite.java" ; my $CopyTestClass = $MYHOME . "/temp/testcases/T2TestSuite.java" ; # -------------------------------------------------------- # Some help-functions first ... # -------------------------------------------------------- sub mkTempDirs { my $DATADir = $MYHOME . "/temp/data" ; my $testcasesDir = $MYHOME . "/temp/testcases" ; if (!(-e $DATADir)) { system("mkdir -p " . $DATADir) ; } if (!(-e $testcasesDir)) { system("mkdir -p " . $testcasesDir) ; } } sub BENCHMARKtoken { my $token = readline(*STDIN) ; chomp $token ; if ($token ne "BENCHMARK") { print STDERR "ERROR: expecting BENCHMARK token" ; exit 0 ; } } sub readPath { my $t = ; chomp $t ; return $t ; } sub readNum { my $N = ; chomp $N ; return 0 + $N ; } sub readContextClassPaths { my $N = $_[0] ; my $paths = "." ; my $k ; for ($k=0; $k<$N; $k++) { my $p = ; chomp $p ; $paths = $paths . $CPseparator ; $paths = $paths . $p ; } return $paths ; } # for passing the path to T2-jar .. not sure if this is a good way # to do it. sub announcePathToTestingTool { print "CLASSPATH\n" ; print "2\n" ; print ($T2JAR . "\n") ; print ($ALLJARS . "\n") ; print ("READY\n") ; } # And here is the function to run T2: sub runT2 { my $mode = $_[0] ; my $CUT = $_[1] ; my $cp = $_[2] ; my $nmax = $_[3] ; my $trlength = $_[4] ; my $suiteID = $_[5] ; my $T2 = " Sequenic.T2.Main " ; my $defaultOptions = " --silent --violmax=1000000 --savegoodtr=1000000 " ; my $trfileOption = " --savefile=" . $MYHOME . "/temp/data/" . $suiteID ; my $logFile = $MYHOME . "/temp/data/generate" . $suiteID ; if ($mode eq "combinatoric") { system ($JAVA . " -ea -cp " . $cp . $T2 . "-C " . $CUT . " --nmax=" . $nmax . " --lenexec=" . $trlength . " --cartesian --dup=10 " . $defaultOptions . $trfileOption . "combin.tr " . " > " . $logFile . "combin.log " . "\n") ; } elsif ($mode eq "search") { system ($JAVA . " -ea -cp " . $cp . $T2 . $CUT . " --nmax=" . $nmax . " --lenexec=" . $trlength . " --searchmode=10 " . $defaultOptions . $trfileOption . "search.tr " . " > " . $logFile . "search.log " . "\n") ; } else { system ($JAVA . " -ea -cp " . $cp . $T2 . $CUT . " --nmax=" . $nmax . " --lenexec=" . $trlength . $defaultOptions . $trfileOption . "rnd.tr " . " > " . $logFile . "rnd.log " . "\n") ; } } # run T2 n-times sub runloop { my $N = $_[0] ; my $cp = $_[1] ; my $k ; for ($k=0; $k<$N; $k++) { mkTempDirs() ; my $CUT = ; chomp $CUT ; runT2("standard",$CUT,$cp,3000,3,"3") ; runT2("search",$CUT,$cp,3000,3,"3") ; runT2("standard",$CUT,$cp,10000,10,"10") ; runT2("search",$CUT,$cp,10000,10,"10") ; runT2("standard",$CUT,$cp,10000,20,"20") ; runT2("search",$CUT,$cp,10000,20,"20") ; runT2("search",$CUT,$cp,10000,20,"20") ; runT2("combinatoric",$CUT,$cp,10000,8,"8") ; system("cp " . $OrigTestClass . " " . $CopyTestClass) ; print ("READY\n") ; } } # -------------------------------------------------------- # Here begins the protocol # -------------------------------------------------------- #print "SBST protocol START\n"; BENCHMARKtoken() ; my $src = readPath() ; my $bin = readPath(); my $numOfContextClassPaths = readNum() ; my $contextClassPath = readContextClassPaths($numOfContextClassPaths) ; my $numOfTargetClasses = readNum() ; my $cp = "\'" . $T2JAR . $CPseparator . $ALLJARS . "/*" .$CPseparator . $bin . $CPseparator . $contextClassPath . "\'" ; announcePathToTestingTool() ; runloop($numOfTargetClasses,$cp) ; # endDEBUG() ; #print "SBST protocol END"; sub endDEBUG { print ("src = " . $src . "\n") ; print ("bin = " . $bin . "\n") ; print ("N = " . ($numOfContextClassPaths + 1 - 1) . "\n") ; print ("cp = " . $cp . "\n") ; }