#!/usr/local/bin/ksh -h # kmothra mutant execution shell file # kmothra is a menu driven shell file to run the different tools of the # MOTHRA. The test session name defines the names of all the files # used by MOTHRA. # # Written by: Jeff Offutt # # Copyright, Jeff Offutt, 1995 # Permission is given to use this software for non-commercial # purposes, providing this copyright notice is kept intact. # # Date : 6/24/86. # Updates : Interface extensively revised 3/93. # : Godzilla tools added 12/93. # # ################################################################ ################################################################ # NOTE: TO USE THIS KSH SCRIPT YOU MUST REDEFINE THE FOLLOWING # VARIABLE TO BE THE LOCATION OF MOTHRA TOOLS ON YOUR COMPUTER. typeset BIN=${BIN:-/home/faculty/ofut/mutate/bin} ################################################################ ################################################################ # Variables: # # ExpName -- Base source file name and global test session name. # (Used to call the test session "experiment".) # MutTypes -- Mutant types. # MoreMuts -- Whether we've received more mutants or not. # MoreTCs -- Whether we've received more test cases or not. # MMask -- Result of mutmake. # NumTstCases -- Current number of test cases. # CurCase -- Current test case number to add. # Alive -- Number of mutants still alive. # Total -- Total number of mutants generated for this program. # NextMut -- The next mutant to generate. # Step -- Percentage of mutants executed. # Percent -- Percentage of mutants created. # GZ_Per -- Percentage of constraints satisfied. # GZ_AdjArrLen-- Length of adjustable arrays. # GZ_Factor -- Number of satisfaction tries. # GZ_Domain -- Domain of input variables. # ################################################################ # Tools: # # PARSER -- MOTHRA's parser. # ROSETTA -- MOTHRA's interpreter. # MAPPER -- MOTHRA's test case editor. # MUTMAKE -- MOTHRA's mutant maker. # MUTSTAT -- MOTHRA's mutant statistician. # NUMCASES -- Number of test cases in the tc file. # ################################################################ ################################################################ # Initialize variables # ################################################################ set -o bgnice MEMDEFAULT=0 if tty -s then PAGER=/usr/ucb/more else PAGER=/bin/cat fi export PAGER RM=/bin/rm typeset -x PATH=/usr/ucb:/usr/bin:/bin:/usr/local/bin:/usr/local # The tools are: #typeset BIN=${BIN:-/u/untch/public/HUBCAPmothra} # My home directory is in a different place on my workstation ... #Not anymore ... #if [ `hostname` = mothra ] #then # typeset BIN=${BIN:-/home/ofut/mutate/bin} #else # typeset BIN=${BIN:-/home/faculty/ofut/mutate/bin} #fi typeset PARSER=${PARSER:-$BIN/parser} typeset ROSETTA=${ROSETTA:-$BIN/rosetta} typeset MUTMAKE=${MUTMAKE:-$BIN/mutmake} typeset MUTSTAT=${MUTSTAT:-$BIN/mutstat} typeset MAPPER=${MAPPER:-$BIN/mapper} # typeset BGMUT=${BGMUT:-$BIN/bgmut} typeset DECODE=${DECODE:-$BIN/decode} typeset MUTEQUIV=${MUTEQUIV:-$BIN/mutequiv} typeset NUMCASES=${NUMCASES:-$BIN/numcases} #Godzilla tools ... typeset PATHS=${PATHS:-$BIN/paths} typeset CONGEN=${CONGEN:-$BIN/congen} typeset CONFORM=${CONFORM:-$BIN/conform} typeset CONSAT=${CONSAT:-$BIN/consat} # The extensions are: typeset SYMEXT=sym typeset CODEEXT=code typeset MDREXT=mdr typeset TCEXT=tc typeset SRCEXT=ftn typeset EXPEXT=exp typeset PATHEXT=pe typeset CONSEXT=con #These two tell ExecMut whether we've defined new mutants or Test cases. #Initialized to zero, set to one with new additions, and returned to #zero when ExecMut processes them. typeset -i MoreMuts=0 typeset -i MoreTCs=0 typeset -i LastTC=0 typeset -i Total=0 typeset -i Alive=0 typeset -i NumTstCases=0 typeset -i CurCase=0 typeset MMask="0" typeset -i Percent=0 typeset RoseOpts="-o5" typeset -x MORE=-dc #Godzilla variables (Auto Test) typeset -i GZ_Per=100 typeset -i GZ_AdjArrLen=10 typeset -i GZ_Factor=25 typeset GZ_Domain="-Bi-100 -Ti100" umask 002 ################################################################ # Hesitate before returning from process to menu. # ################################################################ Hesitate () { read Que?"[Press return to continue]" } ################################################################ # Get a test case from a file or interactively. # ################################################################ GetTC () { print " ENTER TEST CASE SCREEN" typeset numoldtc=0 typeset opt="-a" read REPLY?"Initial values from [USER, OLD TEST SESSION] (USER)? " if test "$REPLY" = "o" -o "$REPLY" = "O" -o "$REPLY" = "old" -o "$REPLY" = "OLD" -o "$REPLY" = "old test session" -o "$REPLY" = "OLD TEST SESSION" then read REPLY?"Enter name of previous Mothra test session: " if test -f $REPLY.$TCEXT then typeset opt="-f $REPLY" numoldtc=`$NUMCASES "$REPLY"` else print "I could not find the test case file for $REPLY." read REPLY?"Enter test session name: " if test -f $REPLY.$TCEXT then typeset opt="-f $REPLY.$TCEXT" numoldtc=`$NUMCASES "$REPLY"` else print "Couldn't find $REPLY." print "Forget it." return fi fi fi print "" if test "$opt" = "-a" then read REPLY?"Run Time values from [USER, FILE] (USER)? " else read REPLY?"Additional Run Time values from [USER, FILE] (USER)? " fi if test "$REPLY" = "f" -o "$REPLY" = "F" -o "$REPLY" = "file" -o "$REPLY" = "FILE" then while true do read INFILE?"Enter input file name: " if test ! -z "$INFILE" then break fi done if test ! -f $INFILE then print "I could not find $INFILE." read INFILE?"Enter input file name: " if test ! -f $INFILE then print "Couldn't find $INFILE." print "Forget it." return fi fi print "" read LEN?"How many test cases are in $INFILE? " print "" if [ $numoldtc -eq 0 ] then ((CurCase = NumTstCases + 1)) ((OldCurCase = NumTstCases + 1)) ((NumTstCases = NumTstCases + LEN)) while test $CurCase -le $NumTstCases do $MAPPER $opt $ExpName ((CurCase = CurCase + 1)) done elif [ $numoldtc -eq $LEN ] then ((OldCurCase = NumTstCases + 1)) ((NumTstCases = NumTstCases + LEN)) CurCase=$NumTstCases $MAPPER $opt $ExpName else print " There are $numoldtc cases in the old test session and $LEN cases in the input file." print " Sorry, but I don't know how to combine them." return fi print "" print "" print " Test cases # $OldCurCase through $NumTstCases" print "" print "Running original program..." print "" (cat $INFILE | $ROSETTA -e $RoseOpts -c$OldCurCase $ExpName) | $PAGER read REPLY?"Are all of these the correct output? [y n](y) " if test "$REPLY" = "n" -o "$REPLY" = "N" then print "Skipping test cases $OldCurCase through $NumTstCases." ((CurCase = OldCurCase)) while test $CurCase -le $NumTstCases do $MAPPER -r $CurCase $ExpName $MAPPER -c $ExpName $RM -f $ExpName.output.$CurCase $RM -f $ExpName.tags.$CurCase ((CurCase = CurCase + 1)) (( MoreTCs = MoreTCs - 1 )) done (( NumTstCases = OldCurCase - 1 )) (( CurCase = OldCurCase - 1 )) fi else #of if reply is file. $MAPPER $opt $ExpName (( CurCase = NumTstCases + 1 )) NumTstCases=`$NUMCASES "$ExpName"` while test $CurCase -le $NumTstCases do print "" print "" print " Test case # "$CurCase. print "" print "Running original program..." print "" $ROSETTA -e $RoseOpts -n$CurCase $ExpName read REPLY?"Is this the correct output? [y n](y) " if test "$REPLY" = "n" -o "$REPLY" = "N" then print "Skipping test case $CurCase." $MAPPER -r $CurCase $ExpName $MAPPER -c $ExpName $RM -f $ExpName.output.$CurCase $RM -f $ExpName.tags.$CurCase (( NumTstCases = NumTstCases - 1 )) (( CurCase = CurCase - 1 )) (( MoreTCs = MoreTCs - 1 )) else $MAPPER -v $CurCase $ExpName fi (( CurCase = CurCase + 1 )) done #While CurCase < NumTstCases (( MoreTCs = MoreTCs + 1 )) fi ExpWrite } ################################################################ # Delete a test case from the test case file. # ################################################################ DelTC () { if [ $NumTstCases -lt 1 ] then print "No test cases to delete." return fi read Que?"Which test case? (1...$NumTstCases) " if test $Que -le $NumTstCases -a $Que -gt 0 then $MAPPER -r $Que $ExpName $MAPPER -c $ExpName (( NumTstCases = NumTstCases - 1 )) if test $Que -le $LastTC then (( LastTC = LastTC - 1 )) fi if test $Que -le $CurCase then (( CurCase = CurCase - 1 )) fi if test $MoreTCs -gt 0 then (( MoreTCs = MoreTCs - 1 )) fi else print "Sorry, I don't have a test case number $Que." Hesitate fi ExpWrite } ################################################################ # Test case menu. # ################################################################ TCs () { while true do clear PS3=" Enter the number of your choice; M or m to return to main menu; Q or q to quit KMothra: " print "" print "" print " TEST CASE MENU" print "" print "" select choice in "View Test Cases" "Print Test Cases To A File" "Delete a Test Case" do print "" case $REPLY in 1) (echo " Test Cases" ; echo "" ; $MAPPER -s $ExpName) | $PAGER ; Hesitate; break ;; 2) read Que?"File name: " ; $MAPPER -s $ExpName > $Que ; print "Test cases saved in $Que"; Hesitate; break ;; 3) DelTC ; Hesitate ; break ;; m) return ;; M) return ;; q) print ""; print "Saving test session $ExpName." ExpWrite; exit 1 ;; Q) print ""; print "Saving test session $ExpName." ExpWrite; exit 1 ;; *) print "Please choose a number from the menu." ; Hesitate; break ;; esac done done #with test case loop. } ################################################################ # Get mutants until mutmake gets a correct set. # ################################################################ GetMuts () { print " CREATE MUTANTS SCREEN" if test $Percent -eq 0 then while true do # Get a mutant percentage from the user. print "" read PERC?"What percentage of mutants would you like [1-100] (100)? " if test -z "$PERC" then Percent=100 break elif test "$PERC" -ge "1" -a "$PERC" -le "100" 2>/dev/null then Percent=$PERC break else echo "Sorry, $PERC is not between 1 and 100." echo "" fi done fi while true do # Ask which mutant types/classes the user would like to # generate. Allow the user to see a list of the allowable # mutants. print "" print " Mutant Names" print "" print "TYPES: aar abs acr aor asr car cnr crp csr der dsa" print " glr lcr ror rsr san sar scr sdl src svr uoi" print "" print "CLASSES: ary con ctl dmn opm prd scl stm" print "" print "SUPER CLASSES: all cca pda sal" print "" print "Which Mutant types/classes would you like to generate?" print "You may enter the complete list of mutants on one line, separated" print "by blanks. Enter a blank line when you are finished selecting." print "Enter a "?" to see a descriptions of the mutant types and classes." print "" while true do read NAMES?"[? (all)]? " if test ! "$NAMES" then break elif test "$NAMES" = "?" then $MUTMAKE -l | $PAGER else MutTypes="$MutTypes $NAMES" fi done #No entry, define all types. if test ! "$MutTypes" then MutTypes="all" fi print "" ################################################################ # Make the mutants that the user wanted. # ################################################################ print "Creating mutants..." MMask=`$MUTMAKE -p$Percent $ExpName $MutTypes` if test ! "$MMask" then #Error message is printed inside mutmake. #print "I don't understand the mutant types." MutTypes="" else # (tail added to avoid header 5/11/91 AJO) NewAlive=`$MUTSTAT -c $ExpName | tail -1 | awk '{print $3}'` (( New = NewAlive - Alive)) print "Created $New additional mutants for $ExpName." (( Total = Total + New )) Alive=$NewAlive Hesitate break #From loop. Good input. fi done if test $New -gt 0 then MoreMuts=1 fi ExpWrite } ################################################################ # Run Godzilla to get a batch of test cases, # # run all the test cases, # # eliminate ineffective test cases. # ################################################################ AutoTest () { print " RUN AUTO TEST SCREEN" if [ "$MMask" = "0" ] then #First create mutants if need be ... #Copied from GetMuts() print "Creating all mutants ..." MutTypes="all" MMask=`$MUTMAKE $ExpName $MutTypes` if [ ! "$MMask" ] then #Error message is printed inside mutmake. #print "I don't understand the mutant types." MutTypes="" else # (tail added to avoid header 5/11/91 AJO) NewAlive=`$MUTSTAT -c $ExpName | tail -1 | awk '{print $3}'` (( New = NewAlive - Alive)) #print "Created $New additional mutants for $ExpName." (( Total = Total + New )) Alive=$NewAlive fi fi #Now create path expressions # If no paths, create them. if [ ! -r "$ExpName.$PATHEXT" ] then print "Creating path expressions ..." $PATHS $ExpName >/dev/null fi # If no necessity constraints, create them. if [ ! -r "$ExpName.$CONSEXT" ] then print "Creating constraints ..." $CONGEN -m$MMask $ExpName $CONFORM $ExpName >/dev/null #ignore it if it barfs. fi #Partly from GetTC() $CONSAT -r -c$GZ_Per $GZ_Domain -j$GZ_AdjArrLen -N$GZ_Factor -m$MMask $ExpName (( CurCase = NumTstCases + 1 )) NumTstCases=`$NUMCASES "$ExpName"` if [ $NumTstCases -eq $CurCase-1 ] then print "No new test cases created." Hesitate else $ROSETTA -g -e $RoseOpts -c$CurCase $ExpName (( MoreTCs = MoreTCs + 1 )) #Is 1 allright? #Run mutants on tcs, but use the gag option ... print "Running test cases ..." t=$RoseOpts RoseOpts=$RoseOpts" -g" ExecMuts RoseOpts=$t print "Removing ineffective test cases ..." $MAPPER -e $ExpName $MAPPER -c $ExpName NumTstCases=`$NUMCASES "$ExpName"` LastTC=$NumTstCases fi ExpWrite #Hesitate #ExecMuts hesitates ... } ################################################################ # Defining mutants to be equivalent. # # # ################################################################ ExecEquiv () { typeset skip=0 #mutstat -l to list all live mutants, use tail to start with #the third line to skip the header. # (tail added to avoid header 5/11/91 AJO) for mutnum in `$MUTSTAT -l $ExpName | tail +3 | awk '{print $1}'` do if test $skip -le $mutnum then typeset skip=0 elif test $skip -gt 0 then continue fi print "Mutant number $mutnum of $Total total mutants." $DECODE -M $mutnum $ExpName print "" set IsEquiv="n" read IsEquiv?"Is this mutant equivalent? [y n # q](n) " case $IsEquiv in *[A-z]*) if test "$IsEquiv" = "y" -o "$IsEquiv" = "Y" then $MUTEQUIV $ExpName $mutnum elif test "$IsEquiv" = "q" then break fi ;; "") ;; *) typeset skip=$IsEquiv ; ;; esac print "" done # (tail added to avoid header 5/11/91 AJO) Alive=`$MUTSTAT -c $ExpName | tail -1 | awk '{print $3}'` } ################################################################ # Status menu # # # ################################################################ Status () { while true do clear PS3=" Enter the number of your choice; M or m to return to main menu; Q or q to quit KMothra: " print "" print "" print " STATUS MENU" print "" print "" select choice in "View Mutant Status" "Print Mutant Status To A File" "Declare Mutants as Equivalent" "Declare One Mutant as Equivalent" "UnEquivalence One Mutant" "View Dead Mutants" "View Equivalent Mutants" "Print Live Mutants To A File" do print "" case $REPLY in 1) (echo " Mutant Status" ; echo "" ; $MUTSTAT -P $ExpName) | $PAGER; Hesitate; break ;; 2) read Que?"File name: " ; $MUTSTAT -P $ExpName >$Que; print "Status saved in $Que"; Hesitate; break ;; 3) ExecEquiv ; break ;; 4) read Que?"Which mutant? " ; $DECODE -M $Que $ExpName; read IsEquiv?"Is this mutant equivalent? [y n](y) "; if test "$IsEquiv" = "n" -o "$IsEquiv" = "N" then break; else $MUTEQUIV $ExpName $Que ; fi (( Alive = Alive - 1 )) break ;; 5) read Que?"Which mutant? " ; $DECODE -M $Que $ExpName; read IsUnEquiv?"Unequivalence this mutant? [y n](y) "; if test "$IsUnEquiv" = "n" -o "$IsUnEquiv" = "N" then break; else $MUTEQUIV -u $ExpName $Que ; fi # Execute all test cases on the one mutant. $ROSETTA $RoseOpts -M$Que -m$MMask $ExpName ; # (tail added to avoid header 5/11/91 AJO) Alive=`$MUTSTAT -c $ExpName | tail -1 | awk '{print $3}'` break ;; 6) (echo " Dead Mutants" ; echo "" ; $DECODE -k $ExpName) | $PAGER; Hesitate; break ;; 7) (echo " Equivalent Mutants" ; echo "" ; $DECODE -q $ExpName) | $PAGER; Hesitate; break ;; 8) read Que?"File name: " ; $DECODE -m $ExpName >$Que; print "Live mutants saved in $Que"; Hesitate; break ;; m) return ;; M) return ;; q) print ""; print "Saving test session $ExpName." ExpWrite; exit 1 ;; Q) print ""; print "Saving test session $ExpName." ExpWrite; exit 1 ;; *) print "Please choose a number from the menu." ; Hesitate; break ;; esac done #with select done #with status loop. } ################################################################ # Execution phase. # # # # If MoreMuts != 0 then run all test cases. # # If MoreTCs != 0 then run new test cases. # # LastTC remembers the last test case executed. # ################################################################ ExecMuts () { print " RUN MUTANTS SCREEN" if test $MoreMuts -ne 0 then LastTC=0 fi if test "$MMask" = "0" then print "" print "I must have a mutant type defined before execution." Hesitate elif test $NumTstCases -eq 0 then print "" print "I must have a test case before execution." elif test $MoreTCs -ne 0 -o $MoreMuts -ne 0 then #Something new, execute. MoreTCs=0 MoreMuts=0 (( CurTC = LastTC + 1)) # #For each test case. # while test $CurTC -le $NumTstCases # do # $ROSETTA $RoseOpts -n$CurTC -m $MMask $ExpName $ROSETTA $RoseOpts -c$CurTC -m$MMask $ExpName # (( CurTC = CurTC + 1)) # done #While CurTC < NumTstCases # (( LastTC = CurTC - 1 )) (( LastTC = NumTstCases )) # (tail added to avoid header 5/11/91 AJO) Alive=`$MUTSTAT -c $ExpName | tail -1 | awk '{print $3}'` Hesitate else print "" print "I need a new test case or mutant to execute." Hesitate fi #If $MoreTCs or $MoreMuts ExpWrite } ################################################## # Set automatic test parameters # ################################################## AutoTestPar () { while true do clear PS3=" Enter the number of your choice; M or m to return to main menu; Q or q to quit KMothra: " print "" print "" print " SET AUTO TEST PARAMETERS MENU" print "" print "" select choice in "Set Domain Control" "Set Percent To Be Satisfied" "Satisfaction Factor" "Set Length of Adjustable Array" do print "" case $REPLY in 1) print "Normally, Mothra generates numeric values between -100 and" print "100. Reducing this domain for programs that do not need" print "such a broad domain can increase the efficiency and" print "effectiveness of the satisfaction procedure." print "" read GZ_Bottom?"Bottom of domain: " read GZ_Top?"Top of domain: " GZ_Domain="-Bi$GZ_Bottom -Ti$GZ_Top -Br$GZ_Bottom -Tr$GZ_Top -Bd$GZ_Bottom -Td$GZ_Top" break ;; 2) print "By default, Mothra tries to generate a separate test case" print "to kill each mutant. By choosing a percent P between 0 and" print "100, Mothra will generate a test case for approximately P%" print "of the mutants." print "" while true do read GZ_Per?"Please choose a value between 0 and 100: " if [ $GZ_Per -ge 0 -a $GZ_Per -le 100 ] then break # good input fi done break ;; 3) print "By default, Mothra tries to satisfy each constraint system" print "25 times before giving up. You can modify this by choosing" print "a value greater than 0. Choosing a larger value may cause" print "the satisfaction procedure to succeed, but will slow down" print "the procedure. Choosing a smaller value will speed up the" print "procedure, but may reduce the effectiveness of the test" print "case set. If you choose 0 or less, the value will remain 25." print "" read GZ_Factor?"Satisfaction factor: " if [ $GZ_Factor -le 0 ] then GZ_Factor=25 fi break ;; 4) print "By default, Mothra assumes that all Fortran-77 adjustable" print "arrays will be of length 10. You can modify this by" print "choosing a value greater than 0. If you choose 0 or less," print "the adjustable array length parameter will not be changed." print "" read GZ_AdjArrLen?"Please choose a value greater than 0: " if [ $GZ_AdjArrLen -le 0 ] then GZ_AdjArrLen=10; fi break ;; m) return ;; M) return ;; q) print ""; print "Saving test session $ExpName." ExpWrite; exit 1 ;; Q) print ""; print "Saving test session $ExpName." ExpWrite; exit 1 ;; *) print "Please choose a number from the menu." ; Hesitate; break ;; esac done #with select done #with while } ################################################## # Read test session file. # ################################################## ExpRead () { set -f `cat $ExpName.$EXPEXT` LastTC=$1 shift MoreMuts=$1 shift MoreTCs=$1 shift Total=$1 shift Alive=$1 shift MMask=$1 shift Percent=$1 shift RoseOpts=$1 shift GZ_Per=$1 shift GZ_AdjArrLen=$1 shift GZ_Factor=$1 shift GZ_Domain="$*" } ################################################## # Writes the test session file. # ################################################## ExpWrite () { print $LastTC > $ExpName.$EXPEXT print $MoreMuts >>$ExpName.$EXPEXT print $MoreTCs >>$ExpName.$EXPEXT print $Total >>$ExpName.$EXPEXT print $Alive >>$ExpName.$EXPEXT print $MMask >>$ExpName.$EXPEXT print $Percent >>$ExpName.$EXPEXT print - $RoseOpts >>$ExpName.$EXPEXT print $GZ_Per >>$ExpName.$EXPEXT print $GZ_AdjArrLen >>$ExpName.$EXPEXT print $GZ_Factor >>$ExpName.$EXPEXT print - $GZ_Domain >>$ExpName.$EXPEXT } ################################################################ # Here's the main program. # # Print a nice introductory message. # ################################################################ clear print "" print "" print " MOTHRA" print "" print " Fortran-77 Mutation System" print "" print " KMothra Interface" print "" print "" print "Each test session needs a unique name that is used" print "to create files associated with the test session." print "" ################################################################ # Get the test session name. # ################################################################ while true do #read ExpName?"Choose a test session name (letters and numbers only): " print "Enter the name of an old test session name," print "or supply the name for a new test session" read ExpName?"(letters and numbers only): " if test ! -z "$ExpName" then break fi done #If the test session file is found ... if test -f $ExpName.exp then print "Continuing old test session ..." #Set up the global variables. if test -r $ExpName.$TCEXT then NumTstCases=`$NUMCASES "$ExpName"` else NumTstCases=0 fi ExpRead else print "Initial test session." print "" print "Local source files:" ls *.f *.ftn 2>/dev/null print "" read OrigSrc?"Enter Fortran-77 source file name: " #Loop until a file is found. while true do # Check to see that the file to be tested exists. if test -f "$OrigSrc" then #File is found, go parse it. if test "$OrigSrc" != "$ExpName.$SRCEXT" then cp $OrigSrc $ExpName.$SRCEXT #print "$OrigSrc copied to $ExpName.$SRCEXT." fi break elif test -f "$OrigSrc.$SRCEXT" then #File is found, go parse it. if test "$OrigSrc.$SRCEXT" != "$ExpName.$SRCEXT" then cp $OrigSrc.$SRCEXT $ExpName.$SRCEXT #print "$OrigSrc.$SRCEXT copied to $ExpName.$SRCEXT." fi break elif test -f "$OrigSrc.f" then #File is found, go parse it. cp $OrigSrc.f $ExpName.$SRCEXT break else print "" print "Sorry, I can't find $OrigSrc." print "Please enter a Fortran-77 source file name," read OrigSrc?'or "q" to quit KMOTHRA: ' fi if test "$OrigSrc" = "q" then exit 1 fi done ############################################ # Parse the program. # ############################################ print "Parsing $OrigSrc..." #Save any error messages in .t, count the output lines. #If any, bag it. if [ `$PARSER "$ExpName" "$ExpName.$SRCEXT" 2>&1 | tee $ExpName.t | wc -l` -gt 0 ] then cat $ExpName.t print "ABORTING TEST SESSION $ExpName." $RM -f $ExpName.* exit 1 else $RM -f $ExpName.t fi ################################################################ # Initialize memory. # ################################################################ print "" print "Do you want to initialize your program's memory?" read REPLY?"Enter \"?\" to explain this option: [? y n](n) " if test "$REPLY" = "?" then print "" print "On the Vax 11/780, all memory is automatically initialized to zeroes." print "On some machines, memory is initialized to zeroes before being used." print "On others, memory is left with whatever values were left from previous" print "processes. If your target machine initializes memory differently from" print "your host machine, you may want to use this option for this test session." print "" print "Initializing memory will make a difference in mutants that are killed" print "versus mutants that are equivalent." print "" print "If you initialize memory, you will supply a value [0-255], and every" print "byte in your program's memory space will be initialized to that" print "value when your program is executed." print "" read REPLY?"Do you want to initialize your program's memory? [y n](n) " fi if test "$REPLY" = "y" -o "$REPLY" = "Y" then read value?"What value do you want to use [0-255]? ($MEMDEFAULT) " if test -z "$value" then value=$MEMDEFAULT fi RoseOpts=$RoseOpts" -s "$value fi ################################################################ # Define parameter classes. # ################################################################ read REPLY?"Define parameter classes? [? y n](y) " if test "$REPLY" = "?" then print "" print "A 'class' is an attribute of a variable having one of four possible" print "values: 'in', 'out', 'inout', and 'dontcare'. The values of 'in'" print "variables are declared before execution begins (through test cases)." print "The values of 'out' variables are displayed when execution completes" print "and used for output comparison. The values of 'inout' variables have" print "both these properties, while the values of 'dontcare' variables have" print "neither. The default class is 'dontcare', and such variables are" print "excluded from the test case file." print "" print "If the first program unit in the source program is a main program, you" print "will be prompted for the class of each variable. If the first program" print "unit is a subroutine or a function, you will be prompted for the class" print "of each parameter." print "" print "Variable class declarations may not be changed after the first test" print "case is executed." print "" read REPLY?"Define parameter classes? [y n](y) " fi if test "$REPLY" != "n" -a "$REPLY" != "N" then echo "Header of file is:" head $ExpName.$SRCEXT echo " " $MAPPER -d $ExpName fi ExpWrite fi ################################################################ # Main menu. # ################################################################ while true do clear PS3=" Enter the number of your choice; Q or q to quit KMothra: " #If the mdr file is found ... if test -f $ExpName.$MDREXT then MutScore=`$MUTSTAT -c $ExpName | tail -1 | awk '{print $8}'` else MutScore="0.0" fi print "" print " TEST SESSION NAME: "$ExpName print "" print -n " Test cases: "$NumTstCases" New test cases? " if test $MoreTCs -ne 0 then print "YES" else print "NO" fi print -n " Total mutants: "$Total" New mutants? " if test $MoreMuts -ne 0 then print "YES" else print "NO" fi print " Live mutants: "$Alive print " Mutation score: "$MutScore print "" print "" print " KMOTHRA MAIN MENU" print "" # select choice in "Enter Test Case" "Run Mutants" "View Live Mutants" "View Program Source" "Enable Mutants" "Status Menu" "Test Case Menu" "Run Mutants in Background" "Quit KDemo" #select choice in "Enter Test Case" "Run Mutants" "View Live Mutants" "View Program Source" "Enable Mutants" "Status Menu ==>" "Test Case Menu ==>" select choice in "Create Mutants" "Run Auto Test" "Enter Test Case" "Run Mutants" "View Live Mutants" "View Program Source" "Go To Set Auto Test Parameters ==>" "Go To Status Menu ==>" "Go To Test Case Menu ==>" do print "" case $REPLY in 1) GetMuts ; #Create Mutants break ;; 2) print "This choice may take a long time to execute." read REPLY?"Are you sure you want to do this? [y n](y) " if [ "$REPLY" = "n" -o "$REPLY" = "N" ] then break else AutoTest ; #Run Auto Test fi break ;; 3) GetTC ; #Enter Test Case break ;; 4) ExecMuts ; #Run Mutants break ;; 5) (print " VIEW LIVE MUTANTS SCREEN"; $DECODE -m $ExpName) | $PAGER ; #View Live Mutants Hesitate; break ;; 6) (print " VIEW PROGRAM SOURCE SCREEN"; cat $ExpName.$SRCEXT) | $PAGER ; #View Program Source Hesitate; break ;; 7) AutoTestPar ; #Set Auto Test Parameters break ;; 8) Status ; #Status Menu break ;; 9) TCs ; #Test Case Menu break ;; # 10) print "Background execution started." ; # print "You shouldn't touch this test session until the execution is finished." ; # print "If you do, no telling what will happen." ; # ExpWrite; # #Note that the exp file must be written before bgmut starts. # (nohup $BGMUT $ExpName >>/dev/null&) ; # exit 1 ;; Q) print ""; print "Saving test session $ExpName." ExpWrite; exit 1 ;; q) print ""; print "Saving test session $ExpName." ExpWrite; exit 1 ;; *) print "Please choose a number from the menu." ; Hesitate; break ;; esac done #with select print "" done