#!/bin/bash DB1=ls.sqlite DB2=ls-old.sqlite DIAPHORA_PATH=../current-diaphora/diaphora.py if [ $# -eq 0 ]; then CPU_COUNT=`cat /proc/cpuinfo | grep "vendor_id" | wc -l` CPU_COUNT=`expr $CPU_COUNT - 1` else CPU_COUNT=$1 fi if [ "$2" != "" ]; then DB1=$2 fi if [ "$3" != "" ]; then DB2=$3 fi export DIAPHORA_CPU_COUNT=1 python $DIAPHORA_PATH -o results.db $DB1 $DB2 >/dev/null expected=`sqlite3 results.db "select count(*) from results where type='best'"` if [ $expected -eq 0 ]; then echo "Something went wrong, the diffing returned 0 matches!" exit 1 fi echo "[+] Testing with $CPU_COUNT cpu(s), should get $expected 'Best' results..." times=0 #export DIAPHORA_CPU_COUNT=$CPU_COUNT unset DIAPHORA_CPU_COUNT while [ 1 ] do times=`expr $times + 1` echo "Iteration $times..." python $DIAPHORA_PATH -o results.db $DB1 $DB2 | egrep "(Took|Parallel)" | tail -2 sqlite3 results.db "select * from results where name in (select name from results group by name having count(*) > 1)" current=`sqlite3 results.db "select count(*) from results where type='best'"` if [ $expected -ne $current ]; then echo "INVALID RESULTS!" sqlite3 results.db "select type, count(*) from results group by type" break fi done
Comments