#!/bin/bash if [ $# -ne 3 ] ; then echo "Usage: $0 <(ins) mut dir (absolute path)> Run first: - pick_mutants - tables/faults (check methods and distributions) - instr_mutants (optional) Args: - , the dir resulting from pick_mutants or instr_mutants (absolute path) - , the dir in which to place the created packages (absolute path) - , the application (cws=crosswordsage-0.3.5 or fm7=freemind-0.7.1 or fm8=freemind-0.8.0) Constants: - & , the minimum and maximum test-case length (depends on the application) Affects: - Creates in a set of packages, which are zip files each containing: - mut_class, a dir containing the class file(s) from - mut_path.txt, a file containing the path to the class file in - tst_len.txt, a file containing the length of test cases to be generated Makes each of these files in the zip read-only." exit 1 fi MUT_DIR=$1 PKG_DIR=$2 APP=$3 MUT_DIR=${MUT_DIR%/} PKG_DIR=${PKG_DIR%/} if [ "$APP" == "cws" ] ; then MIN_TST_LEN=6 # depth of EFG MAX_TST_LEN=20 elif [ "$APP" == "fm7" ] ; then MIN_TST_LEN=3 # depth of EFG MAX_TST_LEN=20 elif [ "$APP" == "fm8" ] ; then MIN_TST_LEN=4 # depth of EFG MAX_TST_LEN=20 else echo "Error: must be 'cws', 'fm7', or 'fm8'" exit 1 fi RANGE_TST_LEN=`expr $MAX_TST_LEN - $MIN_TST_LEN + 1` TMP=/tmp/strecker mkdir -p $PKG_DIR for MUT in `echo $MUT_DIR/*` ; do if [ $MUT != "$MUT_DIR/index" ] ; then MUT_NAME=`basename $MUT`; if [ -e $TMP/$MUT_NAME ] ; then chmod -R u+w $TMP/$MUT_NAME rm -rf $TMP/$MUT_NAME fi mkdir $TMP/$MUT_NAME cd $TMP/$MUT_NAME MUT_LINE=`grep "^$MUT_NAME " $MUT_DIR/index` PACKAGE=`echo $MUT_LINE | perl -pe 's|.*/([^/]+)/traditional_mutants/.*|$1|; s|.*/([^/]+)/class_mutants/.*|$1|; s|\.|/|g; s|/[^/]+$||'` mkdir -p mut_class/$PACKAGE cp -r $MUT/*.class mut_class/$PACKAGE/ echo $MUT_LINE | perl -lane 'print $F[1]' > mut_path.txt TST_LEN=`perl -e "print int(rand($RANGE_TST_LEN)) + $MIN_TST_LEN"` echo "$TST_LEN" > tst_len.txt cd .. chmod -R a-w $MUT_NAME/* zip -r $MUT_NAME $MUT_NAME mv $MUT_NAME.zip $PKG_DIR/ chmod -R u+w $TMP/$MUT_NAME rm -rf $TMP/$MUT_NAME fi done