check "MAGICNAME.*id=.*kenny.cpp:31"
check "run.*id=.*kenny.cpp:56"
-exit_with_code "SUCCESS" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}
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" 1
+ exit_with_code "FAIL: backtraces are different" ${FAIL_CODE}
fi
-exit_with_code "SUCCESS" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}
function check_file_exists {
if [ ! -f ${NEW_PATH}/dump/kenny*/kenny*.${1} ]; then
- exit_with_code "FAIL: no ${1} file in report" 1
+ exit_with_code "FAIL: no ${1} file in report" ${FAIL_CODE}
fi
}
pushd ${NEW_PATH}/dump
if ! unzip kenny*zip > /dev/null; then
popd
- exit_with_code "FAIL: report not found in ${NEW_PATH}/dump" 1
+ exit_with_code "FAIL: report not found in ${NEW_PATH}/dump" ${FAIL_CODE}
fi
popd
check_file_exists so_info
check_file_exists log
-exit_with_code "SUCCESS" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}
. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
+if is_emulator; then
+ exit_with_code "SKIP" ${SKIP_CODE}
+fi;
+
clean_crash_dump
SUICIDE_SERVICE_PATH='/usr/lib/systemd/user/suicide.service'
sleep 4
gum-utils -d --username test1 1> /dev/null 2>&1
clean_after_test
- exit_with_code "SUCCESS" 0
+ exit_with_code "SUCCESS" ${SUCCESS_CODE}
fi
if endoftime; then
gum-utils -d --username test1 1> /dev/null 2>&1
clean_after_test
-exit_with_code "FAIL" 1
+exit_with_code "FAIL" ${FAIL_CODE}
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" 1
+ exit_with_code "FAIL: section ${section_pat} does not contain $body_pat" ${FAIL_CODE}
fi
}
do_check $tmpfile "==== /bin/env test" 999 "^MAGIC_SECRET=$cookie2"
do_check $tmpfile "==== file for cookie3" 1 "^$cookie3"
-exit_with_code "SUCCESS" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}
REPORT_DIR=$(basename ${REPORT_ZIP} .zip)
if [ ! -f ${CRASH_DUMP_PATH}/${REPORT_ZIP} ]; then
- exit_with_code "FAIL: no report in ${CRASH_DUMP_PATH}" 1
+ exit_with_code "FAIL: no report in ${CRASH_DUMP_PATH}" ${FAIL_CODE}
fi
pushd ${CRASH_DUMP_PATH}
if ! unzip ${REPORT_ZIP} > /dev/nulll; then
popd
- exit_with_code "FAIL: report ${REPORT_ZIP} does not exist"
+ exit_with_code "FAIL: report ${REPORT_ZIP} does not exist" ${FAIL_CODE}
fi
popd
check ': .*start.*kenny'
check ': main.*kenny'
-exit_with_code "SUCCESS" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}
pushd ${CRASH_DUMP_PATH}
if [ ! -f ${REPORT_PATH} ]; then
- exit_with_code "Report path does not exist" 1
+ exit_with_code "Report path does not exist" ${FAIL_CODE}
fi
if ! unzip ${REPORT_PATH} > /dev/null; then
popd
- exit_with_code "FAIL: report not found in ${CRASH_DUMP_PATH}" 1
+ exit_with_code "FAIL: report not found in ${CRASH_DUMP_PATH}" ${FAIL_CODE}
fi
COREDUMP=`find -name "kenny*coredump*"`
if [[ $(pidof kenny) ]]; then
kill -9 `pidof kenny`
else
- exit_with_code "FAIL" 1
+ exit_with_code "FAIL" ${FAIL_CODE}
fi
-exit_with_code "SUCCESS" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}
num=`unzip -qql "$logfile" | wc -l`
if [ $num -ne 2 ]; then
- exit_with_code "FAIL: 'log_dump --short' report contains $num files - 2 expected" 1
+ exit_with_code "FAIL: 'log_dump --short' report contains $num files - 2 expected" ${FAIL_CODE}
fi
restore_file ${CRASH_MANAGER_CONF}
-exit_with_code "SUCCESS" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}
clean_logdump
-exit_with_code "SUCCESS" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}
num=`unzip -qql "$logfile" | wc -l`
if [ $num -ne 2 ]; then
- exit_with_code "FAIL: 'log_dump --short' report contains $num files - 2 expected" 1
+ exit_with_code "FAIL: 'log_dump --short' report contains $num files - 2 expected" ${FAIL_CODE}
fi
check_zip_contains "$logfile" 'log/dump_systemstate.*log$'
clean_logdump
-exit_with_code "SUCCESS" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}
if [ ${RES} -eq ${COUNT} ]; then
return 0
fi
- exit_with_code "FAIL: section ${1} does not contain enough data" 1
+ exit_with_code "FAIL: section ${1} does not contain enough data" ${FAIL_CODE}
}
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}" 1
+ exit_with_code "FAIL: no report in ${CRASH_DUMP_PATH}" ${FAIL_CODE}
fi
pushd ${CRASH_DUMP_PATH}
if ! unzip ${REPORT_ZIP} > /dev/nulll; then
popd
- exit_with_code "FAIL: report ${REPORT_ZIP} does not exist"
+ exit_with_code "FAIL: report ${REPORT_ZIP} does not exist" ${FAIL_CODE}
fi
popd
check_section "==== Log messages" 10
check_section "==== Journal messages" 10
-exit_with_code "SUCCESS" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}
name=$(echo kenny_${pid}_*)
name=${name%.zip}
-test -f "${name}.zip" || exit_with_code "FAIL: crash report not found" 1
-unzip "${name}.zip" || exit_with_code "FAIL: unable to extract archive" 1
+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}
# 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" 1
+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}.log" || exit_with_code "FAIL: log corrupt or not found" 1
-test -s "${name}/${name}.so_info" || exit_with_code "FAIL: info corrupt or not found" 1
-test -s "${name}/${name}.info" || exit_with_code "FAIL: info corrupt or not found" 1
+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}
for i in ${CRASH_TEMP_PATH}/*; do
- test -a "${i}" && exit_with_code "FAIL: temp directory not cleaned up" 1
+ test -a "${i}" && exit_with_code "FAIL: temp directory not cleaned up" ${FAIL_CODE}
done
-exit_with_code "SUCCESS" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}
wait_for_app crash-manager
if ! compgen -G ${CRASH_DUMP_PATH}/kenny*info > /dev/null; then
- exit_with_code "FAIL: info file not found" 1
+ exit_with_code "FAIL: info file not found" ${FAIL_CODE}
fi
-exit_with_code "SUCCESS" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}
TESTS=(@TESTS_LIST@)
-if [ -z "${CRASH_SYSTEM_TESTS_PATH}" ]; then
- CRASH_SYSTEM_TESTS_PATH="@CRASH_SYSTEM_TESTS_PATH@"
+if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then
+ CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@"
fi
+. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
+
LOG_FILE=/tmp/crash-worker_system-tests.log
function run_test {
RED="\033[0;31m"
GREEN="\033[0;32m"
+ YELLOW="\033[1;33m"
NORMAL="\033[0m"
echo -ne "${TEST}:\t"
echo "===================================" >> ${LOG_FILE}
echo "Test ${TEST}:" >> ${LOG_FILE}
echo "===================================" >> ${LOG_FILE}
- ${CRASH_SYSTEM_TESTS_PATH}/${TEST}/${TEST}.sh 1>> ${LOG_FILE} 2>&1
- if [ "$?" -eq "0" ]; then
+ ${CRASH_WORKER_SYSTEM_TESTS}/${TEST}/${TEST}.sh 1>> ${LOG_FILE} 2>&1
+ case $? in
+ ${SUCCESS_CODE})
echo -e "${GREEN}SUCCESS${NORMAL}"
echo "SUCCESS" >> ${LOG_FILE}
- else
+ ;;
+ ${FAIL_CODE})
echo -e "${RED}FAIL${NORMAL}"
echo "FAIL" >> ${LOG_FILE}
- fi
+ ;;
+ ${SKIP_CODE})
+ echo -e "${YELLOW}SKIP${NORMAL}"
+ echo "SKIP" >> ${LOG_FILE}
+ ;;
+ esac
}
if [ -f ${LOG_FILE} ]; then
REPORT_DIR=$(basename ${REPORT_ZIP} .zip)
if [ ! -f ${CRASH_DUMP_PATH}/${REPORT_ZIP} ]; then
- exit_with_code "FAIL: no report in ${CRASH_DUMP_PATH}" 1
+ exit_with_code "FAIL: no report in ${CRASH_DUMP_PATH}" ${FAIL_CODE}
fi
pushd ${CRASH_DUMP_PATH}
if ! unzip ${REPORT_ZIP} > /dev/nulll; then
- exit_with_code "FAIL: report ${REPORT_ZIP} does not exist"
+ exit_with_code "FAIL: report ${REPORT_ZIP} does not exist" ${FAIL_CODE}
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" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}
MINICORE_TIME=$(< ${TEMP_DIR}/${MINICORE_TIME_FILE})
if [ ${MINICORE_TIME} -le ${TIME_LIMIT} ]; then
- exit_with_code "SUCCESS" 0
+ exit_with_code "SUCCESS" ${SUCCESS_CODE}
else
- exit_with_code "FAIL: dumping time: ${MINICORE_TIME} but limit was: ${TIME_LIMIT}" 1
+ exit_with_code "FAIL: dumping time: ${MINICORE_TIME} but limit was: ${TIME_LIMIT}" ${FAIL_CODE}
fi
if [[ ${RESULT} =~ ${1} ]]; then
return 0
fi
- exit_with_code "FAIL: not found ${1} in ${RESULT}" 1
+ 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" 1
+ 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" 1
+ exit_with_code "FAIL: file exists $1" ${FAIL_CODE}
fi
}
zipfile=${1}
pattern="$2"
if ! unzip -qql "$logfile" | grep -E "$pattern"; then
- exit_with_code "FAIL: zip file ${zipfile} does not contain ${pattern}" 1
+ exit_with_code "FAIL: zip file ${zipfile} does not contain ${pattern}" ${FAIL_CODE}
fi
}
sleep 1
if [ ! -d ${CRASH_DUMP_PATH} ]; then
- exit_with_code "${CRASH_DUMP_PATH} does not exist" 1
+ exit_with_code "${CRASH_DUMP_PATH} does not exist" ${FAIL_CODE}
fi
rm -rf ${CRASH_DUMP_PATH}/*
while [ ! -f ${1} ];
do
if endoftime; then
- exit_with_code "FAIL: ${1} does not exist" 1
+ exit_with_code "FAIL: ${1} does not exist" ${FAIL_CODE}
else
sleep 1
fi
break;
fi
if endoftime; then
- exit_with_code "FAIL: ${1} is still running" 1
+ exit_with_code "FAIL: ${1} is still running" ${FAIL_CODE}
else
sleep 1
fi
done
+ sleep 1
return 0
}
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" 1
+ 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" 1
+ 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" 1
+ exit_with_code "Couldn't get TZ_SYS_CRASH or TZ_SYS_CRASH 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__
clean_crash_dump
if ! umount -l ${OPT_MOUNTPOINT}; then
- exit_with_code "umount ${OPT_MOUNTPOINT} error" 1
+ exit_with_code "umount ${OPT_MOUNTPOINT} error" ${FAIL_CODE}
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}" 1
+ exit_with_code "ERROR: mount -t ${OPT_FS} -o ${OPT_OPTS} ${OPT_DEV} ${OPT_CUR_MOUNTPOINT}" ${FAIL_CODE}
fi
done
pushd ${CRASH_DUMP_PATH}
if ! unzip kenny*zip > /dev/null; then
popd
- exit_with_code "FAIL: report does not exist" 1
+ exit_with_code "FAIL: report does not exist" ${FAIL_CODE}
fi
popd
if ls ${CRASH_DUMP_PATH}/kenny*/kenny*.coredump.tar > /dev/null; then
- exit_with_code "FAIL: coredump file exists" 1
+ exit_with_code "FAIL: coredump file exists" ${FAIL_CODE}
fi
-exit_with_code "SUCCESS" 0
+exit_with_code "SUCCESS" ${SUCCESS_CODE}