-
Notifications
You must be signed in to change notification settings - Fork 1
/
mytest
executable file
·245 lines (236 loc) · 7.63 KB
/
mytest
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
#!/bin/sh -x
ADDOPT=
if [ $# -eq 0 ]
then
CMDFILE=exec_table_rdp
#CMDFILE=re-test
elif [ $1 == "one" ]
then
CMDFILE=ONSHOT
else
CMDFILE=$1
if [ "$2" = "CPU" ]; then
cpus=$(cat /proc/cpuinfo | grep processor | wc -l)
ADDOPT="-c $cpus"
elif [ "$2" = "IO" ]; then
cpus=$(cat /proc/cpuinfo | grep processor | wc -l)
ADDOPT="-i $cpus"
elif [ "$2" = "MEM" ]; then
cpus=$(cat /proc/cpuinfo | grep processor | wc -l)
ADDOPT="-m $cpus"
fi
fi
TEST_TYPE=AUTO
#CONTINUE=y
export STREAM_PATH=/mnt/nfs/test_stream
#mount /dev/mmcblk0p1 /tmp
export TMPDIR=/tmp
export LTPROOT=$(dirname $0)
TEST_PATH=$(dirname $0)
export PATH=$PATH:${TEST_PATH}/testcases/bin
dos2unix ${TEST_PATH}/runtest/$CMDFILE
mount -t tmpfs tmpfs /tmp
#dmesg -c
#enalbe dvfs
#dvfs_ctl=$(find /sys/devices -name *dvfscore*)
#echo 1 > ${dvfs_ctl}/enable
platfm=$(platfm.sh)
ARCH_PLATFORM=${platfm}
if [ "$CONTINUE" = 'y' ];then
#tday=$(date +%m%d%Y)
mac=$(cat /sys/class/net/eth0/address | sed 's/:/_/g')
tday=${mac}
cat ${TEST_PATH}/runtest/$CMDFILE | sed 's/^#//g' > ${TEST_PATH}/runtest/temp_test_${CMDFILE}_$tday
if [ -e ${TEST_PATH}/temp_cnt_${CMDFILE}_$tday ]; then
#1 not first run, need change the command file skip the last one
#find the last execute one
search=1
cnt=1
ll=0
step=1
rep=$(cat /proc/cmdline| grep "rep=" | sed 's/rep=/^/'| cut -d '^' -f 2 | cut -d " " -f 1)
total_tc=$(cat ${TEST_PATH}/runtest/temp_test_${CMDFILE}_$tday | grep "TGE-"| wc -l)
while [ $search -eq 1 ];do
lct=$(cat ${TEST_PATH}/results/${ARCH_PLATFORM}_${TEST_TYPE}_${CMDFILE}_$tday.txt | grep "TGE-" | wc -l)
id=$(cat ${TEST_PATH}/results/${ARCH_PLATFORM}_${TEST_TYPE}_${CMDFILE}_$tday.txt | grep "TGE-" |tail -n $cnt | head -n 1)
timeout=$(echo $id | grep TIMEOUT | wc -l)
ide=$(echo $id | wc -L)
ll=$(cat ${TEST_PATH}/temp_cnt_${CMDFILE}_$tday)
if [ $ll = $(uname -r) ]; then
echo "test finished for this kernel"
exit 255
else
tstat=$(echo $ll | grep [^0-9] | wc -l)
if [ $tstat -gt 0 ]; then
#last test is finished
ll=0
fi
fi
if [ $ide -eq 0 ]; then
#2 the case id not find in this line
if [ $lct -eq 0 ]; then
#3 if no case is run before
search=0
if [ $ll -eq 0 ]; then
#4 no former fail? start from first case
echo 1 > ${TEST_PATH}/temp_cnt_${CMDFILE}_$tday
else
#4 skip formal fail
if [ $total_tc -gt $ll ]; then
if [ $rep = "1" ]; then
line=$ll
else
line=$(expr $ll + 1)
fi
echo $line > ${TEST_PATH}/temp_cnt_${CMDFILE}_$tday
#sh -c "sed -i '1,${line}s/^/#/g' ${TEST_PATH}/runtest/temp_test_${CMDFILE}_$tday"
sh -c "cat ${TEST_PATH}/runtest/$CMDFILE | sed '1,${ll}s/^/#/g' > ${TEST_PATH}/runtest/temp_test_${CMDFILE}_$tday"
else
echo "all test failed restart test"
echo 0 > ${TEST_PATH}/temp_cnt_${CMDFILE}_$tday
fi
fi
else
#3 there is case run before
if [ $cnt -gt $lct ]; then
#4 can not find any start test from begin
search=0
echo "former test cases list is changed!"
if [ $ll -eq 0 ]; then
#5 if no former fail cases
echo 1 > ${TEST_PATH}/temp_cnt_${CMDFILE}_$tday
else
#5 has former fail case
if [ $total_tc -gt $ll ]; then
if [ $rep = "1" ]; then
line=$ll
else
line=$(expr $ll + 1)
fi
echo $line > ${TEST_PATH}/temp_cnt_${CMDFILE}_$tday
#sh -c "sed -i '1,${line}s/^/#/g' ${TEST_PATH}/runtest/temp_test_${CMDFILE}_$tday"
sh -c "cat ${TEST_PATH}/runtest/$CMDFILE | sed '1,${ll}s/^/#/g' > ${TEST_PATH}/runtest/temp_test_${CMDFILE}_$tday"
else
echo "all following test failed restart test"
echo 0 > ${TEST_PATH}/temp_cnt_${CMDFILE}_$tday
fi
fi
else
#4 search former line
cnt=$(expr $cnt + 1)
fi
fi
else
#2 case ID avaialble
ss=$(echo $id | awk '{print $1}')
line=$(grep -n "${ss}" ${TEST_PATH}/runtest/$CMDFILE | awk '{print $1}' | cut -d ":" -f 1)
if [ -z $ll ]; then
#3 if no former fail data
ll=$(echo $line | head -n 1)
fi
llc=$(echo $line | wc -w)
if [ $llc -gt 1 ]; then
#3 if there are multi cases for same ID
myline=$line
line=$ll
for ilc in $myline
do
if [ $ilc -eq $ll ]; then
line=$ll
break;
elif [ $ilc -gt $ll ]; then
line=$ilc
break;
else
echo $line > /dev/null
fi
done
fi
if [ $timeout -eq 0 ]; then
if [ ! -z "$line" ] ; then
#3 has last success case
if [ $ll -gt $line ]; then
#4 former fail cases is after current success case
if [ $rep = "1" ]; then
line=$ll
else
line=$(expr $ll + 1)
fi
else
#4 former fail cases is before the last success cases
if [ $rep = "1" ]; then
line=$line
else
line=$(expr $line + 1)
fi
fi
else
#3 has not last success cases
if [ $rep = "1" ]; then
line=$ll
else
line=$(expr $ll + 1)
fi
fi
else
#3 timeout cases
if [ ! -z "$line" ] ; then
#3 has last success case
if [ $ll -gt $line ]; then
#4 former fail cases is after current success case
if [ $rep = "1" ]; then
line=$ll
else
line=$(expr $ll + 1)
fi
else
#4 former fail cases is before the last success cases
if [ $rep = "1" ]; then
line=$line
else
line=$(expr $line + 1)
fi
fi
else
if [ $rep = "1" ]; then
line=$ll
else
line=$(expr $ll + 1)
fi
fi
fi
if [ -z "$line" ]; then
#if the case id change and can not find then
line=$ll
fi
echo $line > ${TEST_PATH}/temp_cnt_${CMDFILE}_$tday
ll=$(expr $line - 1)
sh -c "cat ${TEST_PATH}/runtest/$CMDFILE | sed '1,${ll}s/^/#/g' > ${TEST_PATH}/runtest/temp_test_${CMDFILE}_$tday"
#sh -c "sed -i '1,${line}s/^/#/g' ${TEST_PATH}/runtest/temp_test_${CMDFILE}_$tday"
search=0
fi
done
else
#1 fisrt run reset counter
echo 1 > ${TEST_PATH}/temp_cnt_${CMDFILE}_$tday
fi
${TEST_PATH}/runltp -p -g ${ARCH_PLATFORM}_${TEST_TYPE}_${CMDFILE}_$tday.html ${ADDOPT} -l ${ARCH_PLATFORM}_${TEST_TYPE}_${CMDFILE}_$tday.txt -f temp_test_${CMDFILE}_$tday -o ${TEST_PATH}/output/${ARCH_PLATFORM}_${CMDFILE}_log_$tday
else
rm -f ${LTPROOT}/output/${ARCH_PLATFORM}_${CMDFILE}_log_$tday
${TEST_PATH}/runltp -p -g ${ARCH_PLATFORM}_${TEST_TYPE}_${CMDFILE}_test.html ${ADDOPT} -l ${ARCH_PLATFORM}_${TEST_TYPE}_${CMDFILE}_test.txt -f $CMDFILE -o ${TEST_PATH}/${ARCH_PLATFORM}_${CMDFILE}_log_$tday
#${TEST_PATH}/runalltests.sh -v -p -l ${ARCH_PLATFORM}_${TEST_TYPE}_test.txt
fi
lastcmd=$(cat ${TEST_PATH}/runtest/$CMDFILE | grep -v "#" |grep "TGE-" | tail -n 1| awk '{print $1}')
rlastcmd=$(cat ${TEST_PATH}/results/${ARCH_PLATFORM}_${TEST_TYPE}_${CMDFILE}_$tday.txt | grep "TGE-" | tail -n 1 | awk '{print $1}')
flastcmd=$(cat ${TEST_PATH}/output/LTP_RUN_ON-${ARCH_PLATFORM}_${CMDFILE}_log_${tday}.failed | grep "TGE-" | tail -n 1 | awk '{print $1}')
if [ -z $(echo $lastcmd | grep $rlastcmd) ];then
echo "case result and case final result does not match will try restest in new kernel"
else
echo $(uname -r) > ${TEST_PATH}/temp_cnt_${CMDFILE}_${tday}
fi
append_md5=$(md5sum ${TEST_PATH}/output/${ARCH_PLATFORM}_${CMDFILE}_log_$tday | cut -c 1-6)
mv ${TEST_PATH}/output/${ARCH_PLATFORM}_${CMDFILE}_log_$tday ${TEST_PATH}/output/${ARCH_PLATFORM}_${CMDFILE}_log_${tday}_${append_md5}
mv ${TEST_PATH}/output/LTP_RUN_ON-${ARCH_PLATFORM}_${CMDFILE}_log_${tday}.failed ${TEST_PATH}/output//LTP_RUN_ON-${ARCH_PLATFORM}_${CMDFILE}_log_${tday}_${append_md5}.failed
mv ${TEST_PATH}/results/${ARCH_PLATFORM}_${TEST_TYPE}_${CMDFILE}_$tday.txt ${TEST_PATH}/results/${ARCH_PLATFORM}_${TEST_TYPE}_${CMDFILE}_${tday}_${append_md5}.txt
echo "FREESCALE LBG TEST END"
umount /tmp