Add system tests 09/193009/17
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Mon, 5 Nov 2018 12:46:03 +0000 (13:46 +0100)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Fri, 23 Nov 2018 15:36:57 +0000 (16:36 +0100)
Change-Id: I9db485028d328bcc43e3bc4626c24a7f1a844f53

22 files changed:
packaging/crash-worker_system-tests.manifest [new file with mode: 0644]
packaging/crash-worker_system-tests.spec [new file with mode: 0644]
tests/system/CMakeLists.txt [new file with mode: 0644]
tests/system/check_minicore_mem/check_minicore_mem.sh.template [new file with mode: 0755]
tests/system/check_minicore_mem/cp.sh [new file with mode: 0755]
tests/system/cmp_backtraces/cmp_backtraces.sh.template [new file with mode: 0755]
tests/system/cmp_backtraces/cp.sh.template [new file with mode: 0755]
tests/system/crash_root_path/crash_root_path.sh.template [new file with mode: 0644]
tests/system/critical_process/critical_process.sh.template [new file with mode: 0755]
tests/system/info_file/info_file.sh.template [new file with mode: 0644]
tests/system/log_file/log_file.sh.template [new file with mode: 0644]
tests/system/report_type_info/report_type_info.sh.template [new file with mode: 0644]
tests/system/run.sh.template [new file with mode: 0644]
tests/system/so_info_file/so_info_file.sh.template [new file with mode: 0644]
tests/system/time_test/cp.sh [new file with mode: 0755]
tests/system/time_test/time_test.sh.template [new file with mode: 0755]
tests/system/utils/CMakeLists.txt [new file with mode: 0644]
tests/system/utils/btee.c [new file with mode: 0644]
tests/system/utils/kenny.cpp [new file with mode: 0644]
tests/system/utils/minicore-utils.sh [new file with mode: 0644]
tests/system/wait_for_opt_usr/wait_for_opt_usr.sh.template [new file with mode: 0755]
tests/system/without_core/without_core.sh.template [new file with mode: 0644]

diff --git a/packaging/crash-worker_system-tests.manifest b/packaging/crash-worker_system-tests.manifest
new file mode 100644 (file)
index 0000000..15573a3
--- /dev/null
@@ -0,0 +1,25 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+       <assign>
+        <filesystem path="/usr/lib/crash-worker_system-tests/check_minicore_mem/check_minicore_mem.sh" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/check_minicore_mem/cp.sh" label="User::Shell" exec_label="System"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/cmp_backtraces/cmp_backtraces.sh" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/cmp_backtraces/cp.sh" label="User::Shell" exec_label="System"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/critical_process/critical_process.sh" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/time_test/time_test.sh" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/time_test/cp.sh" label="User::Shell" exec_label="System"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/wait_for_opt_usr/wait_for_opt_usr.sh" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/info_file/info_file.sh" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/log_file/log_file.sh" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/so_info_file/so_info_file.sh" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/report_type_info/report_type_info.sh" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/without_core/without_core.sh" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/crash_root_path/crash_root_path.sh" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/utils/btee" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/utils/kenny" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/utils/minicore-utils.sh" label="User::Shell" exec_label="User::Shell"/>
+        <filesystem path="/usr/lib/crash-worker_system-tests/run.sh" label="User::Shell" exec_label="User::Shell"/>
+       </assign>
+</manifest>
diff --git a/packaging/crash-worker_system-tests.spec b/packaging/crash-worker_system-tests.spec
new file mode 100644 (file)
index 0000000..f891d6c
--- /dev/null
@@ -0,0 +1,74 @@
+%global __debug_package 1
+# because of this is debug package, there are source files (kenny.cpp and
+# btee.c) that will be copied to the destination directory, but we don't want
+# them in the rpm package so this flag is to avoid RPM build error:
+%define _unpackaged_files_terminate_build 0
+
+Name:          crash-worker_system-tests
+Summary:       Package with binaries and scripts for crash-worker system tests
+Version:       5.5.2
+Release:       1
+Group:         Framework/system
+License:       Apache-2.0 and BSD
+Source0:       %{name}-%{version}.tar.gz
+Source1001:    crash-worker_system-tests.manifest
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(rpm)
+BuildRequires: cmake
+
+Requires:      diff
+Requires:      gdb
+Requires:      coreutils
+Requires:      tlm
+
+Requires:      crash-worker
+Requires:      %{_sbindir}/minicoredumper
+
+%description
+This package contains installable tests in Bash.
+
+%prep
+%setup -q
+
+
+%build
+cp %{SOURCE1001} .
+
+export CFLAGS+=" -Werror"
+
+cd tests/system
+%cmake . -DCRASH_SYSTEM_TESTS_PATH=%{_libdir}/crash-worker_system-tests
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+cd tests/system
+%make_install
+
+%files -f debugfiles.list
+%manifest %{name}.manifest
+%defattr(0750,system_fw,system_fw)
+%{_libdir}/crash-worker_system-tests/check_minicore_mem/check_minicore_mem.sh
+%{_libdir}/crash-worker_system-tests/check_minicore_mem/cp.sh
+%{_libdir}/crash-worker_system-tests/cmp_backtraces/cmp_backtraces.sh
+%{_libdir}/crash-worker_system-tests/cmp_backtraces/cp.sh
+%{_libdir}/crash-worker_system-tests/critical_process/critical_process.sh
+%{_libdir}/crash-worker_system-tests/time_test/time_test.sh
+%{_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_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
+%{_libdir}/crash-worker_system-tests/without_core/without_core.sh
+%{_libdir}/crash-worker_system-tests/crash_root_path/crash_root_path.sh
+%{_libdir}/crash-worker_system-tests/utils/btee
+%{_libdir}/crash-worker_system-tests/utils/kenny
+%{_libdir}/crash-worker_system-tests/utils/minicore-utils.sh
+%{_libdir}/crash-worker_system-tests/run.sh
+%defattr(-,root,root)
+
+# %post
+# /usr/bin/chsmack -a "_" -e "SSSystem::Privileged" -r %{_libdir}/crash-worker_system-tests/
+
diff --git a/tests/system/CMakeLists.txt b/tests/system/CMakeLists.txt
new file mode 100644 (file)
index 0000000..384a729
--- /dev/null
@@ -0,0 +1,33 @@
+cmake_minimum_required(VERSION 2.6)
+
+ADD_SUBDIRECTORY(utils)
+
+macro(CONFIGURE_TEST test_name)
+  set(file_name ${test_name})
+  set(extra_args ${ARGN})
+
+  list(LENGTH extra_args extra_args_count)
+  if (${extra_args_count} GREATER 0)
+    list(GET extra_args 0 optional_arg)
+    set(file_name ${optional_arg})
+  endif()
+
+  configure_file("${test_name}/${file_name}.sh.template" "${test_name}/${file_name}.sh" @ONLY)
+  INSTALL(DIRECTORY ${test_name}/ DESTINATION ${CRASH_SYSTEM_TESTS_PATH}/${test_name} FILES_MATCHING PATTERN "*sh")
+endmacro()
+
+configure_test("check_minicore_mem")
+configure_test("time_test")
+configure_test("cmp_backtraces")
+configure_test("cmp_backtraces" "cp")
+configure_test("critical_process")
+configure_test("wait_for_opt_usr")
+configure_test("info_file")
+configure_test("log_file")
+configure_test("so_info_file")
+configure_test("report_type_info")
+configure_test("without_core")
+configure_test("crash_root_path")
+
+configure_file("run.sh.template" "run.sh" @ONLY)
+INSTALL(FILES run.sh DESTINATION ${CRASH_SYSTEM_TESTS_PATH})
diff --git a/tests/system/check_minicore_mem/check_minicore_mem.sh.template b/tests/system/check_minicore_mem/check_minicore_mem.sh.template
new file mode 100755 (executable)
index 0000000..627088a
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Minimal coredump MUST consume less than 100MB, assuming it is created from
+# process with maximum number of 8 threads.
+
+if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then
+    CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@"
+fi
+
+. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
+
+CORE_MINI='coredump.mini'
+BASE_DIR='/tmp'
+MEM_LIMIT='102400'
+
+save_core_pattern
+
+echo "|${CRASH_WORKER_SYSTEM_TESTS}/check_minicore_mem/cp.sh %p %u %g %s %t %h %e ${BASE_DIR} ${CORE_MINI} ${MEM_LIMIT}" > /proc/sys/kernel/core_pattern
+rm -f ${BASE_DIR}/${CORE_MINI}
+
+{
+    ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny &
+    sleep 1
+    kill -6 $!
+} 1> /dev/null 2>&1
+
+sleep 2
+
+restore_core_pattern
+
+wait_for_file ${BASE_DIR}/${CORE_MINI}
+
+RESULT=`gdb ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny ${BASE_DIR}/${CORE_MINI} --batch -ex "thread apply all bt"`
+
+check "MAGICNAME.*id=.*kenny.cpp:31"
+check "run.*id=.*kenny.cpp:56"
+
+exit_with_code "SUCCESS" 0
diff --git a/tests/system/check_minicore_mem/cp.sh b/tests/system/check_minicore_mem/cp.sh
new file mode 100755 (executable)
index 0000000..d34d150
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+PID=${1} # %p
+USER=${2} # %u
+GID=${3} # %g
+SIG=${4} # %s
+TIME=${5} # %t
+HOST=${6} # %h
+EXE=${7} # %e
+BASE_DIR=${8} # base_dir
+MINICORE_FILE=${9} # mini
+MEM_LIMIT=${10}
+
+ulimit -v ${MEM_LIMIT}
+ulimit -m ${MEM_LIMIT}
+
+/sbin/minicoredumper ${PID} ${USER} ${GID} ${SIG} ${TIME} ${HOST} ${EXE} /etc/minicoredumper/minicoredumper.cfg.json -d ${BASE_DIR} -o ${MINICORE_FILE}
+
+
diff --git a/tests/system/cmp_backtraces/cmp_backtraces.sh.template b/tests/system/cmp_backtraces/cmp_backtraces.sh.template
new file mode 100755 (executable)
index 0000000..11142e9
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# Functionality to create minimal coredump MUST be provided.  It MUST have
+# following properties:
+#
+#   it MUST be standards-compliant core file,
+#   it MUST be readable by unmodified GDB,
+#   it MUST have all necessary information required to resolve call stacks
+#   ("backtrace") from all threads.
+
+if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then
+    CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@"
+fi
+
+. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
+
+CORE_ORIG="coredump.orig"
+CORE_MINI="coredump.mini"
+THREADS_ORIG="threads.orig"
+THREADS_MINI="threads.mini"
+BASE_DIR="/tmp"
+
+save_core_pattern
+
+echo "|${CRASH_WORKER_SYSTEM_TESTS}/cmp_backtraces/cp.sh %p %u %g %s %t %h %e ${BASE_DIR} ${CORE_ORIG} ${CORE_MINI}" > /proc/sys/kernel/core_pattern
+
+rm -f ${BASE_DIR}/${CORE_MINI}
+rm -f ${BASE_DIR}/${CORE_ORIG}
+rm -f ${BASE_DIR}/${THREADS_MINI}
+rm -f ${BASE_DIR}/${THREADS_ORIG}
+
+{
+    ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny 10 &
+    sleep 1
+    kill -6 $!
+} 1> /dev/null 2>&1
+
+sleep 2
+
+restore_core_pattern
+
+wait_for_file ${BASE_DIR}/${CORE_ORIG}
+wait_for_file ${BASE_DIR}/${CORE_MINI}
+wait_for_app minicoredumper
+
+gdb ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny ${BASE_DIR}/${CORE_ORIG}  -ex "thread apply all bt" -ex "q" 2> /dev/null | grep -e '^#' > ${BASE_DIR}/${THREADS_ORIG}
+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
+fi
+
+exit_with_code "SUCCESS" 0
+
diff --git a/tests/system/cmp_backtraces/cp.sh.template b/tests/system/cmp_backtraces/cp.sh.template
new file mode 100755 (executable)
index 0000000..65f03eb
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then
+    CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@"
+fi
+
+PID=${1} # %p
+USER=${2} # %u
+GID=${3} # %g
+SIG=${4} # %s
+TIME=${5} # %t
+HOST=${6} # %h
+EXE=${7} # %e
+BASE_DIR=${8} # base_dir
+ORIG=${9} # orig
+MINICORE_FILE=${10} # mini
+
+${CRASH_WORKER_SYSTEM_TESTS}/utils/btee ${BASE_DIR}/${ORIG} | /sbin/minicoredumper ${PID} ${USER} ${GID} ${SIG} ${TIME} ${HOST} ${EXE} /etc/minicoredumper/minicoredumper.cfg.json -d ${BASE_DIR} -o ${MINICORE_FILE}
diff --git a/tests/system/crash_root_path/crash_root_path.sh.template b/tests/system/crash_root_path/crash_root_path.sh.template
new file mode 100644 (file)
index 0000000..95c818e
--- /dev/null
@@ -0,0 +1,53 @@
+#!/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
+
+CRASH_MANAGER_CONF=/etc/crash-manager.conf
+NEW_PATH=/tmp/crash_path_test/
+if [ ! -d ${NEW_PATH} ]; then
+    mkdir ${NEW_PATH}
+else
+    rm -rf ${NEW_PATH}/*
+fi
+
+function check_file_exists {
+    if [ ! -f ${NEW_PATH}/dump/kenny*/kenny*.${1} ]; then
+        exit_with_code "FAIL: no ${1} file in report" 1
+    fi
+}
+
+mount -o rw,remount /
+backup_file ${CRASH_MANAGER_CONF}
+cat ${CRASH_MANAGER_CONF}.backup | sed "s|#[ ]\+CrashRootPath=.*|CrashRootPath=${NEW_PATH}|" > ${CRASH_MANAGER_CONF}
+
+{
+    ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny &
+    sleep 1
+    kill -6 $!
+} 1> /dev/null 2>&1
+
+sleep 2
+
+restore_file ${CRASH_MANAGER_CONF}
+
+wait_for_app crash-manager
+
+pushd ${NEW_PATH}/dump
+if ! unzip kenny*zip > /dev/null; then
+    popd
+    exit_with_code "FAIL: report not found in ${NEW_PATH}/dump" 1
+fi
+popd
+
+check_file_exists coredump
+check_file_exists info
+check_file_exists so_info
+check_file_exists log
+
+exit_with_code "SUCCESS" 0
diff --git a/tests/system/critical_process/critical_process.sh.template b/tests/system/critical_process/critical_process.sh.template
new file mode 100755 (executable)
index 0000000..4c8ce35
--- /dev/null
@@ -0,0 +1,83 @@
+#!/bin/bash
+
+# Crash worker SHOULD create minimal coredump when a "critical
+# process" in user-session is crashed before the user-session is
+# destroyed (or user-session timeouts).
+#
+# "critical process" in user-session is defined as a process which,
+# when failed, causes user-session to terminate.
+
+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_crash_root
+
+SUICIDE_SERVICE_PATH='/usr/lib/systemd/user/suicide.service'
+SES_ID=`su - owner -c "loginctl list-sessions  | head -n2 | tail -n1 | tr -s ' ' | cut -d' ' -f2"`
+
+function clean_after_test {
+    su - owner -c 'systemctl --user stop suicide.service'
+    rm ${SUICIDE_SERVICE_PATH}
+    su - owner -c 'systemctl --user daemon-reload'
+}
+
+mount -o rw,remount /
+cat << EOF > ${SUICIDE_SERVICE_PATH}
+[Unit]
+Description=Test service
+
+[Service]
+Type=oneshot
+ExecStart=/bin/sleep 1
+RemainAfterExit=true
+ExecStop=/bin/sh -c 'kill -6 \$\$\$\$'
+
+[Install]
+RequiredBy=basic.target
+Before=basic.target
+EOF
+
+chsmack -a "_" ${SUICIDE_SERVICE_PATH}
+
+su - owner -c 'systemctl --user daemon-reload'
+su - owner -c 'systemctl --user start suicide.service'
+
+USER_TEST1=`gum-utils -c --username=test1 2> /dev/null`
+if [ -z ${USER_TEST1} ]; then
+    gum-utils -a --username test1 --usertype normal --usecret tizen 1> /dev/null 2>&1
+fi
+
+save_core_pattern
+echo "|/usr/bin/crash-manager %p %u %g %s %t %i" > /proc/sys/kernel/core_pattern
+
+tlm-client -s --username test1 --password tizen --seat seat0 1> /dev/null 2>&1
+sleep 4
+
+restore_core_pattern
+
+TIMEOUT=240
+while true; do
+    if [[ `ls ${CRASH_ROOT_PATH}` =~ sh.*.zip ]]; then
+        tlm-client -s --username owner --password tizen --seat seat0 1> /dev/null 2>&1
+        sleep 4
+        gum-utils -d --username test1 1> /dev/null 2>&1
+        clean_after_test
+        exit_with_code "SUCCESS" 0
+    fi
+
+    if endoftime; then
+        break
+    else
+        sleep 1
+    fi
+done
+
+tlm-client -s --username owner --password tizen --seat seat0 1> /dev/null 2>&1
+sleep 4
+gum-utils -d --username test1 1> /dev/null 2>&1
+
+clean_after_test
+exit_with_code "FAIL" 1
diff --git a/tests/system/info_file/info_file.sh.template b/tests/system/info_file/info_file.sh.template
new file mode 100644 (file)
index 0000000..2e5e227
--- /dev/null
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+# Check correction of the *.info file
+
+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_crash_root
+
+{
+    ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny &
+    sleep 1
+    kill -6 $!
+} 1> /dev/null 2>&1
+
+sleep 2
+
+wait_for_app crash-manager
+
+REPORT_ZIP=$(ls ${CRASH_ROOT_PATH})
+REPORT_DIR=$(basename ${REPORT_ZIP} .zip)
+
+if [ ! -f ${CRASH_ROOT_PATH}/${REPORT_ZIP} ]; then
+    exit_with_code "FAIL: no report in ${CRASH_ROOT_PATH}" 1
+fi
+
+pushd ${CRASH_ROOT_PATH}
+if ! unzip ${REPORT_ZIP} > /dev/nulll; then
+    popd
+    exit_with_code "FAIL: report ${REPORT_ZIP} does not exist"
+fi
+popd
+
+RESULT=$(cat ${CRASH_ROOT_PATH}/${REPORT_DIR}/${REPORT_DIR}.info)
+
+check "Executable File Path: ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny"
+
+RESULT=$(cat ${CRASH_ROOT_PATH}/${REPORT_DIR}/${REPORT_DIR}.info | sed -n '/Register Information/,/Memory information/p')
+
+check "[a-z0-9]+[ \t]+= 0x[a-f0-9]+"
+
+RESULT=$(cat ${CRASH_ROOT_PATH}/${REPORT_DIR}/${REPORT_DIR}.info | sed -n '/Memory information/,/Threads Information/p')
+
+check "MemTotal:"
+check "VmExe:"
+check "VmSwap:"
+
+RESULT=$(cat ${CRASH_ROOT_PATH}/${REPORT_DIR}/${REPORT_DIR}.info | sed -n '/Maps Information/,/End of Maps Information/p')
+
+check "${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny"
+check '[heap]'
+check '/usr/lib/libm-.*.so'
+check '/usr/lib/libc-.*.so'
+check '/usr/lib/libgcc_s.so'
+check '/usr/lib/libstdc++.*so'
+check '/usr/lib/libpthread-.*.so'
+check '/usr/lib/ld-.*.so'
+check '[stack]'
+
+RESULT=$(cat ${CRASH_ROOT_PATH}/${REPORT_DIR}/${REPORT_DIR}.info | sed -n '/Callstack Information/,/End of Call Stack/p')
+
+check ': .*nanosleep'
+check ': .*sleep.*'
+check ': .*start.*kenny'
+check ': main.*kenny'
+
+exit_with_code "SUCCESS" 0
diff --git a/tests/system/log_file/log_file.sh.template b/tests/system/log_file/log_file.sh.template
new file mode 100644 (file)
index 0000000..26b852f
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+# Check correction of the *.log file
+
+if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then
+    CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@"
+fi
+
+function check_section_not_empty {
+    COUNT=${2}
+    RES=$(echo "${RESULT}" | grep -A ${COUNT} "^${1}" | grep -ve "^==== " | wc -l)
+    if [ ${RES} -eq ${COUNT} ]; then
+        return 0
+    fi
+    exit_with_code "FAIL: section ${1} does not contain enough data" 1
+}
+
+function check_section {
+    check "${1}"
+    check_section_not_empty "${1}" ${2}
+}
+
+. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
+
+clean_crash_root
+
+{
+    ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny &
+    sleep 1
+    kill -6 $!
+} 1> /dev/null 2>&1
+
+sleep 2
+
+wait_for_app crash-manager
+
+REPORT_ZIP=$(ls ${CRASH_ROOT_PATH})
+REPORT_DIR=$(basename ${REPORT_ZIP} .zip)
+
+if [ ! -f ${CRASH_ROOT_PATH}/${REPORT_ZIP} ]; then
+    exit_with_code "FAIL: no report in ${CRASH_ROOT_PATH}" 1
+fi
+
+pushd ${CRASH_ROOT_PATH}
+if ! unzip ${REPORT_ZIP} > /dev/nulll; then
+    popd
+    exit_with_code "FAIL: report ${REPORT_ZIP} does not exist"
+fi
+popd
+
+RESULT=$(cat ${CRASH_ROOT_PATH}/${REPORT_DIR}/${REPORT_DIR}.log)
+
+check_section "==== Binary version" 7
+check_section "==== Tizen version" 4
+check_section "==== Kernel version" 2
+check_section "==== Boot arguments" 2
+check_section "==== CPU . system architecture" 7
+check_section "==== System uptime" 2
+check_section "==== System statistics" 5
+check_section "==== System memory usage" 7
+check_section "==== Device major numbers" 2
+check_section "==== System disk I/O" 2
+check_section "==== System disk space usage" 4
+check_section "==== System timezone" 2
+check_section "==== System summary" 5
+check_section "==== Current processes" 10
+check_section "==== System memory statistics" 10
+check_section "==== System configuration" 10
+check_section "==== Kernel messages" 10
+check_section "==== Log messages" 10
+check_section "==== Journal messages" 10
+
+exit_with_code "SUCCESS" 0
diff --git a/tests/system/report_type_info/report_type_info.sh.template b/tests/system/report_type_info/report_type_info.sh.template
new file mode 100644 (file)
index 0000000..b49ac80
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Check the report type change in the config file
+
+if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then
+    CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@"
+fi
+
+. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
+
+CRASH_MANAGER_CONF=/etc/crash-manager.conf
+
+clean_crash_root
+
+mount -o rw,remount /
+backup_file ${CRASH_MANAGER_CONF}
+cat ${CRASH_MANAGER_CONF}.backup | sed "s/#[ ]\+ReportType=.*/ReportType=INFO/" > ${CRASH_MANAGER_CONF}
+
+{
+    ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny &
+    sleep 1
+    kill -6 $!
+} 1> /dev/null 2>&1
+
+sleep 2
+
+restore_file ${CRASH_MANAGER_CONF}
+
+wait_for_app crash-manager
+
+if ! compgen -G ${CRASH_ROOT_PATH}/kenny*info > /dev/null; then
+    exit_with_code "FAIL: info file not found" 1
+fi
+
+exit_with_code "SUCCESS" 0
diff --git a/tests/system/run.sh.template b/tests/system/run.sh.template
new file mode 100644 (file)
index 0000000..b8bd498
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+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")
+
+if [ -z "${CRASH_SYSTEM_TESTS_PATH}" ]; then
+    CRASH_SYSTEM_TESTS_PATH="@CRASH_SYSTEM_TESTS_PATH@"
+fi
+
+LOG_FILE=/tmp/crash-worker_system-tests.log
+
+function run_test {
+    RED="\033[0;31m"
+    GREEN="\033[0;32m"
+    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
+        echo -e "${GREEN}SUCCESS${NORMAL}"
+        echo "SUCCESS" >> ${LOG_FILE}
+    else
+        echo -e "${RED}FAIL${NORMAL}"
+        echo "FAIL" >> ${LOG_FILE}
+    fi
+}
+
+if [ -f ${LOG_FILE} ]; then
+    rm ${LOG_FILE}
+fi
+for TEST in ${TESTS[@]}; do
+    run_test ${TEST}
+done
diff --git a/tests/system/so_info_file/so_info_file.sh.template b/tests/system/so_info_file/so_info_file.sh.template
new file mode 100644 (file)
index 0000000..1838a9b
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# Check correction of the *.so_info file
+
+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_crash_root
+
+{
+    ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny &
+    sleep 1
+    kill -6 $!
+} 1> /dev/null 2>&1
+
+sleep 2
+
+wait_for_app crash-manager
+
+REPORT_ZIP=$(ls ${CRASH_ROOT_PATH})
+REPORT_DIR=$(basename ${REPORT_ZIP} .zip)
+
+if [ ! -f ${CRASH_ROOT_PATH}/${REPORT_ZIP} ]; then
+    exit_with_code "FAIL: no report in ${CRASH_ROOT_PATH}" 1
+fi
+
+pushd ${CRASH_ROOT_PATH}
+if ! unzip ${REPORT_ZIP} > /dev/nulll; then
+    exit_with_code "FAIL: report ${REPORT_ZIP} does not exist"
+fi
+popd
+
+RESULT=$(cat ${CRASH_ROOT_PATH}/${REPORT_DIR}/${REPORT_DIR}.so_info)
+
+check "utils/kenny [a-z0-9]+ crash-worker_system-tests;[^;]+;[^;]+;[a-z0-9]+"
+check "/usr/lib/libm[^ ]+ [a-z0-9]+ glibc;[^;]+;[^;]+;[a-z0-9]+"
+check "/usr/lib/libc[^ ]+ [a-z0-9]+ glibc;[^;]+;[^;]+;[a-z0-9]+"
+check "/usr/lib/libgcc_s[^ ]+ [a-z0-9]+ libgcc;[^;]+;[^;]+;[a-z0-9]+"
+check "/usr/lib/libstdc[^ ]+ [a-z0-9]+ libstd[^;]+;[^;]+;[^;]+;[a-z0-9]+"
+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
diff --git a/tests/system/time_test/cp.sh b/tests/system/time_test/cp.sh
new file mode 100755 (executable)
index 0000000..c8699e8
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+PID=${1} # %p
+USER=${2} # %u
+GID=${3} # %g
+SIG=${4} # %s
+TIME=${5} # %t
+HOST=${6} # %h
+EXE=${7} # %e
+BASE_DIR=${8} # base_dir
+ORIG=${9} # orig
+MINICORE_FILE=${10} # mini
+MINICORE_TIME=${11} # minicore_time
+
+START=$(date +%s)
+/sbin/minicoredumper ${PID} ${USER} ${GID} ${SIG} ${TIME} ${HOST} ${EXE} /etc/minicoredumper/minicoredumper.cfg.json -d ${BASE_DIR} -o ${MINICORE_FILE}
+STOP=$(date +%s)
+
+echo $((${STOP} - ${START})) > ${BASE_DIR}/${MINICORE_TIME}
diff --git a/tests/system/time_test/time_test.sh.template b/tests/system/time_test/time_test.sh.template
new file mode 100755 (executable)
index 0000000..8a78090
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# Minimal coredump SHOULD complete within 5 seconds.
+#
+# Real time MUST be measured from invocation of minicoredumper binary to it
+# closing its standard input file descriptor. Measurement MUST be performed on
+# idle system.
+
+if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then
+    CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@"
+fi
+
+. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
+
+CORE_ORIG='core.orig'
+CORE_MINI='core.mini'
+THREADS_ORIG='threads.orig'
+THREADS_MINI='threads.mini'
+TEMP_DIR='/tmp'
+MINICORE_TIME_FILE='mc_time'
+TIME_LIMIT=5
+
+save_core_pattern
+
+echo "|${CRASH_WORKER_SYSTEM_TESTS}/time_test/cp.sh %p %u %g %s %t %h %e ${TEMP_DIR} ${CORE_ORIG} ${CORE_MINI} ${MINICORE_TIME_FILE}" > /proc/sys/kernel/core_pattern
+
+rm -f ${TEMP_DIR}/${CORE_MINI}
+rm -f ${TEMP_DIR}/${CORE_ORIG}
+rm -f ${TEMP_DIR}/${CORE_ORIG}
+rm -f ${TEMP_DIR}/${MINICORE_TIME_FILE}
+
+{
+    ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny 100 &
+    sleep 1
+    kill -6 $!
+} 1> /dev/null 2>&1
+
+sleep 2
+
+restore_core_pattern
+
+wait_for_file ${TEMP_DIR}/${MINICORE_TIME_FILE}
+
+MINICORE_TIME=$(< ${TEMP_DIR}/${MINICORE_TIME_FILE})
+
+if [ ${MINICORE_TIME} -le ${TIME_LIMIT} ]; then
+    exit_with_code "SUCCESS" 0
+else
+    exit_with_code "FAIL: dumping time: ${MINICORE_TIME} but limit was: ${TIME_LIMIT}" 1
+fi
diff --git a/tests/system/utils/CMakeLists.txt b/tests/system/utils/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a486aab
--- /dev/null
@@ -0,0 +1,14 @@
+cmake_minimum_required (VERSION 2.6)
+project(system_tests)
+
+add_executable(btee btee.c)
+
+add_executable(kenny kenny.cpp)
+find_package(Threads)
+target_link_libraries(kenny ${CMAKE_THREAD_LIBS_INIT})
+set_target_properties(kenny PROPERTIES COMPILE_FLAGS "-std=c++11 -ggdb -O0")
+
+install(TARGETS kenny DESTINATION ${CRASH_SYSTEM_TESTS_PATH}/utils)
+install(TARGETS btee DESTINATION ${CRASH_SYSTEM_TESTS_PATH}/utils)
+install(FILES minicore-utils.sh DESTINATION ${CRASH_SYSTEM_TESTS_PATH}/utils)
+
diff --git a/tests/system/utils/btee.c b/tests/system/utils/btee.c
new file mode 100644 (file)
index 0000000..2f596fa
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors: Mateusz Moscicki <m.moscicki2@partner.samsung.com>
+ */
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define TMP_DIR "/tmp/"
+#define DEFAULT_FILE_NAME "core_"
+
+enum copy_errors {
+       COPY_OK,
+       COPY_WRITE_FAIL,
+       COPY_READ_FAIL
+};
+
+static int copy_data(int dest, int src)
+{
+       char buff[1024];
+       int readed;
+       while ((readed = read(src, buff, sizeof(buff))) > 0) {
+               int written = 0;
+               while ((written = write(dest, buff, readed)) < readed) {
+                       if (written < 0)
+                               return COPY_WRITE_FAIL;
+                       readed -= written;
+               }
+       }
+
+       return readed >= 0 ? COPY_OK : COPY_READ_FAIL;
+}
+
+int main(int argc, char *argv[])
+{
+#define EXIT_FAIL(fmt, ...) { \
+               dprintf(STDERR_FILENO, fmt, ##__VA_ARGS__); \
+               ret = EXIT_FAILURE; \
+               goto exit; \
+       }
+
+       int ret = EXIT_SUCCESS;
+       char *file_name;
+
+       if (argc >= 2)
+               file_name = strdup(argv[1]);
+       else
+               file_name = tempnam(TMP_DIR, DEFAULT_FILE_NAME);
+
+       if (file_name == NULL)
+               EXIT_FAIL("error: %m\n")
+
+       int fd = open(file_name, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+       if (fd == -1)
+               EXIT_FAIL("open file %s error: %m\n", file_name)
+
+       int copy_res = copy_data(fd, STDIN_FILENO);
+       close(fd);
+
+       switch (copy_res) {
+       case COPY_WRITE_FAIL:
+               EXIT_FAIL("write to FD error: %m\n")
+       case COPY_READ_FAIL:
+               EXIT_FAIL("read from STDIN error: %m\n")
+       }
+
+       fd = open(file_name, O_RDONLY);
+       if (fd == -1)
+               EXIT_FAIL("open file %s error: %m\n", file_name)
+
+       copy_res = copy_data(STDOUT_FILENO, fd);
+       close(fd);
+
+       switch (copy_res) {
+       case COPY_WRITE_FAIL:
+               EXIT_FAIL("write to STDOUT error: %m\n")
+       case COPY_READ_FAIL:
+               EXIT_FAIL("read from FD error: %m\n")
+       }
+
+exit:
+       free(file_name);
+       return ret;
+#undef EXIT_FAIL
+}
+
diff --git a/tests/system/utils/kenny.cpp b/tests/system/utils/kenny.cpp
new file mode 100644 (file)
index 0000000..98ec8cb
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors: Mateusz Moscicki <m.moscicki2@partner.samsung.com>
+ */
+#include <unistd.h>
+#include <iostream>
+#include <thread>
+#include <cstring>
+
+static constexpr size_t T_NUM = 8;
+static constexpr size_t DEFAULT_COUNT = 1;
+static constexpr size_t MB = 1024*1024;
+
+// This function is used to check the correctness of gdb
+// callstack, so id param may be useful in this case
+static void MAGICNAME(int id) {
+       while (true)
+               sleep(1);
+}
+
+static bool alloc_chunk(size_t nr) {
+       try {
+               // For tests purposes we have to alloc some memory for nothing
+               char *buff = new char[MB];
+               std::memset(buff, nr % 256, MB);
+       } catch (std::bad_alloc& er) {
+               std::cout << "Memory allocation for " << nr << " chunk failed: " << er.what() << std::endl;
+               return false;
+       }
+
+       return true;
+}
+
+static bool alloc_memory(size_t megabytes) {
+       for (size_t i = 0; i < megabytes; i++) {
+               if (!alloc_chunk(i))
+                       return false;
+    }
+       return true;
+}
+
+static void run(int id) {
+       MAGICNAME(id);
+}
+
+int main(int argc, char *argv[]) {
+       std::thread threads[T_NUM];
+
+       for (size_t i = 0; i < T_NUM; i++) {
+               threads[i] = std::thread(run, i);
+               std::this_thread::sleep_for(std::chrono::microseconds(10));
+       }
+
+       size_t count = DEFAULT_COUNT;
+
+       if (argc > 1)
+               count = std::stoul(argv[1]);
+
+       if (!alloc_memory(count))
+               return EXIT_FAILURE;
+
+       run(-1);
+
+       return EXIT_SUCCESS;
+}
diff --git a/tests/system/utils/minicore-utils.sh b/tests/system/utils/minicore-utils.sh
new file mode 100644 (file)
index 0000000..75f2bfc
--- /dev/null
@@ -0,0 +1,96 @@
+#!/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}" 1
+}
+
+function tzplatform_var {
+    VAL=`tzplatform-get ${1}`
+    if [ $? == 0 ]; then
+        echo $VAL | cut -d'=' -f2
+        return 0
+    fi
+    return 1
+}
+
+function clean_crash_root {
+    export CRASH_ROOT_PATH=`tzplatform_var TZ_SYS_CRASH`
+
+    killall crash-manager
+    killall minicoredumper
+
+    sleep 1
+
+    if [ -z ${CRASH_ROOT_PATH} ]; then
+        exit_with_code "Couldn't get TZ_SYS_CRASH or TZ_SYS_CRASH is empty" 1
+    fi
+
+    if [ ! -d ${CRASH_ROOT_PATH} ]; then
+        exit_with_code "${CRASH_ROOT_PATH} does not exist" 1
+    fi
+
+    rm -rf ${CRASH_ROOT_PATH}/*
+}
+
+function wait_for_file {
+    TIMEOUT=240
+    while [ ! -f ${1} ];
+    do
+        if endoftime; then
+            exit_with_code "FAIL: ${1} does not exist" 1
+        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" 1
+        else
+            sleep 1
+        fi
+    done
+    return 0
+}
+
+function backup_file {
+    cp ${1} ${1}.backup
+}
+
+function restore_file {
+    mv ${1}.backup ${1}
+}
diff --git a/tests/system/wait_for_opt_usr/wait_for_opt_usr.sh.template b/tests/system/wait_for_opt_usr/wait_for_opt_usr.sh.template
new file mode 100755 (executable)
index 0000000..fb35e84
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+# Crash worker SHOULD create minimal coredump when process crashed before
+# /opt/usr (user partition) is mounted.  Crash worker MAY create it in temporary
+# location or wait for /opt/usr partition to be mounted.
+
+if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then
+    CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@"
+fi
+
+. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
+
+OPT_MOUNTPOINT='/opt'
+MTAB=`cat /etc/mtab | grep " ${OPT_MOUNTPOINT}"`
+
+clean_crash_root
+
+if ! umount -l ${OPT_MOUNTPOINT}; then
+    exit_with_code "umount ${OPT_MOUNTPOINT} error" 1
+fi
+
+save_core_pattern
+
+echo "|/usr/bin/crash-manager %p %u %g %s %t %i" > /proc/sys/kernel/core_pattern
+
+{
+    ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny 10 &
+    sleep 1
+    killall -6 kenny
+} 1> /dev/null 2>&1
+
+sleep 20
+
+restore_core_pattern
+
+echo "${MTAB}" | while read OPT_LINE; do
+    OPT_DEV=`echo ${OPT_LINE} | cut -d' ' -f1`
+    OPT_FS=`echo ${OPT_LINE} | cut -d' ' -f3`
+    OPT_OPTS=`echo ${OPT_LINE} | cut -d' ' -f4`
+    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
+    fi
+done
+
+wait_for_app crash-manager
+
+wait_for_file ${CRASH_ROOT_PATH}'/kenny*zip'
diff --git a/tests/system/without_core/without_core.sh.template b/tests/system/without_core/without_core.sh.template
new file mode 100644 (file)
index 0000000..18f92a9
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# Test of generating a report without coredump file
+
+if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then
+    CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@"
+fi
+
+. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
+
+CRASH_MANAGER_CONF=/etc/crash-manager.conf
+
+clean_crash_root
+
+mount -o rw,remount /
+backup_file ${CRASH_MANAGER_CONF}
+cat ${CRASH_MANAGER_CONF}.backup | sed "s/#[ ]\+DumpCore=1/DumpCore=0/" > ${CRASH_MANAGER_CONF}
+
+{
+    ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny &
+    sleep 1
+    kill -6 $!
+} 1> /dev/null 2>&1
+
+sleep 2
+
+restore_file ${CRASH_MANAGER_CONF}
+
+wait_for_app crash-manager
+
+pushd ${CRASH_ROOT_PATH}
+if ! unzip kenny*zip > /dev/null; then
+    popd
+    exit_with_code "FAIL: report does not exist" 1
+fi
+popd
+
+if ls ${CRASH_ROOT_PATH}/kenny*/kenny*.coredump > /dev/null; then
+    exit_with_code "FAIL: coredump file exists" 1
+fi
+
+exit_with_code "SUCCESS" 0