check "MAGICNAME.*id=.*kenny.cpp:31"
check "run.*id=.*kenny.cpp:56"
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
gdb ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny ${BASE_DIR}/${CORE_MINI} -ex "thread apply all bt" -ex "q" 2> /dev/null | grep -e '^#' > ${BASE_DIR}/${THREADS_MINI}
if ! diff ${BASE_DIR}/${THREADS_ORIG} ${BASE_DIR}/${THREADS_MINI} > /dev/null; then
- exit_with_code "FAIL: backtraces are different" ${FAIL_CODE}
+ fail "backtraces are different"
fi
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
function check_file_exists {
if [ ! -f ${NEW_PATH}/dump/kenny*/kenny*.${1} ]; then
- exit_with_code "FAIL: no ${1} file in report" ${FAIL_CODE}
+ fail "no ${1} file in report"
fi
}
pushd ${NEW_PATH}/dump
if ! unzip kenny*zip > /dev/null; then
popd
- exit_with_code "FAIL: report not found in ${NEW_PATH}/dump" ${FAIL_CODE}
+ fail "report not found in ${NEW_PATH}/dump"
fi
popd
check_file_exists so_info
check_file_exists log
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
if is_emulator; then
- exit_with_code "SKIP" ${SKIP_CODE}
+ skip "test not applicable on emulator"
fi;
clean_crash_dump
sleep 4
gum-utils -d --username test1 1> /dev/null 2>&1
clean_after_test
- exit_with_code "SUCCESS" ${SUCCESS_CODE}
+ exit_ok
fi
if endoftime; then
gum-utils -d --username test1 1> /dev/null 2>&1
clean_after_test
-exit_with_code "FAIL" ${FAIL_CODE}
+fail "expected crash not found in timeout $TIMEOUT"
fi
if [ $score -eq 5 ]; then
- exit_with_code "SUCCESS" ${SUCCESS_CODE}
+ exit_ok
fi
fi
sleep 1
done
-exit_with_code "FAIL: dbus signal does not match" ${FAIL_CODE}
+fail "dbus signal does not match"
body_pat="$4"
if ! grep -EA "$section_len" "$section_pat" "$f" | grep -qE "$body_pat"; then
- exit_with_code "FAIL: section ${section_pat} does not contain $body_pat" ${FAIL_CODE}
+ fail "section ${section_pat} does not contain $body_pat"
fi
}
do_check $tmpfile "==== /bin/env test" 999 "^MAGIC_SECRET=$cookie2"
do_check $tmpfile "==== file for cookie3" 1 "^$cookie3"
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
check_zip_contains "$dumpfile" '.*info$'
check_zip_contains "$dumpfile" '.*cookie$'
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
REPORT_DIR=$(basename ${REPORT_ZIP} .zip)
if [ ! -f ${CRASH_DUMP_PATH}/${REPORT_ZIP} ]; then
- exit_with_code "FAIL: no report in ${CRASH_DUMP_PATH}" ${FAIL_CODE}
+ fail "no report in ${CRASH_DUMP_PATH}"
fi
pushd ${CRASH_DUMP_PATH}
if ! unzip ${REPORT_ZIP} > /dev/nulll; then
popd
- exit_with_code "FAIL: report ${REPORT_ZIP} does not exist" ${FAIL_CODE}
+ fail "report ${REPORT_ZIP} does not exist"
fi
popd
check ': .*start.*kenny'
check ': main.*kenny'
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
if [ ! -x /usr/bin/livedumper ]; then
- exit_with_code "SKIP" ${SKIP_CODE}
+ skip "livedumper binary not installed"
fi
mount -o rw,remount /
pushd ${LIVE_DUMP_PATH}
if [ ! -f ${REPORT_PATH} ]; then
- exit_with_code "Report path does not exist" ${FAIL_CODE}
+ fail "report path does not exist"
fi
if ! unzip ${REPORT_PATH} > /dev/null; then
popd
- exit_with_code "FAIL: report not found in ${LIVE_DUMP_PATH}" ${FAIL_CODE}
+ fail "report not found in ${LIVE_DUMP_PATH}"
fi
COREDUMP=`find -name "kenny*coredump*"`
if [[ $(pidof kenny) ]]; then
kill -9 `pidof kenny`
else
- exit_with_code "FAIL" ${FAIL_CODE}
+ fail "victim process not found"
fi
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
num=`unzip -qql "$logfile" | wc -l`
if [ $num -ne 2 ]; then
- exit_with_code "FAIL: 'log_dump --short' report contains $num files - 2 expected" ${FAIL_CODE}
+ fail "'log_dump --short' report contains $num files - 2 expected"
fi
restore_file ${CRASH_MANAGER_CONF}
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
clean_logdump
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
num=`unzip -qql "$logfile" | wc -l`
if [ $num -ne 2 ]; then
- exit_with_code "FAIL: 'log_dump --short' report contains $num files - 2 expected" ${FAIL_CODE}
+ fail "'log_dump --short' report contains $num files - 2 expected"
fi
check_zip_contains "$logfile" 'log/dump_systemstate.*log$'
clean_logdump
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
if [ ${RES} -eq ${COUNT} ]; then
return 0
fi
- exit_with_code "FAIL: section ${1} does not contain enough data" ${FAIL_CODE}
+ fail "section ${1} does not contain enough data"
}
function check_section {
REPORT_DIR=$(basename ${REPORT_ZIP} .zip)
if [ ! -f ${CRASH_DUMP_PATH}/${REPORT_ZIP} ]; then
- exit_with_code "FAIL: no report in ${CRASH_DUMP_PATH}" ${FAIL_CODE}
+ fail "no report in ${CRASH_DUMP_PATH}"
fi
pushd ${CRASH_DUMP_PATH}
if ! unzip ${REPORT_ZIP} > /dev/nulll; then
popd
- exit_with_code "FAIL: report ${REPORT_ZIP} does not exist" ${FAIL_CODE}
+ fail "report ${REPORT_ZIP} does not exist"
fi
popd
check_section "==== Log messages" 10
check_section "==== Journal messages" 10
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
name=$(echo kenny_${pid}_*)
name=${name%.zip}
-test -f "${name}.zip" || exit_with_code "FAIL: crash report not found" ${FAIL_CODE}
-unzip "${name}.zip" || exit_with_code "FAIL: unable to extract archive" ${FAIL_CODE}
+test -f "${name}.zip" || fail "crash report not found"
+unzip "${name}.zip" || fail "unable to extract archive"
# assumes default configuration - with coredump
-test -s "${name}/${name}.coredump.tar" || test -f ${name}/${name}.coredump || exit_with_code "FAIL: coredump corrupt or not found" ${FAIL_CODE}
+test -s "${name}/${name}.coredump.tar" || test -f ${name}/${name}.coredump || fail "coredump corrupt or not found"
-test -s "${name}/${name}.log" || exit_with_code "FAIL: log corrupt or not found" ${FAIL_CODE}
-test -s "${name}/${name}.so_info" || exit_with_code "FAIL: info corrupt or not found" ${FAIL_CODE}
-test -s "${name}/${name}.info" || exit_with_code "FAIL: info corrupt or not found" ${FAIL_CODE}
+test -s "${name}/${name}.log" || fail "log corrupt or not found"
+test -s "${name}/${name}.so_info" || fail "info corrupt or not found"
+test -s "${name}/${name}.info" || fail "info corrupt or not found"
for i in ${CRASH_TEMP_PATH}/*; do
- test -a "${i}" && exit_with_code "FAIL: temp directory not cleaned up" ${FAIL_CODE}
+ test -a "${i}" && fail "temp directory not cleaned up"
done
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
wait_for_app crash-manager
if ! compgen -G ${CRASH_DUMP_PATH}/kenny*info > /dev/null; then
- exit_with_code "FAIL: info file not found" ${FAIL_CODE}
+ fail "info file not found"
fi
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
REPORT_DIR=$(basename ${REPORT_ZIP} .zip)
if [ ! -f ${CRASH_DUMP_PATH}/${REPORT_ZIP} ]; then
- exit_with_code "FAIL: no report in ${CRASH_DUMP_PATH}" ${FAIL_CODE}
+ fail "no report in ${CRASH_DUMP_PATH}"
fi
pushd ${CRASH_DUMP_PATH}
if ! unzip ${REPORT_ZIP} > /dev/nulll; then
- exit_with_code "FAIL: report ${REPORT_ZIP} does not exist" ${FAIL_CODE}
+ fail "report ${REPORT_ZIP} does not exist"
fi
popd
check "/usr/lib/libpthread[^ ]+ [a-z0-9]+ glibc;[^;]+;[^;]+;[a-z0-9]+"
check "/usr/lib/ld[^ ]+ [a-z0-9]+ glibc;[^;]+;[^;]+;[a-z0-9]+"
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok
MINICORE_TIME=$(< ${TEMP_DIR}/${MINICORE_TIME_FILE})
if [ ${MINICORE_TIME} -le ${TIME_LIMIT} ]; then
- exit_with_code "SUCCESS" ${SUCCESS_CODE}
+ exit_ok
else
- exit_with_code "FAIL: dumping time: ${MINICORE_TIME} but limit was: ${TIME_LIMIT}" ${FAIL_CODE}
+ fail "dumping time: ${MINICORE_TIME} but limit was: ${TIME_LIMIT}"
fi
#!/bin/bash
__CORE_PATTERN=""
+SUCCESS_CODE=0
+FAIL_CODE=1
+SKIP_CODE=2
function save_core_pattern {
__CORE_PATTERN=$(< /proc/sys/kernel/core_pattern)
exit ${2}
}
+function exit_ok {
+ exit_with_code "SUCCESS" ${SUCCESS_CODE}
+}
+
+function fail {
+ exit_with_code "FAIL: $1" ${FAIL_CODE}
+}
+
+function skip {
+ exit_with_code "SKIP: $1" ${SKIP_CODE}
+}
+
function restore_core_pattern {
echo ${__CORE_PATTERN} > /proc/sys/kernel/core_pattern
}
if [[ ${RESULT} =~ ${1} ]]; then
return 0
fi
- exit_with_code "FAIL: not found ${1} in ${RESULT}" ${FAIL_CODE}
+ fail "not found ${1} in ${RESULT}"
}
function check_file_exists {
if [ ! -f ${1} ]; then
- exit_with_code "FAIL: file not exists $1" ${FAIL_CODE}
+ fail "file not exists $1"
fi
}
function check_file_not_exists {
if [ -f ${1} ]; then
- exit_with_code "FAIL: file exists $1" ${FAIL_CODE}
+ fail "file exists $1"
fi
}
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}
+ fail "zip file ${zipfile} does not contain ${pattern}"
fi
}
sleep 1
if [ ! -d ${CRASH_DUMP_PATH} ]; then
- exit_with_code "${CRASH_DUMP_PATH} does not exist" ${FAIL_CODE}
+ fail "${CRASH_DUMP_PATH} does not exist"
fi
rm -rf ${CRASH_DUMP_PATH}/*
while [ ! -f ${1} ];
do
if endoftime; then
- exit_with_code "FAIL: ${1} does not exist" ${FAIL_CODE}
+ fail "${1} does not exist"
else
sleep 1
fi
break;
fi
if endoftime; then
- exit_with_code "FAIL: ${1} is still running" ${FAIL_CODE}
+ fail "${1} is still running"
else
sleep 1
fi
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}
+ fail "Couldn't get TZ_SYS_CRASH_ROOT"
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}
+ fail "Couldn't get TZ_SYS_CRASH_ROOT"
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}
+ fail "Couldn't get TZ_SYS_CRASH or TZ_SYS_CRASH is empty"
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}
+ fail "Couldn't get TZ_SYS_CRASH_ROOT or TZ_SYS_CRASH_ROOT is empty"
fi
- export SUCCESS_CODE=0
- export FAIL_CODE=1
- export SKIP_CODE=2
}
function is_emulator {
clean_crash_dump
if ! umount -l ${OPT_MOUNTPOINT}; then
- exit_with_code "umount ${OPT_MOUNTPOINT} error" ${FAIL_CODE}
+ fail "umount ${OPT_MOUNTPOINT} error"
fi
save_core_pattern
OPT_CUR_MOUNTPOINT=`echo ${OPT_LINE} | cut -d' ' -f2`
if ! mount -t ${OPT_FS} -o ${OPT_OPTS} ${OPT_DEV} ${OPT_CUR_MOUNTPOINT}; then
- exit_with_code "ERROR: mount -t ${OPT_FS} -o ${OPT_OPTS} ${OPT_DEV} ${OPT_CUR_MOUNTPOINT}" ${FAIL_CODE}
+ fail " mount -t ${OPT_FS} -o ${OPT_OPTS} ${OPT_DEV} ${OPT_CUR_MOUNTPOINT}"
fi
done
pushd ${CRASH_DUMP_PATH}
if ! unzip kenny*zip > /dev/null; then
popd
- exit_with_code "FAIL: report does not exist" ${FAIL_CODE}
+ fail "report does not exist"
fi
popd
if ls ${CRASH_DUMP_PATH}/kenny*/kenny*.coredump.tar > /dev/null; then
- exit_with_code "FAIL: coredump file exists" ${FAIL_CODE}
+ fail "coredump file exists"
fi
-exit_with_code "SUCCESS" ${SUCCESS_CODE}
+exit_ok