-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_BackupTestData.sh
executable file
·182 lines (152 loc) · 5.28 KB
/
run_BackupTestData.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
#/bin/bash
runUsage()
{
echo -e "\033[32m **************--usage--************************************************************ \033[0m"
echo ""
echo -e "\033[32m --./run_BackupTestData.sh \${YourTestDataDir} \${PrefixForBackupFolderName} \033[0m"
echo ""
echo -e "\033[32m e.g.: \033[0m"
echo -e "\033[32m --./run_BackupTestData.sh ./ SCC_V1.3 \033[0m"
echo ""
echo -e "\033[32m backup folder will be: \033[0m"
echo -e "\033[32m /home/SGETestBackUp/openh264/\${PreFixInfo}_ConformanceTest_\${DateInfo} \033[0m"
echo ""
echo -e "\033[32m /home/SGETestBackUp/openh264/SCC_V1.3_ConformanceTest-Fri-Mar-6-21:02:01-CST-2015 \033[0m"
echo ""
echo -e "\033[32m *********************************************************************************** \033[0m"
}
runGenerateCodecCommitInfo()
{
cd ${TestSpaceDir}/${SourceFolder}
echo "***************************************"
echo "***********branch info**********"
echo ""
git branch
echo ""
echo ""
echo "***********commit info**********"
echo ""
git log -2
echo ""
echo "***************************************"
cd ${CurrentDir}
}
runGenerateDateInfo()
{
date
TempDateInfo=`date`
TempDateInfo=`echo ${TempDateInfo} | awk 'BEGINE {FS="[ ]"} {for(i=1;i<=NF;i++)printf("-%s",$i)}'`
DateInfo=${TempDateInfo}
}
runFolderCheck()
{
if [ ! -d ${TestSpaceDir} ]
then
echo -e "\033[31m TestSpaceDir----${TestSpaceDir} dose not exist, please double check! \033[0m"
return 1
else
cd ${TestSpaceDir}
TestSpaceDir=`pwd`
cd ${CurrentDir}
fi
if [ ! -d ${TestSpaceDir}/${SourceFolder} ]
then
echo -e "\033[31m SourceFolder----${TestSpaceDir}/${SourceFolder} dose not exist, please double check! \033[0m"
return 1
fi
if [ ! -d ${TestSpaceDir}/${CodecFolder} ]
then
echo -e "\033[31m CodecFolder----${TestSpaceDir}/${CodecFolder} dose not exist, please double check! \033[0m"
return 1
fi
if [ ! -d ${TestSpaceDir}/${ConfigureFolder} ]
then
echo -e "\033[31m ConfigureFolder----${TestSpaceDir}/${ConfigureFolder} dose not exist, please double check! \033[0m"
return 1
fi
if [ ! -d ${TestSpaceDir}/${FinalResultFolder} ]
then
echo -e "\033[31m FinalResultFolder----${TestSpaceDir}/${FinalResultFolder} dose not exist, please double check! \033[0m"
return 1
fi
}
runBackupTestData()
{
mkdir -p ${BackupFolder}
mkdir -p ${BackupFolder}/${CodecFolder}
mkdir -p ${BackupFolder}/${ConfigureFolder}
mkdir -p ${BackupFolder}/${FinalResultFolder}
cp -f ${TestSpaceDir}/*.log ${BackupFolder}
cp -f ${TestSpaceDir}/*.txt ${BackupFolder}
cp -f ${TestSpaceDir}/*.flag ${BackupFolder}
cp -f ${TestSpaceDir}/${CodecFolder}/* ${BackupFolder}/${CodecFolder}
cp -f ${TestSpaceDir}/${ConfigureFolder}/* ${BackupFolder}/${ConfigureFolder}
cp -f ${TestSpaceDir}/${FinalResultFolder}/* ${BackupFolder}/${FinalResultFolder}
}
runBackupInfo()
{
echo -e "\033[32m **************--backup info--***********************************\033[0m"
echo -e "\033[32m \033[0m"
echo -e "\033[32m backup date: ${DateInfo} \033[0m"
echo -e "\033[32m backup folder: ${BackupFolder} \033[0m"
echo -e "\033[32m \033[0m"
echo -e "\033[32m backup data include: \033[0m"
echo -e "\033[32m --test codec in ${TestSpaceDir}/Codec \033[0m"
echo -e "\033[32m --test configure file in ${TestSpaceDir}/CaseConfigure \033[0m"
echo -e "\033[32m --test result in ${TestSpaceDir}/${FinalResultFolder} \033[0m"
echo -e "\033[32m ****************************************************************\033[0m"
}
runBackupLog()
{
runBackupInfo>${BackupFolder}/${BackupLogFile}
echo "">>${BackupFolder}/${BackupLogFile}
cat ${SourceInfoLog} >>${BackupFolder}/${BackupLogFile}
}
runMain()
{
if [ ! $# -eq 2 ]
then
runUsage
return 0
fi
TestSpaceDir=$1
PreFixInfo=$2
SourceFolder="Source"
CodecFolder="Codec"
ConfigureFolder="CaseConfigure"
FinalResultFolder="FinalTestReport"
CurrentDir=`pwd`
BackupDir="/home/SGETestBackUp/openh264"
BackupLogFile="Backup_readme.log"
BackupFolder=""
DateInfo=""
SourceInfoLog="SourceInfo.log"
#check folder
runFolderCheck
if [ ! $? -eq 0 ]
then
return 0
fi
#generate date info for backup folder
runGenerateDateInfo
#generate bolder name
BackupFolder="${BackupDir}/${PreFixInfo}_ConformanceTest${DateInfo}"
#generate source code info
runGenerateCodecCommitInfo>${SourceInfoLog}
#backup test data
runBackupTestData
#generate backup log
runBackupInfo
runBackupLog
return 0
}
TestSpaceDir=$1
PreFixInfo=$2
echo ""
echo "*********************************************************"
echo " call bash file is $0"
echo " input parameters is:"
echo " $0 $@"
echo "*********************************************************"
echo ""
runMain ${TestSpaceDir} ${PreFixInfo}