Skip to content

Commit 1e1f977

Browse files
committed
* experimental directory and runner
1 parent 9b38885 commit 1e1f977

File tree

7 files changed

+317
-0
lines changed

7 files changed

+317
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -le 1 ]
4+
then
5+
echo "Usage: "$0" <Stage Path> [GCC_MACRO]"
6+
echo "Sample: "$0" ./stage -DPROGRAM --static"
7+
exit 1
8+
fi
9+
10+
cd "$1"
11+
12+
#Clean directory
13+
ls | grep -v 'prepare' | xargs rm -f
14+
15+
#Prepare Benchmark Program
16+
CODE=$(cat <<EOF
17+
#include <unistd.h>
18+
int main() {int rn=0;
19+
#ifdef PROGRAM
20+
rn=link("`realpath $1`/test.txt","`realpath $1`/link-test.txt");
21+
#endif
22+
return (rn==-1);}
23+
EOF
24+
)
25+
26+
TMPFILE=$(mktemp -t tmp.XXXXXX.c)
27+
echo "$CODE">$TMPFILE
28+
29+
gcc -o test ${*:2} $TMPFILE
30+
31+
touch test.txt
32+
echo "TEST" > test.txt
33+
34+
rm "$TMPFILE"
35+
chown 1000:1000 *
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -le 1 ]
4+
then
5+
echo "Usage: "$0" <Stage Path> [GCC_MACRO]"
6+
echo "Sample: "$0" ./stage -DPROGRAM --static"
7+
exit 1
8+
fi
9+
10+
cd "$1"
11+
12+
#Clean directory
13+
ls | grep -v 'prepare' | xargs rm -f
14+
15+
#Prepare Benchmark Program
16+
CODE=$(cat <<EOF
17+
#include<unistd.h>
18+
#include<fcntl.h>
19+
int main() {int d=open("`realpath $1`",O_DIRECTORY); int rn=0;
20+
#ifdef PROGRAM
21+
rn=linkat(d,"test.txt",d, "linkat-test.txt",0);
22+
#endif
23+
close(d);
24+
return (rn==-1);}
25+
EOF
26+
)
27+
28+
TMPFILE=$(mktemp -t tmp.XXXXXX.c)
29+
echo "$CODE">$TMPFILE
30+
31+
gcc -o test ${*:2} $TMPFILE
32+
33+
touch test.txt
34+
echo "TEST" > test.txt
35+
36+
rm "$TMPFILE"
37+
chown 1000:1000 *
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -le 1 ]
4+
then
5+
echo "Usage: "$0" <Stage Path> [GCC_MACRO]"
6+
echo "Sample: "$0" ./stage -DPROGRAM --static"
7+
exit 1
8+
fi
9+
10+
cd "$1"
11+
12+
#Clean directory
13+
ls | grep -v 'prepare' | xargs rm -f
14+
15+
#Prepare Benchmark Program
16+
CODE=$(cat <<EOF
17+
#include <unistd.h>
18+
int main() {int rn=0;
19+
#ifdef PROGRAM
20+
rn=symlink("`realpath $1`/test.txt","`realpath $1`/symlink-test.txt");
21+
unlink("`realpath $1`/symlink-test.txt");
22+
rn=symlink("`realpath $1`/test.txt","`realpath $1`/symlink-test.txt");
23+
unlink("`realpath $1`/symlink-test.txt");
24+
#endif
25+
return (rn==-1);}
26+
EOF
27+
)
28+
29+
TMPFILE=$(mktemp -t tmp.XXXXXX.c)
30+
echo "$CODE">$TMPFILE
31+
32+
gcc -o test ${*:2} $TMPFILE
33+
34+
touch test.txt
35+
echo "TEST" > test.txt
36+
37+
rm "$TMPFILE"
38+
chown 1000:1000 *
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -le 1 ]
4+
then
5+
echo "Usage: "$0" <Stage Path> [GCC_MACRO]"
6+
echo "Sample: "$0" ./stage -DPROGRAM --static"
7+
exit 1
8+
fi
9+
10+
cd "$1"
11+
12+
#Clean directory
13+
ls | grep -v 'prepare' | xargs rm -f
14+
15+
#Prepare Benchmark Program
16+
CODE=$(cat <<EOF
17+
#include <unistd.h>
18+
#include <fcntl.h>
19+
int main() {int d=open("`realpath $1`",O_DIRECTORY); int rn=0;
20+
#ifdef PROGRAM
21+
rn=symlinkat("test.txt",d,"symlinkat-test.txt");
22+
#endif
23+
close(d);
24+
return (rn==-1);}
25+
EOF
26+
)
27+
28+
TMPFILE=$(mktemp -t tmp.XXXXXX.c)
29+
echo "$CODE">$TMPFILE
30+
31+
gcc -o test ${*:2} $TMPFILE
32+
33+
touch test.txt
34+
echo "TEST" > test.txt
35+
36+
rm "$TMPFILE"
37+
chown 1000:1000 *
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -le 1 ]
4+
then
5+
echo "Usage: "$0" <Stage Path> [GCC_MACRO]"
6+
echo "Sample: "$0" ./stage -DPROGRAM --static"
7+
exit 1
8+
fi
9+
10+
cd "$1"
11+
12+
#Clean directory
13+
ls | grep -v 'prepare' | xargs rm -f
14+
15+
#Prepare Benchmark Program
16+
CODE=$(cat <<EOF
17+
#include <stdio.h>
18+
int main() {int rn=0;
19+
#ifdef PROGRAM
20+
rn=rename("`realpath $1`/test.txt","`realpath $1`/rename-test.txt");
21+
#endif
22+
return (rn!=-1);}
23+
EOF
24+
)
25+
26+
TMPFILE=$(mktemp -t tmp.XXXXXX.c)
27+
echo "$CODE">$TMPFILE
28+
gcc -o test ${*:2} $TMPFILE
29+
30+
rm -f test.txt
31+
32+
rm "$TMPFILE"
33+
chown 1000:1000 *
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -le 1 ]
4+
then
5+
echo "Usage: "$0" <Stage Path> [GCC_MACRO]"
6+
echo "Sample: "$0" ./stage -DPROGRAM --static"
7+
exit 1
8+
fi
9+
10+
cd "$1"
11+
12+
#Clean directory
13+
ls | grep -v 'prepare' | xargs rm -f
14+
15+
#Prepare Benchmark Program
16+
CODE=$(cat <<EOF
17+
#include<stdio.h>
18+
#include<fcntl.h>
19+
#include<unistd.h>
20+
int main() {int d=open("`realpath $1`",O_DIRECTORY); int rn=0;
21+
#ifdef PROGRAM
22+
rn=renameat(d,"test.txt",d, "renameat-test.txt");
23+
#endif
24+
close(d);
25+
return (rn!=-1);}
26+
EOF
27+
)
28+
29+
TMPFILE=$(mktemp -t tmp.XXXXXX.c)
30+
echo "$CODE">$TMPFILE
31+
32+
gcc -o test ${*:2} $TMPFILE
33+
34+
rm -f test.txt
35+
36+
rm "$TMPFILE"
37+
chown 1000:1000 *
38+

runExperiments.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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

Comments
 (0)