From 079ff9a5fb026edd0fe886866d374105e937b3c8 Mon Sep 17 00:00:00 2001 From: Clark Coleman <clc@zephyr-software.com> Date: Tue, 2 Apr 2019 13:18:27 -0400 Subject: [PATCH] Update CICD test scripts. --- SMP-fullanalyze64-ida7.sh | 58 +++++++++++++++++++++++++++++++++++++++ cicd_testing/do-build.sh | 43 +++++++++++++++++++---------- cicd_testing/do-clean.sh | 20 ++++++++------ cicd_testing/starstest.sh | 49 +++++++++++++++++++++++++++++++++ cicd_testing/xform-ls.sh | 11 ++++++++ 5 files changed, 157 insertions(+), 24 deletions(-) create mode 100755 SMP-fullanalyze64-ida7.sh create mode 100755 cicd_testing/starstest.sh create mode 100755 cicd_testing/xform-ls.sh diff --git a/SMP-fullanalyze64-ida7.sh b/SMP-fullanalyze64-ida7.sh new file mode 100755 index 00000000..746c1ec6 --- /dev/null +++ b/SMP-fullanalyze64-ida7.sh @@ -0,0 +1,58 @@ +#!/bin/sh +# Make terminal ansi-color +export TVOPT=ansi +# Fix screwed-up LD environment on power machines. +# export LD_LIBRARY_PATH=/uf1/jdh8d/RA/NICECAP/idapro_lib/ +export LD_LIBRARY_PATH=${IDAROOT} +# Set IDA path. +export IDADIR=$IDAROOT +# Make sure that the idal executable can be reached from PATH. +export PATH=$PATH:$IDADIR +export STARS_ROOT_FILENAME=$1 +export IDALOG=$1.log +# export IDALOG_SILENT=1 +# Extract the code addresses with objdump. +objdump -d --prefix-addresses $1 | grep "^[0-9]" > $1.SMPobjdump + +# Extract the exception-handling function target addresses. +# dwarfdump -F $1 | grep "^<" | cut --delimiter="<" --field=3 | cut --delimiter=":" --field=1 | cut --bytes 4-10 > $1.eh_frame_addrs +# Make readelf do the same thing as the above dwarfdump command, to +# eliminate configuration dependence on dwarfdump. +readelf -wF $1 | grep "pc=" | cut --delimiter="=" --field=3 | cut --delimiter="." --field=1 > $1.eh_frame_addrs + +if [ "${IDAROOT}"X = "X" ]; then echo Please set IDAROOT; exit 1; fi +if [ ! -f ${IDAROOT}/libida.so ]; then echo IDAROOT is set poorly, please fix.; exit 1; fi + + +# remove tmp files +rm -f $1.id? $1.{i64,nam,til,log,syms} +rm -f `basename $1 .psexe`.{i64,nam,til} `basename $1 .psexe`.id? +rm -f `basename $1 .ncexe`.{i64,nam,til} `basename $1 .ncexe`.id? +rm -f `basename $1 .exe`.{i64,nam,til} `basename $1 .exe`.id? + +old_stty=`stty -g` + + + +# Run the linux IDA Pro with the SMPStaticAnalyzer plugin. +# jdh - added -B for batch mode, avoids any prompts. +# jdh - note: can't use -B, as the plugin doesn't run! + +# TVHEADLESS=1 time ${IDAROOT}/idat64 -A -Telf -OSMPStaticAnalyzer:run $1 2>&1 >/dev/null + +# TVHEADLESS=1 time ${IDAROOT}/idat64 -A -SSMP.idc -OSMPStaticAnalyzer:ShadowFuncPtrs:ShadowArgs:ImproveCFG:AnalyzeLoops:SCCP:NoGenAsm $1 > $1.idaoutput + +TVHEADLESS=1 time ${IDAROOT}/idat64 -A -SSMP7noasm.idc -OSMPStaticAnalyzer:ShadowFuncPtrs:ShadowArgs:ImproveCFG:AnalyzeLoops:SCCP:NoGenAsm $1 > $1.idaoutput + +# TVHEADLESS=1 time ${IDAROOT}/idat64 -A -SSMP7.idc -OSMPStaticAnalyzer:ShadowFuncPtrs:ShadowArgs:ImproveCFG:AnalyzeLoops:SCCP:NoGenAsm $1 > $1.idaoutput + +# TVHEADLESS=1 valgrind -v --leak-check=full --show-reachable=yes --track-origins=yes --log-file=$1.valgrind.log ${IDAROOT}/idat64 -A -SSMP7.idc $1 + + +# SMP seems to mess up the terminal, using this to fix it. +/usr/bin/reset +stty $old_stty + +# Get the output file SMP.syms into $1.syms. +# mv SMP.annot $1.annot + diff --git a/cicd_testing/do-build.sh b/cicd_testing/do-build.sh index 2834f534..f6d3fa13 100755 --- a/cicd_testing/do-build.sh +++ b/cicd_testing/do-build.sh @@ -1,21 +1,34 @@ -#!/bin/bash +#/bin/bash + set -e set -x +main() +{ + + # gather info for debugging later, probably not necessary + pwd + hostname + whoami + env|grep "^CICD" + + local orig_dir=$(pwd) + + # puts peasoup_umbrella (and all submodules) in CICD_MODULE_WORK_DIR + cicd_setup_module_dependency allnp/peasoup_umbrella.git stars_umbrella + + + # puts the version of zipr to test in stars_umbrella/SMPStaticAnalyzer. + cicd_put_module_in_tree stars_umbrella/SMPStaticAnalyzer -# update submodules -git submodule sync --recursive -git submodule update --recursive --init -# gather info for debugging later, probably not necessary -pwd -hostname -whoami -env|grep CICD + # Build peasoup_umbrella as stars_umbrella + cd $CICD_MODULE_WORK_DIR/stars_umbrella + source set_env_vars + sudo ./get-peasoup-packages.sh all + ./build-all.sh + dropdb $PGDATABASE 2>/dev/null || true ; ./postgres_setup.sh -time rsync -a --exclude='.git' $CICD_TO_TEST_DIR/ /tmp/stars_test -cd /tmp/stars_test -# source set_env_vars -# sudo ./get-peasoup-packages.sh all -# ./build-all.sh -# bash -x ./postgres_setup.sh + cd $orig_dir +} +main "$@" diff --git a/cicd_testing/do-clean.sh b/cicd_testing/do-clean.sh index b279cdf4..409081b3 100755 --- a/cicd_testing/do-clean.sh +++ b/cicd_testing/do-clean.sh @@ -1,20 +1,22 @@ -#!/bin/bash +#/bin/bash + set -e set -x main() { - if [[ $CICD_NIGHTLY == 1 ]] ; then - # gather info for debugging later, probably not necessary - pwd - hostname - whoami - env|grep CICD + # gather info for debugging later, probably not necessary + pwd + hostname + whoami + env|grep "^CICD" + - rm -rf /tmp/stars_test + if [[ $CICD_NIGHTLY == 1 ]] ; then + rm -rf $CICD_MODULE_WORK_DIR/stars_umbrella fi + } main "$@" - diff --git a/cicd_testing/starstest.sh b/cicd_testing/starstest.sh new file mode 100755 index 00000000..0e865a88 --- /dev/null +++ b/cicd_testing/starstest.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Usage: + +function validate { + if grep "FROMIB COMPLETE 20 SWITCHTABLE" $1.STARSxrefs > /dev/null; then + if grep "FROMIB COMPLETE 1 RETURNTARGET" $1.STARSxrefs > /dev/null; then + if tail $1.infoannot | grep "SUCCESS ANALYSISCOMPLETED" > /dev/null; then + echo "STARS success" + exitstatus=0 + else + echo "Failed to find SUCCESS ANALYSISCOMPLETED annotation" + exitstatus=1 + fi + else + echo "Failed to find any COMPLETE RETURNTARGET xref annotations" + exitstatus=2 + fi + else + echo "Failed to find COMPLETE 20 SWITCHTABLE xref annotation" + exitstatus=3 + fi + return $exitstatus +} + +function test { + ./$SMPSA_HOME/SMP-fullanalyze64-ida7.sh $1 + validate $1 +} + +# Pass in optimization level string, e.g. O0, Og, or O3 +function build { + rm -f starstest_$1.exe + gcc -m64 -$1 -o starstest_$1.exe starstest.c +} + +# Pass in optimization level string, e.g. O0, Og, or O3 +function build_and_test { + build $1 + test starstest_$1.exe +} + +# Build and test each of the optimization levels -O0, -Og, and -O3. +if build_and_test O0 ; then + if build_and_test Og ; then + build_and_test O3 + fi +fi + + diff --git a/cicd_testing/xform-ls.sh b/cicd_testing/xform-ls.sh new file mode 100755 index 00000000..ffcea7fc --- /dev/null +++ b/cicd_testing/xform-ls.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +set -x + +cd $CICD_MODULE_WORK_DIR/stars_umbrella +source set_env_vars +cd /tmp +rm -rf ls.stars.killdeads stars_ped_ls; $PSZ /bin/ls ./ls.stars.killdeads -c rida=on -s meds_static=off -c kill_deads=on --tempdir stars_ped_ls || true +if [[ ! -x ./ls.stars.killdeads ]]; then cat stars_ped_ls/logs/*; fi +rm -rf stars_ped_ls +./ls.stars.killdeads -- GitLab