-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_amd
More file actions
128 lines (113 loc) · 3.39 KB
/
Copy pathrun_amd
File metadata and controls
128 lines (113 loc) · 3.39 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# Simplified script to download test data only
# Copyright © Advanced Micro Devices, Inc., or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
init_globals() {
if [ "$0" != "/bin/bash" ]; then
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
export RUN_SCRIPT_FILE="$(readlink -f "$0")"
else
export RUN_SCRIPT_FILE="$(readlink -f "${BASH_SOURCE[0]}")"
fi
export TOP=$(git rev-parse --show-toplevel 2>/dev/null || pwd)
}
# Utility functions for colored output
c_str() {
local old_color=39
local old_attr=0
local color=39
local attr=0
local text=""
for i in "$@"; do
case "$i" in
r|R) color=31 ;;
g|G) color=32 ;;
y|Y) color=33 ;;
b|B) color=34 ;;
p|P) color=35 ;;
c|C) color=36 ;;
w|W) color=37 ;;
z|Z) color=0 ;;
esac
case "$i" in
l|L|R|G|Y|B|P|C|W) attr=1 ;;
n|N|r|g|y|b|p|c|w) attr=0 ;;
z|Z) attr=0 ;;
*) text="${text}$i"
esac
if [ ${old_color} -ne ${color} ] || [ ${old_attr} -ne ${attr} ]; then
text="${text}\033[${attr};${color}m"
old_color=$color
old_attr=$attr
fi
done
/bin/echo -en "$text"
}
c_echo() {
local old_opt="$(shopt -op xtrace)"
set +x
local text="$(c_str "$@")"
/bin/echo -e "$text\033[0m"
eval "${old_opt}"
}
run_command() {
local status=0
local cmd="$*"
c_echo B "$(date -u '+%Y-%m-%d %H:%M:%S') " W "\$ " G "${cmd}"
[ "$(echo -n "$@")" = "" ] && return 1
"$@"
status=$?
return $status
}
download_testdata_desc() { echo 'Download test data from Docker Hub' ; }
download_testdata() {
c_echo W "Downloading test data..."
run_command mkdir -p "${TOP}/use-cases/hipcim/input"
if [ ! -e "${TOP}/use-cases/hipcim/input/image.tif" ]; then
run_command rm -rf "${TOP}/use-cases/hipcim/input"
id=$(docker create gigony/svs-testdata:little-big)
run_command docker cp $id:/input "${TOP}/use-cases/hipcim"
run_command docker rm -v $id
c_echo G "Test data is downloaded to '${TOP}/use-cases/hipcim/input'!"
else
c_echo G "Test data already exists at '${TOP}/use-cases/hipcim/input'!"
fi
}
print_usage() {
echo "USAGE: $0 [command]"
echo ""
echo "Available commands:"
echo " download_testdata Download test data from Docker Hub"
echo " help Show this help message"
}
main() {
local cmd="$1"
case "$cmd" in
download_testdata)
download_testdata
;;
help|--help|-h)
print_usage
;;
'')
print_usage
;;
*)
echo "Unknown command: $cmd"
print_usage
exit 1
;;
esac
}
init_globals
if [ -n "${SCRIPT_DIR}" ]; then
main "$@"
fi