forked from plasma-disassembler/plasma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diff.sh
executable file
·87 lines (74 loc) · 1.55 KB
/
diff.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
color() {
local color="$1"
if [ "$3" == "" ]; then
local prefix=""
local txt="$2"
else
local prefix="$2 "
local txt="$3"
fi
echo -en "${prefix}\x1b[;${color}m${txt}\x1b[0m"
}
red() {
color 31 "$1" "$2"
}
green() {
color 32 "$1" "$2"
}
OPTIONS="--nosectionsname --nocolor"
VERBOSE=0
__diff() {
local name=$1
local suffix=""
local more_opt=""
local tmp=tmp$$
if [ "$2" != "" ]; then
local more_opt="-x=$2"
local suffix="_$2"
fi
if [ -f "tests/${name}${suffix}.rev" ]; then
./reverse.py "tests/${name}.bin" $more_opt $OPTIONS >$tmp 2>/dev/null
if [ $? -eq 0 ]; then
if [ $VERBOSE -eq 1 ]; then
diff $tmp "tests/${name}${suffix}.rev"
else
diff -q $tmp "tests/${name}${suffix}.rev" >/dev/null
fi
if [ $? -eq 0 ]; then
green "$name$suffix" "[OK]\n"
else
red "$name$suffix" "[FAIL]\n"
fi
rm $tmp
else
red "$name$suffix" "[EXCEPTION]\n"
fi
else
red "$name$suffix" "[NOT FOUND]\n"
fi
}
name=`basename "$1" .rev`
shift
while true; do
case "$1" in
"1")
VERBOSE=1
;;
-*)
OPTIONS="$OPTIONS $1"
;;
*)
break
;;
esac
shift
done
if [ "$1" == "" ]; then
__diff "$name"
else
while [ "$1" != "" ]; do
__diff "$name" "$1"
shift
done
fi