blob: 747809a8673b3bfe7fd8efcfd732dee990ef7870 (
plain)
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
|
#!/bin/bash
__CORE_PATTERN=""
function save_core_pattern {
__CORE_PATTERN=$(< /proc/sys/kernel/core_pattern)
}
function exit_with_code {
echo ${1}
exit ${2}
}
function restore_core_pattern {
echo ${__CORE_PATTERN} > /proc/sys/kernel/core_pattern
}
function endoftime {
TIMEOUT=$((TIMEOUT-1))
if [ $((TIMEOUT)) == 0 ]; then
return 0
fi
return 1
}
function check {
if [[ ${RESULT} =~ ${1} ]]; then
return 0
fi
exit_with_code "FAIL: not found ${1} in ${RESULT}" ${FAIL_CODE}
}
function check_file_exists {
if [ ! -f ${1} ]; then
exit_with_code "FAIL: file not exists $1" ${FAIL_CODE}
fi
}
function check_file_not_exists {
if [ -f ${1} ]; then
exit_with_code "FAIL: file exists $1" ${FAIL_CODE}
fi
}
function check_zip_contains {
zipfile=${1}
pattern="$2"
if ! unzip -qql "$zipfile" | grep -E "$pattern"; then
exit_with_code "FAIL: zip file ${zipfile} does not contain ${pattern}" ${FAIL_CODE}
fi
}
function tzplatform_var {
VAL=`tzplatform-get ${1}`
if [ $? == 0 ]; then
echo $VAL | cut -d'=' -f2
return 0
fi
return 1
}
function clean_crash_dump {
killall crash-manager
killall minicoredumper
sleep 1
if [ ! -d ${CRASH_DUMP_PATH} ]; then
exit_with_code "${CRASH_DUMP_PATH} does not exist" ${FAIL_CODE}
fi
rm -rf ${CRASH_DUMP_PATH}/*
}
function clean_logdump {
killall log_dump
sleep 1
if [ -d ${LOGDUMP_RESULT_PATH} ]; then
rm -rf ${LOGDUMP_RESULT_PATH}/*
fi
}
function clean_temp {
if [ -d ${CRASH_TEMP_PATH} ]; then
rm -rf ${CRASH_TEMP_PATH}/*
fi
}
function wait_for_file {
TIMEOUT=240
while [ ! -f ${1} ];
do
if endoftime; then
exit_with_code "FAIL: ${1} does not exist" ${FAIL_CODE}
else
sleep 1
fi
done
return 0
}
function wait_for_app {
TIMEOUT=240
while true;
do
if ! pidof ${1} 1> /dev/null 2>&1; then
break;
fi
if endoftime; then
exit_with_code "FAIL: ${1} is still running" ${FAIL_CODE}
else
sleep 1
fi
done
sleep 1
return 0
}
function backup_file {
cp ${1} ${1}.backup
}
function restore_file {
mv ${1}.backup ${1}
}
function untar_file {
pushd ${1}
tar xf ${2}
popd
}
function __export_vars__ {
export CRASH_TEMP_PATH=`tzplatform_var TZ_SYS_CRASH_ROOT`/temp
if [ "x${CRASH_TEMP_PATH}" = 'x/temp' ]; then
exit_with_code "Couldn't get TZ_SYS_CRASH_ROOT" ${FAIL_CODE}
fi
export LOGDUMP_RESULT_PATH=`tzplatform_var TZ_SYS_CRASH_ROOT`/debug
if [ "x${LOGDUMP_RESULT_PATH}" = 'x/debug' ]; then
exit_with_code "Couldn't get TZ_SYS_CRASH_ROOT" ${FAIL_CODE}
fi
export CRASH_DUMP_PATH=`tzplatform_var TZ_SYS_CRASH`
if [ -z ${CRASH_DUMP_PATH} ]; then
exit_with_code "Couldn't get TZ_SYS_CRASH or TZ_SYS_CRASH is empty" ${FAIL_CODE}
fi
export LIVE_DUMP_PATH=`tzplatform_var TZ_SYS_CRASH_ROOT`/livedump
if [ -z ${LIVE_DUMP_PATH} ]; then
exit_with_code "Couldn't get TZ_SYS_CRASH_ROOT or TZ_SYS_CRASH_ROOT is empty" ${FAIL_CODE}
fi
export SUCCESS_CODE=0
export FAIL_CODE=1
export SKIP_CODE=2
}
function is_emulator {
[[ `uname -m` =~ 86$ ]]
}
__export_vars__
|