[6ccf55]: testcases / kdump / runkdump.sh  Maximize  Restore  History

Download this file

283 lines (212 with data), 6.4 kB

  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
#!/bin/sh -xe
SetupCrontab ()
{
echo "Setup crontab."
set +e
crontab -r
set -e
# crontab in some distros will not read from STDIN.
cat <<EOF >kdump.cron
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin
MAILTO=root
@reboot cd "$(pwd)"; cd ..; ${0} >>/tmp/kdump-$(date +%F-%T).log 2>&1
EOF
crontab kdump.cron
echo "Enable cron daemon by default."
if [ -f /etc/init.d/crond ]; then
cron=crond
else
# SUSE
cron=cron
fi
# Red Hat and SUSE.
if [ -x "/sbin/chkconfig" ]; then
/sbin/chkconfig "${cron}" on
# Debian and Ubuntu.
elif [ -x "/sbin/update-rc.d" ]; then
/sbin/update-rc.d "${cron}" defaults
fi
}
SetupKdump ()
{
echo "Start kdump daemon."
/etc/init.d/kdump restart
echo "Enable kdump daemon by default."
# Red Hat and SUSE.
if [ -x "/sbin/chkconfig" ]; then
/sbin/chkconfig kdump on
# Debian and Ubuntu.
elif [ -x "/sbin/update-rc.d" ]; then
/sbin/update-rc.d kdump defaults
fi
}
PrepareVerify ()
{
if [ "${last}" = "KLEXT" ]; then
# If not mountable, skip it, and continue doing the test.
set +e
mount "${EXT3_PART}" /mnt
set -e
COREDIR=/mnt"${COREDIR}"
elif [ "${last}" = "KLLBL" ]; then
# If not mountable, skip it, and continue doing the test.
set +e
mount -L "${EXT3_LABEL}" /mnt
set -e
COREDIR=/mnt"${COREDIR}"
elif [ "${last}" = "KLUID" ]; then
# If not mountable, skip it, and continue doing the test.
set +e
mount "/dev/disk/by-uuid/${EXT3_UID}" /mnt
set -e
COREDIR=/mnt"${COREDIR}"
elif [ "${last}" = "KLRAW" ]; then
mkdir -p "${COREDIR}/${last}"
# If not dumpable, skip it, and continue doing the test.
set +e
dd if="${RAW_PART}" of="${COREDIR}/${last}/vmcore" bs=1024
set -e
elif [ "${last}" = "KNSCP" ]; then
if [ -z "${SCP_PATH}" ]; then
echo "Fail: network destination not defined."
exit 1
fi
file=$(ssh "${SCP_PATH}" "ls -t ${COREDIR}/*/vmcore \
2>/dev/null | head -1")
mkdir -p "${COREDIR}/${last}"
if [ "${file}" ]; then
# Not fatal error.
set +e
scp "${SCP_PATH}:${file}" "${COREDIR}/${last}"
set -e
fi
elif [ "${last}" = "KNNFS" ]; then
# Not fatal error.
set +e
mount "${NFS_PATH}" /mnt
set -e
COREDIR=/mnt"${COREDIR}"
fi
vmcore=$(ls -t "${COREDIR}"/*/vmcore 2>/dev/null | head -1)
}
VerifyTest ()
{
# Should not be here.
if [ -z "${last}" ]; then
echo "Should not be here!"
echo "There must be something wrong with the test setup."
exit 1
fi
echo "Verifying the result of previous test ${last}."
ldir=$(ls -td "../${log}/$(hostname)."* | head -1)
if [ -f "${vmcore}" ]; then
echo "$(date +%F-%T): verification of test ${last} passed." \
>>"${ldir}/status"
./verify.sh "../${conf}" "${vmcore}" "${CRASH}" \
>>"${ldir}/${ITERATION}.${last}.$(date +%F-%T)"
# Be careful to define COREDIR.
rm -rf "${COREDIR}"/*
else
echo "$(date +%F-%T): verification of test ${last} failed:\
vmcore NOT FOUND." >>"${ldir}/status"
echo "vmcore NOT FOUND." \
>>"${ldir}/${ITERATION}.${last}.$(date +%F-%T)"
fi
}
RunTest ()
{
sed -i "s/\(^REBOOT\)=.*/\1=$((count + 1))/" \
"../${conf}"
echo "Running current test ${i}."
echo "$(date +%F-%T): running current test ${i}." \
>> "${ldir}/status"
# Save STDIO buffers.
sync
./test.sh "../${conf}" "${i}" "../${log}"
}
# Start test.
conf="./runkdump.conf"
lib="lib"
log="log"
# Read test configuration file.
. "${conf}"
# Check mandatory variables.
if [ -z "${ITERATION}" ] || [ -z "${REBOOT}" ] || [ -z "${COREDIR}" ]
then
echo "Fail: some mandatory variables are missing from\
configuration file."
exit 1
fi
cd "${lib}"
while [ "${ITERATION}" -ge 1 ]; do
# Reboot the machine first to take advantage of boot parameter
# changes.
if [ -z "${REBOOT}" ] || [ "${REBOOT}" -eq 0 ]; then
echo "Setup test environment."
SetupCrontab
./setup.sh "../${conf}"
sed -i 's/\(^REBOOT\)=.*/\1=1/' "../${conf}"
echo "System is going to reboot."
/sbin/shutdown -r now
sleep 60
else
count=1
for i in ${CRASHER} ${BASIC_LKDTM} ${EXTRA_LKDTM} ${EXTRA_DUMP} \
END; do
if [ "${count}" -eq "${REBOOT}" ]; then
# Wait for machine fully booted.
sleep 60
# First Test.
if [ "${REBOOT}" -eq 1 ]; then
echo "First test..."
echo "Verify Boot Loader."
if ! grep 'crashkernel=' /proc/cmdline; then
echo "Fail: error changing Boot Loader, no crashkernel=."
exit 1
fi
SetupKdump
# Creat log directory.
mkdir -p "../${log}/$(hostname).$(date +%F-%T)"
echo "Gather system information."
ldir=$(ls -td "../${log}/$(hostname)."* | head -1)
./sysinfo.sh >"${ldir}/system.info"
else
PrepareVerify
VerifyTest
if [ "${i}" = END ]; then
# We are done.
break
fi
fi
RunTest
# Some tests could not reboot target. They can hung up
# machine or leave it working. But we need to do all
# tests. So we are going to reboot if we are in wrong
# place.
sleep 3600
echo "$(date +%F-%T): manually reboot for test ${i}." >>"${ldir}/status"
/sbin/shutdown -r now
sleep 60
fi
# No test is scheduled to run.
count=$((count + 1))
last=${i}
done
fi
if [ "${ITERATION}" -eq 1 ]; then
# We are done.
break
else
# Run the next iteration.
sed -i "s/\(^ITERATION\)=.*/\1=$((ITERATION - 1))/" \
"../${conf}"
fi
done
# We are done.
# Reset.
sed -i "s/\(^REBOOT\)=.*/\1=0/" "../${conf}"
crontab -r
ldir=$(ls -td "../${log}/$(hostname)."* | head -1)
echo "$(date +%F-%T): test run complete." >>"${ldir}/status"
exit 0

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks