diff --git a/tools/ps_tne_scripts_p2/analyze b/tools/ps_tne_scripts_p2/analyze index fae79942f90324d836387cef3108526445804617..341204d49fbb77c4ed7b9f8ddc5fd133bee59c71 100755 --- a/tools/ps_tne_scripts_p2/analyze +++ b/tools/ps_tne_scripts_p2/analyze @@ -34,41 +34,7 @@ env > analysis_after.env # cd to the build directory # cd $5 - -# build the package, after breaking the up the "build_commands" -# build_commands=$4 -# begin_of_command=0 -# commands_length=${#build_commands} -# for (( i=0; i<$commands_length; i++ )); do - # c=${build_commands:$i:1} - # if [[ $c == ";" || $i -eq $commands_length-1 ]]; then - # if [[ $i -eq $commands_length-1 ]]; then - # x=${build_commands:$begin_of_command:$i-$begin_of_command+1} - # else - # x=${build_commands:$begin_of_command:$i-$begin_of_command} - # fi - # begin_of_command=$(( i + 1 )) - # echo "**************************************************************************************************" - # echo "Command is: " $x - # echo "**************************************************************************************************" - # eval $x - # nothing before the $? is read from the eval!!!! - # if [[ $? -ne 0 ]]; then - # cd $previous_dir - # env > analysis_after.env - # ss_report_status $7 "<?xml version=1.0 encoding=UTF-8 ?><return_status_message><message_type>analyze_status</message_type><test_case>$1</test_case><ref_id>$6</ref_id><status>skip</status></return_status_message>" - # exit - # fi - # fi -# done -# echo "**************************************************************************************************" - -# cd $previous_dir -# env > analysis_after.env -# ss_report_status $7 "<?xml version=1.0 encoding=UTF-8 ?><return_status_message><message_type>analyze_status</message_type><test_case>$1</test_case><ref_id>$6</ref_id><status>success</status></return_status_message>" - - -#---- CUT HERE - GRAMMATECH STUFF TO DO ACTUAL ANALYZE BELOW ---------------- +# NO BUILD FOR PEASOUP!! export TNE_TEST_CASE="$1" @@ -119,6 +85,7 @@ python $GEN_MESSAGE_COMMAND -n $1 -t "Analyze called" -m "analyze script called # cmdline=($2) # execpath=${cmdline[0]} +# All script debugging stuff echo "arg2 = $2" execcmd=$2 echo "execcmd = $execcmd" @@ -175,7 +142,7 @@ TO_ANALYZE+=("$execcmd") for f in "${TO_ANALYZE[@]}" do echo "Analyzing $f..." >> ps_analyze_log.txt - $PEASOUP_HOME/tools/ps_analyze.sh $f $f.peasoup --step integertransform=off --timeout 7200 >> ps_analyze_log.txt 2>&1 + $PEASOUP_HOME/tools/ps_analyze.sh $f $f.peasoup --step manual_test=off --step determine_program=off --timeout 7200 >> ps_analyze_log.txt 2>&1 PS_ANALYZE_STATUS="$?" python $LOG_COMMAND -n $1 -t "Analyze script" -m "Analysis phase done with exit status: $PS_ANALYZE_STATUS" if [ "$PS_ANALYZE_STATUS" != "0" ] @@ -189,8 +156,6 @@ done # Send a general message that analyze is done python $GEN_MESSAGE_COMMAND -n $1 -t "Analyze complete" -m "analyze script finished" - -# cd $PEASOUP/TestHarness4 if [ "$PS_ANALYZE_STATUS" == "0" ]; then ss_report_status $7 "<?xml version=1.0 encoding=UTF-8 ?><return_status_message><message_type>analyze_status</message_type><test_case>$1</test_case><ref_id>$7</ref_id><status>success</status></return_status_message>" elif [ "$PS_ANALYZE_STATUS" == "142" ]; then @@ -199,4 +164,15 @@ else ss_report_status $7 "<?xml version=1.0 encoding=UTF-8 ?><return_status_message><message_type>analyze_status</message_type><test_case>$1</test_case><ref_id>$7</ref_id><status>skip</status></return_status_message>" fi +# CLEANUP +# It should delete temporary files only +# Any file deleted will not be archived or available for execute + +# Clean the database +${PEASOUP_HOME}/tools/db/drop_my_tables.sh +${PEASOUP_HOME}/tools/db/pdb_setup.sh + +# Remove any temporary files here + +# Remove any left over processes pkill sleep diff --git a/tools/ps_tne_scripts_p2/execute b/tools/ps_tne_scripts_p2/execute index 871e89dfc2ef215b2e4e87ef978a314b80a75f41..2ff8fbec405a513d6bfa575b04b6ae9f6d222de6 100755 --- a/tools/ps_tne_scripts_p2/execute +++ b/tools/ps_tne_scripts_p2/execute @@ -70,6 +70,11 @@ python $GEN_MESSAGE_COMMAND -n $1 -t "Execute called" -m "execute script called cd $4 python $LOG_COMMAND -n $1 -t "Execute script" -m "run dir: $PWD" +# check if the cmd_line ($3) ends with &, if so, need to wait for the batch +# process to be complete and capture the actual return code +# options of grep that used -E, --extended-regexp and -q, --quiet, --silent +echo $3 | grep -qE "&$" +ck_code=$? echo "4" 1>&2 @@ -120,22 +125,40 @@ echo "7" 1>&2 eval cmd="command executed: ${cmdline[@]:0}" python $LOG_COMMAND -n $1 -t "Execute script" -m "$cmd" eval ${cmdline[@]:0} -PS_RUN_STATUS="$?" + +# Block of code from MITRE to handle return code of background command +if [ $ck_code -ne 0 ]; then + # capture the return code + rtn_code=$? + echo "if: ck_code <> 0; rtn_code = $rtn_code" +else + tc_pid=$! + wait $tc_pid + rtn_code=$? + echo "else: ck_code = 0; tc_pid = $tc_pid; rtn_code=$rtn_code" +fi +PS_RUN_STATUS="$rtn_code" + +# report status with the actual rtn_code +ss_report_status $6 "<?xml version=3D1.0 encoding=3DUTF-8 ?><return_status_message><message_type>execute_status</message_type><test_case>$1</test_case><ref_id>$5</ref_id><status>success</status><status_code>$rtn_code</status_code></return_status_message>" + + python $LOG_COMMAND -n $1 -t "Execute script" -m "execution complete with status: $PS_RUN_STATUS" echo "Execute Complete with status $PS_RUN_STATUS" -datapath=dirname `tail -n 1 $execpath|gawk '{print $2}'` +#--- this block commented out - moved to individual peasoup scripts +# datapath=dirname `tail -n 1 $execpath|gawk '{print $2}'` -if [ -f $datapath/diagnostics.out ]; then - len=`cat $datapath/diagnostics.out | wc -l` - if [ $len -gt 0 ]; then +#if [ -f $datapath/diagnostics.out ]; then + #len=`cat $datapath/diagnostics.out | wc -l` + #if [ $len -gt 0 ]; then # make output more concise # wc -l $4/diagnostics.out # sort $4/diagnostics.out | uniq > tmp.$$ - cat $datapath/diagnostics.out | uniq > tmp.$$ - mv tmp.$$ $datapath/diagnostics.out - + #cat $datapath/diagnostics.out | uniq > tmp.$$ + #mv tmp.$$ $datapath/diagnostics.out +# #echo "--------------------------------------------------------" #echo "- PEASOUP DETECTED AND CONFINED ERRORS -" #echo "- (and possibly detected that some errors were benign) -" @@ -144,22 +167,23 @@ if [ -f $datapath/diagnostics.out ]; then #cat $4/diagnostics.out # report detector warnings to test manager - while read line - do - case $line in - POLICY:\ controlled\ exit*) - $GRACE_HOME/concolic/src/util/linux/controlled_exit.py -m "$line" - ;; - POLICY:\ continue\ execution*) - $GRACE_HOME/concolic/src/util/linux/continue_execution.py -m "$line" - ;; - *) - $GRACE_HOME/concolic/src/util/linux/general_message.py -m "$line" - ;; - esac - done < $datapath/diagnostics.out - fi -fi + #while read line + #do + #case $line in + #POLICY:\ controlled\ exit*) + #$GRACE_HOME/concolic/src/util/linux/controlled_exit.py -m "$line" + #;; + #POLICY:\ continue\ execution*) + #$GRACE_HOME/concolic/src/util/linux/continue_execution.py -m "$line" + #;; + #*) + #$GRACE_HOME/concolic/src/util/linux/general_message.py -m "$line" + #;; + #esac + #done < $datapath/diagnostics.out + #fi +#fi +#---------------------- echo "8" 1>&2 # Send a general message that execution has finished @@ -209,4 +233,28 @@ echo "11" 1>&2 # rm /home/ps1/$1_observables.tar #----------------------------------------------------- +#CLEANUP +# It should delete all files created by the analysis step +# since they are already archived by that step. This +# prevents files from being archived twice + +echo "Cleaning..." +pwd +ls -l + +# Save any changed files from peasoup executable folder +# Save off the diagnostics.out and a.ncexe.sigs files +# There might be more than one peasoup_executables folder +# so append the diagnostics.out files together since they +# have the same name +cd /opt/stonesoup/TH-workspace +more peasoup_executable*/diagnostics.out > diagnostics.out +more peasoup_executable*/a.ncexe.sigs.orig >> a.ncexe.sigs.orig +mv peasoup_executable*/a.ncexe.sigs.* . +rm -rf peasoup_executable* + +# Remove the programs - they are archived in analyze +rm -rf built install + +# Kill any left over processes pkill sleep