-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmerlin.sh
executable file
·61 lines (43 loc) · 1.17 KB
/
merlin.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
if [ $# -lt 3 ]; then
echo 'Usage: merlin.sh <program_file> <target_function> <input_dir>'
exit 1
fi
PROGRAM=$1
TARGET=$2
INPUT_DIR=$3
EXT="${PROGRAM##*.}"
OUTPUT="temp.$EXT"
RUN_SCRIPT="./scripts/run.sh"
# ----------------------- INSTRUMENTATION -----------------------
cd instrumentation
printf "Compiling instrumentation... "
SETUP_OUT=$(./scripts/setup.sh 2>&1)
printf "done\n"
printf "Instrumenting target program... "
INST_OUT=$($RUN_SCRIPT "../$PROGRAM" $OUTPUT $TARGET)
printf "done\n"
cd output
# ----------- COMPILING AND RUNNING THE TARGET PROGRAM -----------
case $EXT in
"cc" | "cpp") CC="clang++" ;;
"c") CC="clang -std=c99" ;;
esac
$CC $OUTPUT -o temp
TEMP_OUTPUT=""
for i in ../../"$INPUT_DIR"*; do
TEMP_OUTPUT+="$(./temp <"$i")\n"
done
# ------------------------ INTERPOLATION ------------------------
rm temp*
INPUT_FILE=temp_input.txt
echo -e "$TEMP_OUTPUT" >../../interpolation/$INPUT_FILE
cd ../../interpolation
printf "Compiling interpolation... "
MAKE_OUT=$(make 2>&1)
printf "done\n"
python3 produceInput.py $INPUT_FILE $INPUT_FILE
rm $INPUT_FILE
printf "Final output:\n\n"
./bin/interpolator <input/$INPUT_FILE
rm input/$INPUT_FILE