|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +if [[ "$#" -lt 3 || ("$3" != "rb" && "$3" != "rg" && "$3" != "rh") ]] |
| 4 | +then |
| 5 | + echo "Usage: "$0" <Tools> <Tools_Path> <Result Type> <Num Trials>" |
| 6 | + echo "Result Type:" |
| 7 | + echo "rb: benchmark only" |
| 8 | + echo "rg: benchmark and generalized foreground and background graph only" |
| 9 | + echo "rh: html page displaying benchmark and generalied foreground and background graph" |
| 10 | + exit 1 |
| 11 | +fi |
| 12 | + |
| 13 | +sudo mkdir finalResult > /dev/null 2>&1 |
| 14 | +row="" |
| 15 | +for i in `ls benchmarkProgram/expSyscall` |
| 16 | +do |
| 17 | + for j in `ls benchmarkProgram/expSyscall/$i` |
| 18 | + do |
| 19 | + syscall=${j:3} |
| 20 | + syscall=${syscall,,} |
| 21 | + if [ -e finalResult/$syscall ] |
| 22 | + then |
| 23 | + sudo rm -f finalResult/$syscall/* |
| 24 | + else |
| 25 | + sudo mkdir finalResult/$syscall > /dev/null 2>&1 |
| 26 | + fi |
| 27 | + |
| 28 | + echo "Generating provenance benchmark for $syscall in group $i using $1 settings..." |
| 29 | + sudo ./fullAutomation.py $1 $2 benchmarkProgram/expSyscall/$i/$j $4 |
| 30 | + |
| 31 | + unset benchmark |
| 32 | + for result in `ls result/result-*.clingo` |
| 33 | + do |
| 34 | + fingerprint=`echo $result | cut -d- -f2 | cut -d. -f1` |
| 35 | + sudo cp $result "finalResult/$syscall/benchmark-$fingerprint.clingo" |
| 36 | + sudo genClingoGraph/clingo2Dot.py $result $fingerprint.dot |
| 37 | + sudo dot -Tsvg -o "finalResult/$syscall/benchmark-$fingerprint.svg" $fingerprint.dot |
| 38 | + sudo rm -f $fingerprint.dot |
| 39 | + if [ ! -z $benchmark ] |
| 40 | + then |
| 41 | + benchmark=$benchmark"<br/><hr/><br/>" |
| 42 | + fi |
| 43 | + benchmark=$benchmark$(cat template/element.html | sed "s|@@@ELEMENT@@@|benchmark-${fingerprint}|g") |
| 44 | + done |
| 45 | + |
| 46 | + if [ "$3" != "rb" ] |
| 47 | + then |
| 48 | + unset background |
| 49 | + for result in `ls result/general.clingo-control-*` |
| 50 | + do |
| 51 | + fingerprint=`echo $result | cut -d- -f3` |
| 52 | + sudo cp $result "finalResult/$syscall/background-$fingerprint.clingo" |
| 53 | + sudo genClingoGraph/clingo2Dot.py $result $fingerprint.dot |
| 54 | + sudo dot -Tsvg -o "finalResult/$syscall/background-$fingerprint.svg" $fingerprint.dot |
| 55 | + sudo rm -f $fingerprint.dot |
| 56 | + if [ ! -z $background ] |
| 57 | + then |
| 58 | + background=$background"<br/><hr/><br/>" |
| 59 | + fi |
| 60 | + background=$background$(cat template/element.html | sed "s|@@@ELEMENT@@@|background-${fingerprint}|g") |
| 61 | + done |
| 62 | + |
| 63 | + unset foreground |
| 64 | + for result in `ls result/general.clingo-program-*` |
| 65 | + do |
| 66 | + fingerprint=`echo $result | cut -d- -f3` |
| 67 | + sudo cp $result "finalResult/$syscall/foreground-$fingerprint.clingo" |
| 68 | + sudo genClingoGraph/clingo2Dot.py $result $fingerprint.dot |
| 69 | + sudo dot -Tsvg -o "finalResult/$syscall/foreground-$fingerprint.svg" $fingerprint.dot |
| 70 | + sudo rm -f $fingerprint.dot |
| 71 | + if [ ! -z $foreground ] |
| 72 | + then |
| 73 | + foreground=$foreground"<br/><hr/><br/>" |
| 74 | + fi |
| 75 | + foreground=$foreground$(cat template/element.html | sed "s|@@@ELEMENT@@@|foreground-${fingerprint}|g") |
| 76 | + done |
| 77 | + |
| 78 | + if [ "$3" = "rh" ] |
| 79 | + then |
| 80 | + newrow=$(cat template/row.html | sed "s|@@@BACKGROUND@@@|${background}|g") |
| 81 | + newrow=$(echo $newrow | sed "s|@@@FOREGROUND@@@|${foreground}|g") |
| 82 | + newrow=$(echo $newrow | sed "s|@@@BENCHMARK@@@|${benchmark}|g") |
| 83 | + newrow=$(echo $newrow | sed "s|@@@SYSCALL@@@|${syscall}|g") |
| 84 | + |
| 85 | + row=$row$newrow |
| 86 | + fi |
| 87 | + fi |
| 88 | + |
| 89 | + echo "Process complete for $syscall." |
| 90 | + done |
| 91 | +done |
| 92 | + |
| 93 | +if [ "$3" = "rh" ] |
| 94 | +then |
| 95 | + html=$(sudo cat template/base.html) |
| 96 | + echo "${html%@@@TABLEROW@@@*} $row ${html##*@@@TABLEROW@@@}" | sudo tee finalResult/index.html > /dev/null |
| 97 | +fi |
| 98 | + |
| 99 | +echo "Process done. Result in finalResult directory." |
0 commit comments