forked from tom-gall/android-report
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkernelreport.sh
executable file
·155 lines (141 loc) · 4.97 KB
/
kernelreport.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
#!/bin/bash -e
dir_parent=$(cd $(dirname $0); pwd)
f_name="${0}"
f_basename=$(basename "${0}")
ker_version=""
no_check_ker_ver=false
reverse_build_order=false
exact_ver1=""
opt_exact_ver1=""
exact_ver2=""
opt_exact_ver2=""
qareport_project=""
opt_qareport_project=""
trim_number="0"
opt_trim_number=""
function printUsage(){
# e.g.
# ./kernelreport.sh 5.10
# ./kernelreport.sh 5.10 --exact-version-1 5.10.40 --no-check-kernel-version
echo "Please run like this:"
echo -e "\t${f_name} kernel_ver [--exact-version-1 exact_ver1 [--exact-version-2 exact_ver2 [--reverse-build-order]]] [--no-check-kernel-version] [--qareport-project qareport-project] [--trim-number trima-number]"
}
function parseArgs(){
while [ -n "${1}" ]; do
case "X$1" in
X--no-check-kernel-version)
no_check_ker_ver=true
shift
;;
X--reverse-build-order)
reverse_build_order=true
shift
;;
X--exact-version-1)
if [ -z "${2}" ]; then
echo "Please specify value for the --exact-version-1 option"
exit 1
fi
exact_ver1=$(echo "${2}"|sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
opt_exact_ver1="--exact-version-1 ${exact_ver1}"
shift 2
;;
X--exact-version-2)
if [ -z "${2}" ]; then
echo "Please specify value for the --exact-version-2 option"
exit 1
fi
exact_ver2=$(echo "${2}"|sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
opt_exact_ver2="--exact-version-2 ${exact_ver2}"
shift 2
;;
X--qareport-project)
if [ -z "${2}" ]; then
echo "Please specify value for the --qareport-project option"
exit 1
fi
qareport_project="$2"
opt_qareport_project="--qareport-project ${qareport_project}"
shift 2
;;
X--trim-number)
if [ -z "${2}" ]; then
echo "Please specify value for the --trim-number option"
exit 1
fi
trim_number="$2"
opt_trim_number="--trim-number ${trim_number}"
shift 2
;;
X-h|X--help)
printUsage
exit 1
;;
X*)
if [ -n "${ker_version}" ]; then
echo "kernel_ver could be only spedified once"
printUsage
exit 1
fi
ker_version=$(echo "${1}"|sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
shift
;;
esac
done
}
parseArgs "$@"
if [ -z "${ker_version}" ]; then
printUsage
exit 1
fi
if ${no_check_ker_ver}; then
opt_no_check_ker_ver="--no-check-kernel-version"
fi
if ${reverse_build_order}; then
opt_reverse_build_order="--reverse-build-order"
fi
if [ -z "${exact_ver1}" ]; then
f_report="/tmp/kernelreport-${ker_version}"
elif [ -z "${exact_ver2}" ]; then
f_report="/tmp/kernelreport-${ker_version}-${exact_ver1}"
elif ${reverse_build_order}; then
f_report="/tmp/kernelreport-${ker_version}-${exact_ver2}-${exact_ver1}"
else
f_report="/tmp/kernelreport-${ker_version}-${exact_ver1}-${exact_ver2}"
fi
if [ -n "${qareport_project}" ]; then
f_report="${f_report}-${qareport_project}"
fi
f_report="${f_report}.txt"
rm -f "${f_report}.scribble"
rm -f "${f_report}.errorprojects"
rm -f "${f_report}.successprojects"
PYTHON="$(command -v python3)"
if [ -e "${dir_parent}/../workspace-python3/bin/python" ]; then
PYTHON="${dir_parent}/../workspace-python3/bin/python"
fi
wget -c https://raw.githubusercontent.com/tom-gall/android-qa-classifier-data/master/flakey.txt -O /tmp/flakey.txt
"${PYTHON}" ${dir_parent}/manage.py kernelreport \
${opt_no_check_ker_ver} \
"${ker_version}" \
${f_report} \
/tmp/flakey.txt \
${opt_exact_ver1} \
${opt_exact_ver2} \
${opt_reverse_build_order} \
${opt_qareport_project} \
${opt_trim_number}
if [ -f "${f_report}.scribble" ]; then
mv -f "${f_report}" "${f_report}.successprojects"
cat "${f_report}.errorprojects" >> "${f_report}"
cat "${f_report}.successprojects" >> "${f_report}"
cat "${f_report}.scribble" >> "${f_report}"
echo "############ Reports End #########################"
echo "## Command to reproduce this report ##############"
echo "## ./${f_basename} $@"
echo "##################################################"
echo "Please check the file of ${f_report} for report"
rm -f "${f_report}.scribble" "${f_report}.errorprojects" "${f_report}.successprojects"
else
echo "Failed to generate the test report, Please check and try again"
fi