-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_example.sh
More file actions
executable file
·112 lines (92 loc) · 2.28 KB
/
Copy pathbuild_example.sh
File metadata and controls
executable file
·112 lines (92 loc) · 2.28 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env bash
# build_example.sh
set -euo pipefail
usage() {
cat <<'EOF'
Usage:
./build_example.sh <keyword> [--position]
Description:
Runs the opencv stress-test case using the revisions configured in
test/stress/opencv/info.json, then copies the generated srcDiff and srcMove
XML outputs into examples/ using the requested keyword.
Examples:
./build_example.sh baseline
./build_example.sh baseline --position
EOF
}
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repo_root="$script_dir"
stress_runner="$repo_root/test/stress/diff_and_move_repo.py"
stress_case="wowy_advanced_analytics"
stress_work_dir="$repo_root/test/stress/$stress_case/work"
examples_dir="$repo_root/examples"
keyword=""
use_position=0
while (($# > 0)); do
case "$1" in
--position)
use_position=1
shift
;;
-h | --help)
usage
exit 0
;;
-*)
echo "error: unknown option: $1" >&2
usage >&2
exit 1
;;
*)
if [[ -n "$keyword" ]]; then
echo "error: expected exactly one keyword argument" >&2
usage >&2
exit 1
fi
keyword="$1"
shift
;;
esac
done
if [[ -z "$keyword" ]]; then
echo "error: missing keyword" >&2
usage >&2
exit 1
fi
if [[ ! "$keyword" =~ ^[A-Za-z0-9._-]+$ ]]; then
echo "error: keyword may only contain letters, numbers, dot, underscore, and hyphen" >&2
exit 1
fi
if [[ ! -f "$stress_runner" ]]; then
echo "error: stress runner not found: $stress_runner" >&2
exit 1
fi
runner_cmd=(python3 "$stress_runner" "$stress_case")
if ((use_position)); then
runner_cmd+=(--position)
fi
echo "Running stress case: $stress_case"
"${runner_cmd[@]}"
src_diff="$stress_work_dir/diff.xml"
src_move="$stress_work_dir/diff_new.xml"
if [[ ! -f "$src_diff" ]]; then
echo "error: expected generated diff file not found: $src_diff" >&2
exit 1
fi
if [[ ! -f "$src_move" ]]; then
echo "error: expected generated move diff file not found: $src_move" >&2
exit 1
fi
mkdir -p "$examples_dir"
name_prefix="$stress_case.$keyword"
if ((use_position)); then
name_prefix="$name_prefix.position"
fi
dest_diff="$examples_dir/$name_prefix.diff.xml"
dest_move="$examples_dir/$name_prefix.move.diff.xml"
cp "$src_diff" "$dest_diff"
cp "$src_move" "$dest_move"
echo
echo "Saved example files:"
echo " $dest_diff"
echo " $dest_move"