diff options
author | Karol Lewandowski <k.lewandowsk@samsung.com> | 2019-02-21 16:36:45 +0100 |
---|---|---|
committer | Karol Lewandowski <k.lewandowsk@samsung.com> | 2019-02-26 13:40:40 +0000 |
commit | 68209a9b9c57e9255870f9e4628b8987e2926ff8 (patch) | |
tree | 17341569b12b0cdd909d1407f194ed22b28c8f93 | |
parent | 8663d442a71f8f9f87283986fce97e4a9e9b2eb4 (diff) | |
download | crash-worker-68209a9b9c57e9255870f9e4628b8987e2926ff8.tar.gz crash-worker-68209a9b9c57e9255870f9e4628b8987e2926ff8.tar.bz2 crash-worker-68209a9b9c57e9255870f9e4628b8987e2926ff8.zip |
system tests: add basic log_dump tests
Change-Id: Ibcbf680ba2b4c105d66c9f0c93acf6aaababe375
-rw-r--r-- | packaging/crash-worker_system-tests.spec | 3 | ||||
-rw-r--r-- | tests/system/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/system/log_dump_normal/log_dump_normal.sh.template | 29 | ||||
-rw-r--r-- | tests/system/log_dump_short/log_dump_short.sh.template | 33 | ||||
-rw-r--r-- | tests/system/run.sh.template | 3 | ||||
-rw-r--r-- | tests/system/utils/minicore-utils.sh | 36 |
6 files changed, 105 insertions, 1 deletions
diff --git a/packaging/crash-worker_system-tests.spec b/packaging/crash-worker_system-tests.spec index 11d644a..79ef265 100644 --- a/packaging/crash-worker_system-tests.spec +++ b/packaging/crash-worker_system-tests.spec @@ -21,6 +21,7 @@ Requires: gdb Requires: coreutils Requires: tlm Requires: /bin/bash +Requires: /usr/bin/unzip Requires: crash-worker Requires: %{_sbindir}/minicoredumper @@ -59,6 +60,8 @@ cd tests/system %{_libdir}/crash-worker_system-tests/time_test/cp.sh %{_libdir}/crash-worker_system-tests/wait_for_opt_usr/wait_for_opt_usr.sh %{_libdir}/crash-worker_system-tests/info_file/info_file.sh +%{_libdir}/crash-worker_system-tests/log_dump_normal/log_dump_normal.sh +%{_libdir}/crash-worker_system-tests/log_dump_short/log_dump_short.sh %{_libdir}/crash-worker_system-tests/log_file/log_file.sh %{_libdir}/crash-worker_system-tests/so_info_file/so_info_file.sh %{_libdir}/crash-worker_system-tests/report_type_info/report_type_info.sh diff --git a/tests/system/CMakeLists.txt b/tests/system/CMakeLists.txt index 384a729..e57ad96 100644 --- a/tests/system/CMakeLists.txt +++ b/tests/system/CMakeLists.txt @@ -28,6 +28,8 @@ configure_test("so_info_file") configure_test("report_type_info") configure_test("without_core") configure_test("crash_root_path") +configure_test("log_dump_short") +configure_test("log_dump_normal") configure_file("run.sh.template" "run.sh" @ONLY) INSTALL(FILES run.sh DESTINATION ${CRASH_SYSTEM_TESTS_PATH}) diff --git a/tests/system/log_dump_normal/log_dump_normal.sh.template b/tests/system/log_dump_normal/log_dump_normal.sh.template new file mode 100644 index 0000000..ef22b69 --- /dev/null +++ b/tests/system/log_dump_normal/log_dump_normal.sh.template @@ -0,0 +1,29 @@ +#!/bin/bash + +# Custom report path test + +if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then + CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@" +fi + +. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh + +clean_logdump +dummy="$CRASH_DUMP_DIR/logdump-short-test" +touch "$dummy" + +log_dump --normal +logfile="${LOGDUMP_RESULT_PATH}"/* # there shall be only one file + +check_file_exists "$logfile" +check_zip_contains "$logfile" 'log/dump_systemstate.*log$' +check_zip_contains "$logfile" 'log/system_log/$' +check_zip_contains "$logfile" 'log/system_log/dlog/kernel$' +check_zip_contains "$logfile" 'log/module_log/$' +check_zip_contains "$logfile" 'dump/$' + +check_file_not_exists "$dummy" + +clean_logdump + +exit_with_code "SUCCESS" 0 diff --git a/tests/system/log_dump_short/log_dump_short.sh.template b/tests/system/log_dump_short/log_dump_short.sh.template new file mode 100644 index 0000000..e4db298 --- /dev/null +++ b/tests/system/log_dump_short/log_dump_short.sh.template @@ -0,0 +1,33 @@ +#!/bin/sh + +# Custom report path test + +if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then + CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@" +fi + +. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh + +clean_logdump + +dummy="$CRASH_DUMP_DIR/logdump-short-test" +touch "$dummy" + +log_dump --short +logfile="${LOGDUMP_RESULT_PATH}"/* # there shall be only one file + +check_file_exists "$logfile" + +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 +fi + +check_zip_contains "$logfile" 'log/dump_systemstate.*log$' +check_zip_contains "$logfile" 'log/$' + +check_file_not_exists "$dummy" + +clean_logdump + +exit_with_code "SUCCESS" 0 diff --git a/tests/system/run.sh.template b/tests/system/run.sh.template index 236151c..feece4f 100644 --- a/tests/system/run.sh.template +++ b/tests/system/run.sh.template @@ -2,7 +2,8 @@ TESTS=("check_minicore_mem" "cmp_backtraces" "info_file" "log_file" "report_type_info" "critical_process" "time_test" "wait_for_opt_usr" - "so_info_file" "without_core" "crash_root_path") + "so_info_file" "without_core" "crash_root_path" "log_dump_short" + "log_dump_normal") if [ -z "${CRASH_SYSTEM_TESTS_PATH}" ]; then CRASH_SYSTEM_TESTS_PATH="@CRASH_SYSTEM_TESTS_PATH@" diff --git a/tests/system/utils/minicore-utils.sh b/tests/system/utils/minicore-utils.sh index 9cb8627..36e6d59 100644 --- a/tests/system/utils/minicore-utils.sh +++ b/tests/system/utils/minicore-utils.sh @@ -30,6 +30,26 @@ function check { exit_with_code "FAIL: not found ${1} in ${RESULT}" 1 } +function check_file_exists { + if [ ! -f ${1} ]; then + exit_with_code "FAIL: file not exists $1" 1 + fi +} + +function check_file_not_exists { + if [ -f ${1} ]; then + exit_with_code "FAIL: file exists $1" 1 + fi +} + +function check_zip_contains { + zipfile=${1} + pattern="$2" + if ! unzip -qql "$logfile" | grep -E "$pattern"; then + exit_with_code "FAIL: zip file ${zipfile} does not contain ${pattern}" 1 + fi +} + function tzplatform_var { VAL=`tzplatform-get ${1}` if [ $? == 0 ]; then @@ -58,6 +78,22 @@ function clean_crash_dump { rm -rf ${CRASH_DUMP_PATH}/* } +function clean_logdump { + + export LOGDUMP_RESULT_PATH=`tzplatform_var TZ_SYS_CRASH_ROOT`/debug + + killall log_dump + sleep 1 + + if [ "x${LOGDUMP_RESULT_PATH}" = 'x/debug' ]; then + exit_with_code "Couldn't get TZ_SYS_CRASH_ROOT" 1 + fi + + if [ -d ${LOGDUMP_RESULT_PATH} ]; then + rm -rf ${LOGDUMP_RESULT_PATH}/* + fi +} + function wait_for_file { TIMEOUT=240 while [ ! -f ${1} ]; |