diff options
author | Karol Lewandowski <k.lewandowsk@samsung.com> | 2019-04-26 15:48:32 +0200 |
---|---|---|
committer | Karol Lewandowski <k.lewandowsk@samsung.com> | 2019-04-30 17:15:51 +0200 |
commit | f3bae175b6c367957c8fe5e37fb93ee2666b4bef (patch) | |
tree | 8a1cd202b5fb800dce5e0f5409003c992744671c | |
parent | 4bcce9664ab339519a0e285c41b11651b8570250 (diff) | |
download | crash-worker-f3bae175b6c367957c8fe5e37fb93ee2666b4bef.tar.gz crash-worker-f3bae175b6c367957c8fe5e37fb93ee2666b4bef.tar.bz2 crash-worker-f3bae175b6c367957c8fe5e37fb93ee2666b4bef.zip |
system tests: add `dump_systemstate -e' test
Change-Id: I4fa93d87bffaf2178b213eda2861a2522ce531ad
-rw-r--r-- | packaging/crash-worker_system-tests.spec | 3 | ||||
-rw-r--r-- | tests/system/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/system/dump_systemstate_extras/dump_systemstate_extras.sh.template | 64 |
3 files changed, 67 insertions, 1 deletions
diff --git a/packaging/crash-worker_system-tests.spec b/packaging/crash-worker_system-tests.spec index 660872d..a9cf4d4 100644 --- a/packaging/crash-worker_system-tests.spec +++ b/packaging/crash-worker_system-tests.spec @@ -22,7 +22,7 @@ Requires: coreutils Requires: tlm Requires: /bin/bash Requires: /usr/bin/unzip - +Requires: /usr/bin/mcookie Requires: crash-worker Requires: %{_sbindir}/minicoredumper @@ -69,6 +69,7 @@ cd tests/system %{_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/dump_systemstate_extras/dump_systemstate_extras.sh %{_libdir}/crash-worker_system-tests/utils/btee %{_libdir}/crash-worker_system-tests/utils/kenny %{_libdir}/crash-worker_system-tests/utils/minicore-utils.sh diff --git a/tests/system/CMakeLists.txt b/tests/system/CMakeLists.txt index 0767dc1..b8015d7 100644 --- a/tests/system/CMakeLists.txt +++ b/tests/system/CMakeLists.txt @@ -35,6 +35,7 @@ configure_test("crash_root_path") configure_test("log_dump_short") configure_test("log_dump_normal") configure_test("log_dump_crash_root_path") +configure_test("dump_systemstate_extras") get_property(TESTS_LIST GLOBAL PROPERTY TMP_TESTS_LIST) diff --git a/tests/system/dump_systemstate_extras/dump_systemstate_extras.sh.template b/tests/system/dump_systemstate_extras/dump_systemstate_extras.sh.template new file mode 100644 index 0000000..3899ae1 --- /dev/null +++ b/tests/system/dump_systemstate_extras/dump_systemstate_extras.sh.template @@ -0,0 +1,64 @@ +#!/bin/bash + +# Check dump_systemstate -e + +if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then + CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@" +fi + +function do_check { + f="$1" + section_pat="$2" + section_len="$3" + 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 + fi +} + +. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh + +mount -o rw,remount / + +cookie1=$(mcookie) +cookie2=$(mcookie) +cookie3=$(mcookie) +cookie3_tmpfile=$(mktemp /tmp/cookie3.XXXXXX) +echo $cookie3 > $cookie3_tmpfile +tmpfile=$(mktemp /tmp/dump_systemstate_extra.XXXXXX) + +cleanup() +{ + rm -f "$cookie3_tmpfile" "$tmpfile" + rm -f /etc/dump_systemstate.conf.d/files/dump_systemstate_extras_system_test.conf + rm -f /etc/dump_systemstate.conf.d/programs/dump_systemstate_extras_system_test.conf + mount -o ro,remount / +} +trap cleanup 0 + +cat > /etc/dump_systemstate.conf.d/programs/dump_systemstate_extras_system_test.conf <<EOF +[Prog1] +title=$cookie1 +path=/bin/echo +args=magic_cookie is $cookie1 + +[Prog2] +title=/bin/env test +path=/bin/env +env=MAGIC_SECRET=$cookie2 +EOF + +cat > /etc/dump_systemstate.conf.d/files/dump_systemstate_extras_system_test.conf <<EOF +[File1] +title=file for cookie3 +path=$cookie3_tmpfile +EOF + +dump_systemstate -e > $tmpfile + +do_check $tmpfile "==== $cookie1" 1 "^magic_cookie is $cookie1" +do_check $tmpfile "==== /bin/env test" 999 "^MAGIC_SECRET=$cookie2" +do_check $tmpfile "==== file for cookie3" 1 "^$cookie3" + +exit_with_code "SUCCESS" 0 |