-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_PrepareAllTestData.sh
executable file
·296 lines (246 loc) · 11.4 KB
/
run_PrepareAllTestData.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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#!/bin/bash
#***************************************************************************************
# brief:
# --delete previous test data,
# --prepare test space for all test sequences in AllTestData/XXX.yuv
#
# --usage: refer to function runUsage()
#
#date: 5/08/2014 Created
#***************************************************************************************
runUsage()
{
echo -e "\033[32m ************************************************************************** \033[0m"
echo -e "\033[31m usage: run_PrepareAllTestFolder.sh \$TestType \$ConfigureFile \033[0m"
echo -e "\033[31m \$OpenH264Branch \$OpenH264Repos \033[0m"
echo -e "\033[31m \$SourceFolder \$ReposUpdateOption \033[0m"
echo -e "\033[31m --last four parameters are optional \033[0m"
echo -e "\033[31m which used to overwrite value in configure file \033[0m"
echo -e "\033[31m --ReposUpdateOption: fast or colone \033[0m"
echo -e "\033[31m ----fast: update repos via git pull only \033[0m"
echo -e "\033[31m ----clone: clone a new repos \033[0m"
echo -e "\033[31m \033[0m"
echo -e "\033[31m example: \033[0m"
echo -e "\033[31m ./run_PrepareAllTestFolder.sh LocalTest case_SVC.cfg \033[0m"
echo -e "\033[31m \033[0m"
echo -e "\033[32m ************************************************************************** \033[0m"
}
runGlobalVariableInitial()
{
CurrentDir=`pwd`
#the same with run_main.sh
AllTestDataFolder="AllTestData";SHA1TableFolder="SHA1Table";FinalResultDir="FinalResult"
CodecFolder="Codec";Codec_Linux="Codec_Linux";Codec_Mac="Codec_Mac"
Tools32Bits="${Codec_Linux}/Tools32Bits"
Tools64Bits="${Codec_Linux}/Tools64Bits"
ToolsAppDir="${Tools32Bits}"
ScriptFolder="Scripts"; ToolsScriptsFolder="Tools"
BitStreamToYUVFolder="BitStreamToYUV"
FinalTestReportDir="FinalTestReport"
let "SGEJobNum =0 ";let "SGEJobSubCasesNum=0"
Openh264GitAddr="";Branch=""
#Input test set setting
declare -a aTestYUVList
InputFileFormat=""
#folder for eache test sequence
SubFolder="";SGEJobFile=""
}
runRemovedPreviousTestData()
{
[ -d $AllTestDataFolder ] && ./${ScriptFolder}/run_SafeDelete.sh $AllTestDataFolder
[ -d $SHA1TableFolder ] && ./${ScriptFolder}/run_SafeDelete.sh $SHA1TableFolder
[ -d $FinalResultDir ] && ./${ScriptFolder}/run_SafeDelete.sh $FinalResultDir
[ -d $FinalTestReportDir ] && ./${ScriptFolder}/run_SafeDelete.sh $FinalTestReportDir
[ -d $BitStreamToYUVFolder ] && ./${ScriptFolder}/run_SafeDelete.sh $BitStreamToYUVFolder
[ -d $CodecFolder ] && ./${ScriptFolder}/run_SafeDelete.sh $CodecFolder
#[ -d $SourceFolder ] && ./${ScriptFolder}/run_SafeDelete.sh $SourceFolder
for file in ${CurrentDir}/*.log
do
[ -e ${file} ] && ./${ScriptFolder}/run_SafeDelete.sh ${file}
done
for file in ${CurrentDir}/*.txt
do
[ -e ${file} ] && ./${ScriptFolder}/run_SafeDelete.sh ${file}
done
for file in ${CurrentDir}/*.flag
do
[ -e ${file} ] && ./${ScriptFolder}/run_SafeDelete.sh ${file}
done
mkdir -p ${AllTestDataFolder} ${SHA1TableFolder} ${FinalResultDir} ${FinalTestReportDir} ${BitStreamToYUVFolder} ${CodecFolder}
}
runParseConfigureFile()
{
Openh264GitAddr=(`cat ${ConfigureFile} | grep "^GitAddress" | awk '{print $2}' `)
Branch=(`cat ${ConfigureFile} | grep "^GitBranch" | awk '{print $2}' `)
TempString=(`cat ${ConfigureFile} | grep "^SubCasesNum" | awk 'BEGIN {FS="[#:]"} {print $2}' `)
let "SGEJobSubCasesNum= ${TempString}"
TempString=(`cat ${ConfigureFile} | grep "^InputFormat" | awk 'BEGIN {FS="[#:]"} {print $2}' `)
let "InputFileFormat= ${TempString}"
Platform=(`cat ${ConfigureFile} | grep "TestPlatform" | awk 'BEGIN {FS="[#:]"} {print $2}' `)
#if value in configure files will be overwrite by input value
[ ! -z ${OpenH264Repos} ] && Openh264GitAddr="${OpenH264Repos}"
[ ! -z ${OpenH264Branch} ] && Branch="${OpenH264Branch}"
DefaultSourceFolder="Source";
DefaultReposUpdateOption="fast"
#using default value
[ -z ${SourceFolder} ] && SourceFolder="${DefaultSourceFolder}"
[ -z ${ReposUpdateOption} ] && ReposUpdateOption="${DefaultReposUpdateOption}"
}
runUpdateCodec()
{
#copy JM/JSVM/DowsampleApp etc. tools to codec folder
echo "Test platform is ${Platform}; copy JM/JSVM etc. tools to codec"
#for linux platform, check test os's bit version, 32bits or 64 bits
if [ "${Platform}" = "Linux" ]
then
BitVersion=`uname --machine`
[ "${BitVersion}" = "x86_64" ] && ToolsAppDir="${Tools64Bits}"
[ "${BitVersion}" = "i686" ] && ToolsAppDir="${Tools32Bits}"
cp -f ${ToolsAppDir}/* ${CodecFolder}
cp -f ${Codec_Linux}/*.cfg ${CodecFolder}
elif [ "${Platform}" = "Mac" ]
then
cp -f ${Codec_Mac}/* ${CodecFolder}
fi
#checkout openh264 repos and switch to test branch
./run_CheckoutRepos.sh ${Openh264GitAddr} ${Branch} ${SourceFolder} ${ReposUpdateOption}
[ ! $? -eq 0 ] && echo -e "\033[31m\n Failed to checkout openh264 repository! \n\033[0m" && exit 1
#build codec with enable YUV dump macro
./run_UpdateCodec.sh ${SourceFolder}
[ ! $? -eq 0 ] && echo -e "\033[31m\n Failed build and update codec! \n\033[0m" && exit 1
ls -l ${CodecFolder}
return 0
}
runGenerateCaseFiles()
{
TestYUVName=$1
AllCasesFile=${TestYUVName}_AllCase.csv
SubCaseInfoLog=${TestYUVName}_SubCasesInfo.log
./run_GenerateCase.sh ${ConfigureFile} ${TestYUVName} ${AllCasesFile}
[ ! $? -eq 0 ] && echo -e "\033[31m\n failed to generate cases ! \n\033[0m" && exit 1
if [ ${TestType} == "SGETest" ]
then
./run_CasesPartition.sh ${AllCasesFile} ${SGEJobSubCasesNum}\
${TestYUVName} ${SubCaseInfoLog}
[ ! $? -eq 0 ] && echo -e "\033[31m failed to split all cases set into sub-set! \n\033[0m" && exit 1
fi
return 0
}
runPrepareTestSpace()
{
let "YUVIndex=0"
for TestYUV in ${aTestYUVList[@]}
do
SubFolder="${AllTestDataFolder}/${TestYUV}"
[ -d ${SubFolder} ] && continue #for those repeat YUV name in TestYUVList
echo -e "\033[32m ********************************************************************* \033[0m"
echo -e "\033[32m Test sequence name is: ${TestYUV} \033[0m"
echo -e "\033[32m Test space is: ${SubFolder} \033[0m"
echo -e "\033[32m ********************************************************************* \033[0m"
#copy codec app, script files, cfg files to test space for one YUV
mkdir -p ${SubFolder}
cp ${CodecFolder}/* ${SubFolder}; cp ${ScriptFolder}/* ${SubFolder}; cp ${ToolsScriptsFolder}/* ${SubFolder};
cp ${ConfigureFile} ${SubFolder};
#if input format is bit stream, will decode to YUV, and sub-folder as input YUV dir
[ ${InputFileFormat} -eq 1 ] && cp ${BitStreamToYUVFolder}/${TestYUV} ${SubFolder}
#generate test cases
cd ${SubFolder};runGenerateCaseFiles ${TestYUV};cd ${CurrentDir}
let "YUVIndex++"
if [ ${TestType} = "SGETest" ]
then
./Scripts/run_GenerateSGEJobFile.sh ${SubFolder} ${TestYUV} ${ConfigureFile}
fi
done
return 0
}
runGetInputYUVTestSet()
{
#if InputFileFormat=1, which means bit stream as input,
# --1, will decode to YUV, rename YUV with actual resolution
# --2, will copy decoded YUV files to BitStreamToYUV
# --3, BitStreamToYUV will be set as input YUVs' dir
aTestYUVList=(`./Scripts/run_GetTestYUVSet.sh ${ConfigureFile}`)
[ ${InputFileFormat} -eq 1 ] && cat BitStreamToYUV.log
}
runOutput()
{
echo -e "\033[32m ********************************************************* \033[0m"
echo -e "\033[32m Repository is ${Openh264GitAddr} \033[0m"
echo -e "\033[32m Branch is ${Branch} \033[0m"
echo -e "\033[32m SGEJobSubCasesNum is ${SGEJobSubCasesNum} \033[0m"
echo -e "\033[32m SGEJobSubCasesNum is ${SGEJobSubCasesNum} \033[0m"
echo -e "\033[32m ********************************************************* \033[0m"
}
runCheck()
{
#check test type
[ ! "${TestType}" = "SGETest" ] && [ ! "${TestType}" = "LocalTest" ] && exit 1
#check configure file
[ ! -f ${ConfigureFile} ] && echo "Configure file ${ConfigureFile} does not exist!please double check in " && exit 1
return 0
}
runMain()
{
#check input parameters
runCheck
runGlobalVariableInitial
echo -e "\033[32m ********************************************************************* \033[0m"
echo -e "\033[32m Removing previous test data \033[0m"
echo -e "\033[32m ********************************************************************* \033[0m"
runRemovedPreviousTestData
#parse git repository info
runParseConfigureFile
runOutput
#update codec
echo -e "\033[32m ********************************************************************* \033[0m"
echo -e "\033[32m updating test codec \033[0m"
echo -e "\033[32m ********************************************************************* \033[0m"
runUpdateCodec
runGetInputYUVTestSet
echo -e "\033[32m ********************************************************************* \033[0m"
echo -e "\033[32m Preparing all test spaces for eache test sequence \033[0m"
echo -e "\033[32m ********************************************************************* \033[0m"
runPrepareTestSpace
echo -e "\033[32m ********************************************************************* \033[0m"
echo -e "\033[32m Test space preparation succeed \033[0m"
echo -e "\033[32m All test data, please refer to: ${AllTestDataFolder} \033[0m"
echo -e "\033[32m ********************************************************************* \033[0m"
}
runExampleTest()
{
TestType="LocalTest"
ConfigureFile="./CaseConfigure/case_for_Mac_fast_test.cfg"
OpenH264Repos="https://github.com/cisco/openh264"
Branch="master"
CheckoutDir="Source"
ReposUpdateOption="fast"
runMain
}
#************************************************************************************************************
# example test
#runExampleTest
#EnableExampleTest()
#{
#************************************************************************************************************
echo ""
echo "*********************************************************"
echo " call bash file is $0"
echo " input parameters is:"
echo " $0 $@"
echo "*********************************************************"
echo ""
#parameter check!
if [ ! $# -ge 2 ]
then
runUsage
return 1
fi
TestType=$1
ConfigureFile=$2
OpenH264Branch=$3
OpenH264Repos=$4
SourceFolder=$5
ReposUpdateOption=$6
runMain
#************************************************************************************************************
#}