joxeankoret

Untitled

Aug 6th, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.26 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. DB1=ls.sqlite
  4. DB2=ls-old.sqlite
  5. DIAPHORA_PATH=../current-diaphora/diaphora.py
  6.  
  7. if [ $# -eq 0 ]; then
  8.   CPU_COUNT=`cat /proc/cpuinfo  | grep "vendor_id" | wc -l`
  9.   CPU_COUNT=`expr $CPU_COUNT - 1`
  10. else
  11.   CPU_COUNT=$1
  12. fi
  13.  
  14. if [ "$2" != "" ]; then
  15.   DB1=$2
  16. fi
  17.  
  18. if [ "$3" != "" ]; then
  19.   DB2=$3
  20. fi
  21.  
  22. export DIAPHORA_CPU_COUNT=1
  23. python $DIAPHORA_PATH -o results.db $DB1 $DB2 >/dev/null
  24.  
  25. expected=`sqlite3 results.db "select count(*) from results where type='best'"`
  26.  
  27. if [ $expected -eq 0 ]; then
  28.   echo "Something went wrong, the diffing returned 0 matches!"
  29.   exit 1
  30. fi
  31.  
  32. echo "[+] Testing with $CPU_COUNT cpu(s), should get $expected 'Best' results..."
  33.  
  34. times=0
  35. #export DIAPHORA_CPU_COUNT=$CPU_COUNT
  36. unset DIAPHORA_CPU_COUNT
  37. while [ 1 ]
  38. do
  39.   times=`expr $times + 1`
  40.   echo "Iteration $times..."
  41.   python $DIAPHORA_PATH -o results.db $DB1 $DB2 | egrep "(Took|Parallel)" | tail -2
  42.   sqlite3 results.db "select * from results where name in (select name from results group by name having count(*) > 1)"
  43.   current=`sqlite3 results.db "select count(*) from results where type='best'"`
  44.   if [ $expected -ne $current ]; then
  45.     echo "INVALID RESULTS!"
  46.     sqlite3 results.db "select type, count(*) from results group by type"
  47.     break
  48.   fi
  49. done
Advertisement
Add Comment
Please, Sign In to add comment