-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsave_results
executable file
·216 lines (197 loc) · 4.61 KB
/
save_results
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/bin/bash
#
# Copyright (C) 2024 David Valin dvalin@redhat.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#
# Common code for the test wrappers to call to save the run data.
#
curdir=""
home_root=""
other_files=""
copy_dir=""
results=""
tar_file=""
test_name=""
tuned_setting=""
version=""
user=""
copy_file()
{
ls $1 &> /dev/null
if [[ $? -eq 0 ]]; then
if [[ $1 != "" ]] && [[ $2 != "" ]] && [[ ! -f $2 ]]; then
cp -R $1 $2
fi
fi
}
link_files()
{
if [[ -f $1 ]] && [[ ! -f $2 ]]; then
ln -s $1 $2
fi
}
usage()
{
echo "Usage $1:"
echo " --copy_dir <dir>: export the entire directory"
echo " --curdir <dir> : the directory we started at before running the wrapper"
echo " --home_root <dir>: Running users home directory"
echo " --other_files <file,file,...>: comma separated list of files want to export"
echo " --results <file>: results file to export"
echo " --tar_file <tar ball>: tar file that we want to export"
echo " --test_name <name>: name of the test we are saving data for"
echo " --tuned_setting <tuned setting>: tuned settings"
echo " --version <version # or None>: Version number of the test."
echo " --user <name>: name of the user who ran the wrapper"
exit 1
}
ARGUMENT_LIST=(
"copy_dir"
"curdir"
"home_root"
"other_files"
"results"
"tar_file"
"test_name"
"tuned_setting"
"version"
"user"
)
NO_ARGUMENTS=(
"usage"
)
opts=$(getopt \
--longoptions "$(printf "%s:," "${ARGUMENT_LIST[@]}")" \
--longoptions "$(printf "%s," "${NO_ARGUMENTS[@]}")" \
--name "$(basename "$0")" \
--options "h" \
-- "$@"
)
eval set --$opts
if [[ $? -ne 0 ]] || [[ $# -eq 1 ]]; then
usage $0
fi
while [[ $# -gt 0 ]]; do
case "$1" in
--copy_dir)
copy_dir=$2
shift 2
;;
--curdir)
curdir=$2
shift 2
;;
--home_root)
home_root=$2
shift 2
;;
--other_files)
other_files=$2
shift 2
;;
--results)
results=$2
shift 2
;;
--tar_file)
tar_file=$2
shift 2
;;
--test_name)
test_name=$2
shift 2
;;
--tuned_setting)
tuned_setting=$2
shift 2
;;
--version)
version=$2
shift 2
;;
--user)
user=$2
shift 2
;;
--usage)
usage $0
;;
-h)
usage $0
;;
--)
break
;;
*)
echo option not found $1
usage $0
;;
esac
done
if [[ $curdir == "" ]]; then
curdir=`pwd`
fi
if [[ $user == "" ]] && [[ $home_root == "" ]]; then
$home_root=$curdir
fi
export_results="$home_root/$user/export_results"
if [[ ! -d $export_results ]]; then
mkdir $export_results
fi
time_stamp=`date "+%Y.%m.%d-%H.%M.%S"`
results_dir=${test_name}_${time_stamp}
RESULTS_PATH=${export_results}/${results_dir}
mkdir -p ${RESULTS_PATH}
copy_file $results $RESULTS_PATH
if [[ $other_files != "" ]]; then
file_list=`echo $other_files | sed "s/,/ /g"`
for i in $file_list; do
copy_file $i $RESULTS_PATH
done
fi
if [[ $tar_file != "" ]]; then
pushd $RESULTS_PATH
tar xf $tar_file
popd
fi
if [[ $copy_dir != "" ]]; then
cp -R $copy_dir $RESULTS_PATH
fi
if [[ $version == "" ]]; then
echo tag: No version provided > $RESULTS_PATH/version
else
echo commit: ${version} > $RESULTS_PATH/version
fi
pushd $export_results > /dev/null
copy_file ${curdir}/meta_data*.yml ${RESULTS_PATH}
copy_file ${curdir}/hw_info.out ${RESULTS_PATH}
tar hcf results_${test_name}_${tuned_setting}.tar ${results_dir}
copy_file ${results_dir}/* .
link_files results_${test_name}_${tuned_setting}.tar results_pbench_${test_name}_${tuned_setting}.tar
tardir=`pwd`
link_files ${tardir}/results_${test_name}_${tuned_setting}.tar /tmp/results_${test_name}_${tuned_setting}.tar
link_files ${tardir}/results_${test_name}_${tuned_setting}.tar /tmp/results_pbench_${test_name}_${tuned_setting}.tar
cd /tmp
#
# Provide a common pull for Zathra.
#
if [[ -f test_wrapper_results_${test}.zip ]]; then
rm test_wrapper_results_${test}.zip test_wrapper_results_pbench_${test}.zip
fi
zip results_${test_name}.zip results_${test_name}_${tuned_setting}.tar
link_files results_${test_name}.zip results_pbench_${test_name}.zip
popd > /dev/null