From 770ef44c466bf977da8d63ac4b5153f926bdf7a8 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Fri, 7 Dec 2018 11:02:24 +0100 Subject: [PATCH 01/16] crash-stack: Fix format specifier Change-Id: Ifdc4a229275b866f5718f0779b1a9cba01d7b1ea --- src/crash-stack/proc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crash-stack/proc.c b/src/crash-stack/proc.c index fd346c6..da21663 100644 --- a/src/crash-stack/proc.c +++ b/src/crash-stack/proc.c @@ -472,8 +472,8 @@ static int copy_memory_proc_mem(int pid, struct mem_data_chunk **frames, ssize_t rd = pread(fd, to, count, from); if (rd == -1) { - _E("pread() at %s:0x%lx (#%d) failed: %m [%d]", - fname, from, i, errno); + _E("pread() at %s:0x%llx (#%d) failed: %m [%d]", + fname, from, i, errno); goto proc_mem_end; } -- 2.7.4 From ac711afc73c2b8db9b6f2a673da9bbee9869d882 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Fri, 14 Dec 2018 16:08:46 +0100 Subject: [PATCH 02/16] Release 5.5.4 This release brings following fixes: - fix DLog format specifier (needed if DLog start enforcing valid printf-formats) - fix: Make disk-usage functions use off_t - relability fix: crash-manager: Do not force system to wait for crash-popup to complete Change-Id: I733f09298c34c1c7824f57dfa156f23cf9196947 --- packaging/crash-worker.spec | 2 +- packaging/crash-worker_system-tests.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index 3a221ce..587c925 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -10,7 +10,7 @@ Name: crash-worker Summary: Crash-manager -Version: 5.5.3 +Version: 5.5.4 Release: 1 Group: Framework/system License: Apache-2.0 and BSD diff --git a/packaging/crash-worker_system-tests.spec b/packaging/crash-worker_system-tests.spec index 68f521e..6e814f0 100644 --- a/packaging/crash-worker_system-tests.spec +++ b/packaging/crash-worker_system-tests.spec @@ -6,7 +6,7 @@ Name: crash-worker_system-tests Summary: Package with binaries and scripts for crash-worker system tests -Version: 5.5.3 +Version: 5.5.4 Release: 1 Group: Framework/system License: Apache-2.0 and BSD -- 2.7.4 From 2f379db2c637bda9c84b8606fdc9bbb2b721e5f8 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Tue, 18 Dec 2018 12:15:40 +0100 Subject: [PATCH 03/16] Fix DLog format specifier for 64-bit architecures Change-Id: I3f29eb0dc3e5081843f0c982dab92cd45aad1364 --- src/crash-manager/crash-manager.c | 5 +++-- src/crash-stack/proc.c | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index 215904b..1cba5ee 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -976,7 +977,7 @@ static int scan_dump(struct file_info **dump_list, off_t *usage) *usage = 0; for (i = 0; i < dump_num; i++) { - _D("[%d] path: %s(%s), size: %d kb, mtime: %s", + _D("[%d] path: %s(%s), size: %zu kb, mtime: %s", i, temp_list[i].path, temp_list[i].isdir ? "DIR" : "FILE", @@ -1065,7 +1066,7 @@ static void clean_dump(void) dump_list[i].path); break; case USAGE_EXCEED: - _I("Reached the maximum disk usage %lld/%d kb, so remove (%s)", + _I("Reached the maximum disk usage %" PRId64 "/%d kb, so remove (%s)", usage / 1024, system_max_use, dump_list[i].path); break; diff --git a/src/crash-stack/proc.c b/src/crash-stack/proc.c index da21663..46f40e1 100644 --- a/src/crash-stack/proc.c +++ b/src/crash-stack/proc.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -472,7 +473,7 @@ static int copy_memory_proc_mem(int pid, struct mem_data_chunk **frames, ssize_t rd = pread(fd, to, count, from); if (rd == -1) { - _E("pread() at %s:0x%llx (#%d) failed: %m [%d]", + _E("pread() at %s:0x%" PRIx64 " (#%d) failed: %m [%d]", fname, from, i, errno); goto proc_mem_end; } -- 2.7.4 From d233538e2b50d3fe644a64096945ea35fe65495d Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Tue, 18 Dec 2018 12:25:56 +0100 Subject: [PATCH 04/16] Release 5.5.5 This release brings one change - DLog format specifier fixes for 64-bit architecures. Change-Id: I443faa5a06afb9c272c953360e0f85cbf913f7db --- packaging/crash-worker.spec | 2 +- packaging/crash-worker_system-tests.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index 587c925..287cfbd 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -10,7 +10,7 @@ Name: crash-worker Summary: Crash-manager -Version: 5.5.4 +Version: 5.5.5 Release: 1 Group: Framework/system License: Apache-2.0 and BSD diff --git a/packaging/crash-worker_system-tests.spec b/packaging/crash-worker_system-tests.spec index 6e814f0..c57473b 100644 --- a/packaging/crash-worker_system-tests.spec +++ b/packaging/crash-worker_system-tests.spec @@ -6,7 +6,7 @@ Name: crash-worker_system-tests Summary: Package with binaries and scripts for crash-worker system tests -Version: 5.5.4 +Version: 5.5.5 Release: 1 Group: Framework/system License: Apache-2.0 and BSD -- 2.7.4 From 11f80fbdbf633b1f396e87d87c08de757fdb1bd4 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Thu, 17 Jan 2019 12:38:48 +0100 Subject: [PATCH 05/16] svace: fix closing potentially negative fd This commit fixes following issue reported by svace: "Variable 'cinfo.prstatus_fd', which may receive negative value at crash-manager.c:588 by calling function 'set_crash_info' at crash-manager.c:1267, is used at crash-manager.c:1332 by calling function 'close'." Change-Id: Ie625bc8ac5eb16a84bb7b139b569c6189e1a5e25 --- src/crash-manager/crash-manager.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index 1cba5ee..e2c6a0f 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -1202,7 +1202,7 @@ static void free_crash_info(struct crash_info *cinfo) int main(int argc, char *argv[]) { - struct crash_info cinfo = {0}; + struct crash_info cinfo = {.prstatus_fd = -1}; /* Execute dump_systemstate in parallel */ static int dump_state_pid; @@ -1319,7 +1319,8 @@ int main(int argc, char *argv[]) launch_crash_popup(&cinfo); exit: - close(cinfo.prstatus_fd); + if (cinfo.prstatus_fd >= 0) + close(cinfo.prstatus_fd); free(crash_temp_path); free(crash_root_path); free(crash_crash_path); -- 2.7.4 From 9501909d076fa49b299c69dd4175abb2cb1a764f Mon Sep 17 00:00:00 2001 From: Mateusz Moscicki Date: Mon, 14 Jan 2019 13:41:50 +0100 Subject: [PATCH 06/16] Add support for tpk packages Change-Id: Ic625678478e3dc888bea786bb203ef021c579228 --- src/crash-manager/so-info.c | 121 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/src/crash-manager/so-info.c b/src/crash-manager/so-info.c index 07032b5..554edc4 100644 --- a/src/crash-manager/so-info.c +++ b/src/crash-manager/so-info.c @@ -284,9 +284,116 @@ char* get_rpm_info(rpmts ts, const char* filename) return rpm_info; } +struct rpm_file { + char *pkg_name; + char *file_name; +}; + +GSList* create_tpk_list(rpmts ts) +{ + GSList *tpk_list = NULL; + + rpmdbMatchIterator mi = rpmtsInitIterator(ts, RPMTAG_NAME, NULL, 0); + if (mi == NULL) { + _E("Failed to init rpmdb match iterator"); + goto end; + } + + for (Header h = rpmdbNextIterator(mi); h; h = rpmdbNextIterator(mi)) { + const char *pkg_name = headerGetString(h, RPMTAG_NAME); + if (pkg_name == NULL) + continue; + rpmfi fi = rpmfiNew(NULL, h, RPMTAG_FILENAMES, 0); + + while (rpmfiNext(fi) != -1) { + const char *file_name = rpmfiFN(fi); + size_t file_name_len = strlen(file_name); + + if (file_name_len < 4 || + strcmp(&file_name[file_name_len-4], ".tpk") != 0) + continue; + + struct rpm_file *rpm = (struct rpm_file*)malloc(sizeof(rpm)); + if (rpm == NULL) { + _E("malloc() error (%m). Report (*.so_info) may be incomplete."); + continue; + } + + const char *version = headerGetString(h, RPMTAG_VERSION); + const char *release = headerGetString(h, RPMTAG_RELEASE); + const char *arch = headerGetString(h, RPMTAG_ARCH); + + if (version == NULL || release == NULL || arch == NULL) + continue; + + if (asprintf(&rpm->pkg_name, "%s;%s;%s;%s", + pkg_name, version, release, arch) == -1) { + _E("asprintf() error: %m"); + free(rpm); + continue; + } + rpm->file_name = strdup(file_name); + if (rpm->file_name == NULL) { + _E("strdup() error: %m"); + free(rpm->pkg_name); + free(rpm); + continue; + } + tpk_list = g_slist_append(tpk_list, rpm); + } + } + rpmdbFreeIterator(mi); + + if (tpk_list == NULL) + _E("No RPM packages containing *.tpk files found"); +end: + return tpk_list; +} + +char* get_app_name_from_path(const char *file_path) +{ + static const char *prefix[] = {"/usr/apps/", + "/opt/usr/globalapps/", + NULL}; + + for (size_t i = 0; i < ARRAY_SIZE(prefix); i++) { + if (strncmp(file_path, prefix[i], strlen(prefix[i])) != 0) + continue; + + const char *app_name = &file_path[strlen(prefix[i])]; + + char *end_of_name = strchr(app_name, '/'); + if (end_of_name != NULL) + return strndup(app_name, end_of_name - app_name); + } + return NULL; +} + +char* get_rpm_info_for_tpk(GSList *tpk_list, const char *file_path) +{ + char *app_name = get_app_name_from_path(file_path); + if (app_name == NULL) + return NULL; + + char *res = NULL; + + for (GSList *iterator = tpk_list; iterator; iterator = iterator->next) { + struct rpm_file *rpm_pkg = (struct rpm_file *)iterator->data; + + if (strstr(rpm_pkg->file_name, app_name) != NULL) { + res = strdup(rpm_pkg->pkg_name); + break; + } + } + + free(app_name); + return res; +} + void get_and_save_so_info(char *map_path, char *out_path) { GSList *file_list = get_filepaths(map_path); + GSList *tpk_list = NULL; char *rpm_info; FILE *f = fopen(out_path, "w"); @@ -306,6 +413,12 @@ void get_and_save_so_info(char *map_path, char *out_path) int fret; rpm_info = get_rpm_info(ts, file_path); + if (rpm_info == NULL) { + if (tpk_list == NULL) + tpk_list = create_tpk_list(ts); + if (tpk_list != NULL) + rpm_info = get_rpm_info_for_tpk(tpk_list, file_path); + } if (rpm_info == NULL) fret = fprintf(f, "%s %s\n", file_path, build_id); else { @@ -326,7 +439,15 @@ void get_and_save_so_info(char *map_path, char *out_path) for (GSList *iterator = file_list; iterator; iterator = iterator->next) free(iterator->data); + for (GSList *iterator = tpk_list; iterator; iterator = iterator->next) { + struct rpm_file *rpm = (struct rpm_file*)iterator->data; + free(rpm->file_name); + free(rpm->pkg_name); + free(rpm); + } + g_slist_free(file_list); + g_slist_free(tpk_list); free_rpm(ts); } -- 2.7.4 From 69d34b239dca0725a5cb48917698ebbd75abe729 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Thu, 17 Jan 2019 16:20:23 +0100 Subject: [PATCH 07/16] Release 5.5.6 This release adds information about crashed application (.tpk) to .so_info file. Additionally, one svace issue is fixed. Change-Id: I0ce18e1c47906df26bc996960681685a33f88c89 --- packaging/crash-worker.spec | 2 +- packaging/crash-worker_system-tests.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index 287cfbd..e77648b 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -10,7 +10,7 @@ Name: crash-worker Summary: Crash-manager -Version: 5.5.5 +Version: 5.5.6 Release: 1 Group: Framework/system License: Apache-2.0 and BSD diff --git a/packaging/crash-worker_system-tests.spec b/packaging/crash-worker_system-tests.spec index c57473b..58ee9ca 100644 --- a/packaging/crash-worker_system-tests.spec +++ b/packaging/crash-worker_system-tests.spec @@ -6,7 +6,7 @@ Name: crash-worker_system-tests Summary: Package with binaries and scripts for crash-worker system tests -Version: 5.5.5 +Version: 5.5.6 Release: 1 Group: Framework/system License: Apache-2.0 and BSD -- 2.7.4 From f1c251b1ebb9e8857438068c4018c56d514e2a7c Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Fri, 1 Feb 2019 17:22:58 +0900 Subject: [PATCH 08/16] log_dump: change permission of service file The systemd service file should be set to root ownership. Change-Id: I27978116c0b6f1c782285a604e30ee093999166b Signed-off-by: Sunmin Lee --- packaging/crash-worker.spec | 2 +- src/log_dump/CMakeLists.txt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index e77648b..904e238 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -172,7 +172,7 @@ sed -i "/${pattern}/D" %{_sysconfdir}/ld.so.preload %dir %{crash_all_log} %{crash_dump_gen}/* %attr(0750,system_fw,system_fw) %{_bindir}/* -%{_unitdir}/log_dump.service +%attr(-,root,root) %{_unitdir}/log_dump.service %{_sysconfdir}/crash-manager.conf %attr(-,root,root) %{_sysconfdir}/dbus-1/system.d/log_dump.conf %attr(-,root,root) %{_prefix}/lib/sysctl.d/99-crash-manager.conf diff --git a/src/log_dump/CMakeLists.txt b/src/log_dump/CMakeLists.txt index fcceff5..e43654d 100644 --- a/src/log_dump/CMakeLists.txt +++ b/src/log_dump/CMakeLists.txt @@ -39,8 +39,7 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/log_dump.conf DESTINATION /etc/dbus-1/system.d) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/log_dump.service DESTINATION /usr/lib/systemd/system - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE -- 2.7.4 From 330d32ec418d5e4f6fedfeaef36d586b96c0cf11 Mon Sep 17 00:00:00 2001 From: Mateusz Moscicki Date: Tue, 12 Feb 2019 14:48:10 +0100 Subject: [PATCH 09/16] Fix allocation size mismatch Change-Id: Iee761aafd7f7cb63d12acc48345519faba821536 --- src/crash-manager/so-info.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/crash-manager/so-info.c b/src/crash-manager/so-info.c index 554edc4..cab1398 100644 --- a/src/crash-manager/so-info.c +++ b/src/crash-manager/so-info.c @@ -313,12 +313,6 @@ GSList* create_tpk_list(rpmts ts) strcmp(&file_name[file_name_len-4], ".tpk") != 0) continue; - struct rpm_file *rpm = (struct rpm_file*)malloc(sizeof(rpm)); - if (rpm == NULL) { - _E("malloc() error (%m). Report (*.so_info) may be incomplete."); - continue; - } - const char *version = headerGetString(h, RPMTAG_VERSION); const char *release = headerGetString(h, RPMTAG_RELEASE); const char *arch = headerGetString(h, RPMTAG_ARCH); @@ -326,6 +320,12 @@ GSList* create_tpk_list(rpmts ts) if (version == NULL || release == NULL || arch == NULL) continue; + struct rpm_file *rpm = (struct rpm_file*)malloc(sizeof(*rpm)); + if (rpm == NULL) { + _E("malloc() error (%m). Report (*.so_info) may be incomplete."); + continue; + } + if (asprintf(&rpm->pkg_name, "%s;%s;%s;%s", pkg_name, version, release, arch) == -1) { _E("asprintf() error: %m"); -- 2.7.4 From 6aa1ef3902205d1c00fe48d2b88601f41a62de5f Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Thu, 14 Feb 2019 15:41:44 +0100 Subject: [PATCH 10/16] Release 5.5.7 This release brings following changes: - Fix allocation size mismatch (SVACE fix) - log_dump: change permission of service file Change-Id: I8ca897471a727b811d62baa323c7a166ff40412a --- packaging/crash-worker.spec | 2 +- packaging/crash-worker_system-tests.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index 904e238..1816bef 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -10,7 +10,7 @@ Name: crash-worker Summary: Crash-manager -Version: 5.5.6 +Version: 5.5.7 Release: 1 Group: Framework/system License: Apache-2.0 and BSD diff --git a/packaging/crash-worker_system-tests.spec b/packaging/crash-worker_system-tests.spec index 58ee9ca..080009f 100644 --- a/packaging/crash-worker_system-tests.spec +++ b/packaging/crash-worker_system-tests.spec @@ -6,7 +6,7 @@ Name: crash-worker_system-tests Summary: Package with binaries and scripts for crash-worker system tests -Version: 5.5.6 +Version: 5.5.7 Release: 1 Group: Framework/system License: Apache-2.0 and BSD -- 2.7.4 From 13a13714bda94399ed425d6491dd02d50fe8d566 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Tue, 19 Feb 2019 13:04:34 +0100 Subject: [PATCH 11/16] crash-manager: Fix error checking for pkgmgrinfo*() invocation This commit fixes 'unchecked return value' as reported by coverity. Change-Id: I8c31504fd03826862f85df5ff24d7752a12262e9 --- src/crash-manager/crash-manager.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index e2c6a0f..dee6e62 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -143,13 +143,11 @@ static int appinfo_get_appid_func(pkgmgrinfo_appinfo_h handle, void *user_data) { char *str = NULL; - int ret = PMINFO_R_ERROR; - pkgmgrinfo_appinfo_get_appid(handle, &str); - if (str) { + int ret = pkgmgrinfo_appinfo_get_appid(handle, &str); + if (ret == PMINFO_R_OK && str) (*(char **)user_data) = strdup(str); - ret = PMINFO_R_OK; - } + return ret; } -- 2.7.4 From 14cd1b8dea941c694af29f24330b32629c94065a Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Tue, 19 Feb 2019 13:23:59 +0100 Subject: [PATCH 12/16] Release 5.5.8 This change brings on Coverity fix. Change-Id: I8da5e50276189c609a70712d3d652f44237346d5 --- packaging/crash-worker.spec | 2 +- packaging/crash-worker_system-tests.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/crash-worker.spec b/packaging/crash-worker.spec index 1816bef..42835d6 100644 --- a/packaging/crash-worker.spec +++ b/packaging/crash-worker.spec @@ -10,7 +10,7 @@ Name: crash-worker Summary: Crash-manager -Version: 5.5.7 +Version: 5.5.8 Release: 1 Group: Framework/system License: Apache-2.0 and BSD diff --git a/packaging/crash-worker_system-tests.spec b/packaging/crash-worker_system-tests.spec index 080009f..efbee08 100644 --- a/packaging/crash-worker_system-tests.spec +++ b/packaging/crash-worker_system-tests.spec @@ -6,7 +6,7 @@ Name: crash-worker_system-tests Summary: Package with binaries and scripts for crash-worker system tests -Version: 5.5.7 +Version: 5.5.8 Release: 1 Group: Framework/system License: Apache-2.0 and BSD -- 2.7.4 From 5cd071d122d6fd4713a0fce51116d62639b00940 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Thu, 21 Feb 2019 15:55:19 +0100 Subject: [PATCH 13/16] system tests: scripts depend on bash extensions Even if given script does not explicitly use bash extensions it sources minicore-utils.sh, which do require bash. Change-Id: I1689531bf9f9a60f0e2c607dad504d92c5419fba --- packaging/crash-worker_system-tests.spec | 1 + tests/system/check_minicore_mem/check_minicore_mem.sh.template | 2 +- tests/system/cmp_backtraces/cmp_backtraces.sh.template | 2 +- tests/system/crash_root_path/crash_root_path.sh.template | 2 +- tests/system/info_file/info_file.sh.template | 2 +- tests/system/log_file/log_file.sh.template | 2 +- tests/system/report_type_info/report_type_info.sh.template | 2 +- tests/system/run.sh.template | 2 +- tests/system/so_info_file/so_info_file.sh.template | 2 +- tests/system/time_test/time_test.sh.template | 2 +- tests/system/wait_for_opt_usr/wait_for_opt_usr.sh.template | 2 +- tests/system/without_core/without_core.sh.template | 2 +- 12 files changed, 12 insertions(+), 11 deletions(-) diff --git a/packaging/crash-worker_system-tests.spec b/packaging/crash-worker_system-tests.spec index efbee08..11d644a 100644 --- a/packaging/crash-worker_system-tests.spec +++ b/packaging/crash-worker_system-tests.spec @@ -20,6 +20,7 @@ Requires: diff Requires: gdb Requires: coreutils Requires: tlm +Requires: /bin/bash Requires: crash-worker Requires: %{_sbindir}/minicoredumper diff --git a/tests/system/check_minicore_mem/check_minicore_mem.sh.template b/tests/system/check_minicore_mem/check_minicore_mem.sh.template index 627088a..5ad2382 100755 --- a/tests/system/check_minicore_mem/check_minicore_mem.sh.template +++ b/tests/system/check_minicore_mem/check_minicore_mem.sh.template @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Minimal coredump MUST consume less than 100MB, assuming it is created from # process with maximum number of 8 threads. diff --git a/tests/system/cmp_backtraces/cmp_backtraces.sh.template b/tests/system/cmp_backtraces/cmp_backtraces.sh.template index 11142e9..ecf3d77 100755 --- a/tests/system/cmp_backtraces/cmp_backtraces.sh.template +++ b/tests/system/cmp_backtraces/cmp_backtraces.sh.template @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Functionality to create minimal coredump MUST be provided. It MUST have # following properties: diff --git a/tests/system/crash_root_path/crash_root_path.sh.template b/tests/system/crash_root_path/crash_root_path.sh.template index 95c818e..625ae36 100644 --- a/tests/system/crash_root_path/crash_root_path.sh.template +++ b/tests/system/crash_root_path/crash_root_path.sh.template @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Custom report path test diff --git a/tests/system/info_file/info_file.sh.template b/tests/system/info_file/info_file.sh.template index 2e5e227..b98b6a9 100644 --- a/tests/system/info_file/info_file.sh.template +++ b/tests/system/info_file/info_file.sh.template @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Check correction of the *.info file diff --git a/tests/system/log_file/log_file.sh.template b/tests/system/log_file/log_file.sh.template index 26b852f..f032f15 100644 --- a/tests/system/log_file/log_file.sh.template +++ b/tests/system/log_file/log_file.sh.template @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Check correction of the *.log file diff --git a/tests/system/report_type_info/report_type_info.sh.template b/tests/system/report_type_info/report_type_info.sh.template index b49ac80..a9021b1 100644 --- a/tests/system/report_type_info/report_type_info.sh.template +++ b/tests/system/report_type_info/report_type_info.sh.template @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Check the report type change in the config file diff --git a/tests/system/run.sh.template b/tests/system/run.sh.template index b8bd498..236151c 100644 --- a/tests/system/run.sh.template +++ b/tests/system/run.sh.template @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash TESTS=("check_minicore_mem" "cmp_backtraces" "info_file" "log_file" "report_type_info" "critical_process" "time_test" "wait_for_opt_usr" diff --git a/tests/system/so_info_file/so_info_file.sh.template b/tests/system/so_info_file/so_info_file.sh.template index 1838a9b..d736198 100644 --- a/tests/system/so_info_file/so_info_file.sh.template +++ b/tests/system/so_info_file/so_info_file.sh.template @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Check correction of the *.so_info file diff --git a/tests/system/time_test/time_test.sh.template b/tests/system/time_test/time_test.sh.template index 8a78090..5df1cee 100755 --- a/tests/system/time_test/time_test.sh.template +++ b/tests/system/time_test/time_test.sh.template @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Minimal coredump SHOULD complete within 5 seconds. # 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 index fb35e84..7c00b99 100755 --- 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 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Crash worker SHOULD create minimal coredump when process crashed before # /opt/usr (user partition) is mounted. Crash worker MAY create it in temporary diff --git a/tests/system/without_core/without_core.sh.template b/tests/system/without_core/without_core.sh.template index 18f92a9..be8869c 100644 --- a/tests/system/without_core/without_core.sh.template +++ b/tests/system/without_core/without_core.sh.template @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Test of generating a report without coredump file -- 2.7.4 From 8663d442a71f8f9f87283986fce97e4a9e9b2eb4 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Thu, 21 Feb 2019 16:34:57 +0100 Subject: [PATCH 14/16] system tests: rationalize naming Change-Id: I21d22e7cba27ce4ede716573056946bf3cd3ddd6 --- .../critical_process/critical_process.sh.template | 4 ++-- tests/system/info_file/info_file.sh.template | 20 ++++++++++---------- tests/system/log_file/log_file.sh.template | 12 ++++++------ .../report_type_info/report_type_info.sh.template | 4 ++-- tests/system/so_info_file/so_info_file.sh.template | 12 ++++++------ tests/system/utils/minicore-utils.sh | 12 ++++++------ .../wait_for_opt_usr/wait_for_opt_usr.sh.template | 4 ++-- tests/system/without_core/without_core.sh.template | 6 +++--- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/tests/system/critical_process/critical_process.sh.template b/tests/system/critical_process/critical_process.sh.template index 4c8ce35..e3c38e1 100755 --- a/tests/system/critical_process/critical_process.sh.template +++ b/tests/system/critical_process/critical_process.sh.template @@ -13,7 +13,7 @@ fi . ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh -clean_crash_root +clean_crash_dump 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"` @@ -60,7 +60,7 @@ restore_core_pattern TIMEOUT=240 while true; do - if [[ `ls ${CRASH_ROOT_PATH}` =~ sh.*.zip ]]; then + if [[ `ls ${CRASH_DUMP_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 diff --git a/tests/system/info_file/info_file.sh.template b/tests/system/info_file/info_file.sh.template index b98b6a9..129799a 100644 --- a/tests/system/info_file/info_file.sh.template +++ b/tests/system/info_file/info_file.sh.template @@ -8,7 +8,7 @@ fi . ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh -clean_crash_root +clean_crash_dump { ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny & @@ -20,35 +20,35 @@ sleep 2 wait_for_app crash-manager -REPORT_ZIP=$(ls ${CRASH_ROOT_PATH}) +REPORT_ZIP=$(ls ${CRASH_DUMP_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 +if [ ! -f ${CRASH_DUMP_PATH}/${REPORT_ZIP} ]; then + exit_with_code "FAIL: no report in ${CRASH_DUMP_PATH}" 1 fi -pushd ${CRASH_ROOT_PATH} +pushd ${CRASH_DUMP_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) +RESULT=$(cat ${CRASH_DUMP_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') +RESULT=$(cat ${CRASH_DUMP_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') +RESULT=$(cat ${CRASH_DUMP_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') +RESULT=$(cat ${CRASH_DUMP_PATH}/${REPORT_DIR}/${REPORT_DIR}.info | sed -n '/Maps Information/,/End of Maps Information/p') check "${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny" check '[heap]' @@ -60,7 +60,7 @@ 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') +RESULT=$(cat ${CRASH_DUMP_PATH}/${REPORT_DIR}/${REPORT_DIR}.info | sed -n '/Callstack Information/,/End of Call Stack/p') check ': .*nanosleep' check ': .*sleep.*' diff --git a/tests/system/log_file/log_file.sh.template b/tests/system/log_file/log_file.sh.template index f032f15..3a0c385 100644 --- a/tests/system/log_file/log_file.sh.template +++ b/tests/system/log_file/log_file.sh.template @@ -22,7 +22,7 @@ function check_section { . ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh -clean_crash_root +clean_crash_dump { ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny & @@ -34,21 +34,21 @@ sleep 2 wait_for_app crash-manager -REPORT_ZIP=$(ls ${CRASH_ROOT_PATH}) +REPORT_ZIP=$(ls ${CRASH_DUMP_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 +if [ ! -f ${CRASH_DUMP_PATH}/${REPORT_ZIP} ]; then + exit_with_code "FAIL: no report in ${CRASH_DUMP_PATH}" 1 fi -pushd ${CRASH_ROOT_PATH} +pushd ${CRASH_DUMP_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) +RESULT=$(cat ${CRASH_DUMP_PATH}/${REPORT_DIR}/${REPORT_DIR}.log) check_section "==== Binary version" 7 check_section "==== Tizen version" 4 diff --git a/tests/system/report_type_info/report_type_info.sh.template b/tests/system/report_type_info/report_type_info.sh.template index a9021b1..eaaf748 100644 --- a/tests/system/report_type_info/report_type_info.sh.template +++ b/tests/system/report_type_info/report_type_info.sh.template @@ -10,7 +10,7 @@ fi CRASH_MANAGER_CONF=/etc/crash-manager.conf -clean_crash_root +clean_crash_dump mount -o rw,remount / backup_file ${CRASH_MANAGER_CONF} @@ -28,7 +28,7 @@ restore_file ${CRASH_MANAGER_CONF} wait_for_app crash-manager -if ! compgen -G ${CRASH_ROOT_PATH}/kenny*info > /dev/null; then +if ! compgen -G ${CRASH_DUMP_PATH}/kenny*info > /dev/null; then exit_with_code "FAIL: info file not found" 1 fi diff --git a/tests/system/so_info_file/so_info_file.sh.template b/tests/system/so_info_file/so_info_file.sh.template index d736198..fe5c8c0 100644 --- a/tests/system/so_info_file/so_info_file.sh.template +++ b/tests/system/so_info_file/so_info_file.sh.template @@ -8,7 +8,7 @@ fi . ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh -clean_crash_root +clean_crash_dump { ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny & @@ -20,20 +20,20 @@ sleep 2 wait_for_app crash-manager -REPORT_ZIP=$(ls ${CRASH_ROOT_PATH}) +REPORT_ZIP=$(ls ${CRASH_DUMP_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 +if [ ! -f ${CRASH_DUMP_PATH}/${REPORT_ZIP} ]; then + exit_with_code "FAIL: no report in ${CRASH_DUMP_PATH}" 1 fi -pushd ${CRASH_ROOT_PATH} +pushd ${CRASH_DUMP_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) +RESULT=$(cat ${CRASH_DUMP_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]+" diff --git a/tests/system/utils/minicore-utils.sh b/tests/system/utils/minicore-utils.sh index 75f2bfc..9cb8627 100644 --- a/tests/system/utils/minicore-utils.sh +++ b/tests/system/utils/minicore-utils.sh @@ -39,23 +39,23 @@ function tzplatform_var { return 1 } -function clean_crash_root { - export CRASH_ROOT_PATH=`tzplatform_var TZ_SYS_CRASH` +function clean_crash_dump { + export CRASH_DUMP_PATH=`tzplatform_var TZ_SYS_CRASH` killall crash-manager killall minicoredumper sleep 1 - if [ -z ${CRASH_ROOT_PATH} ]; then + if [ -z ${CRASH_DUMP_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 + if [ ! -d ${CRASH_DUMP_PATH} ]; then + exit_with_code "${CRASH_DUMP_PATH} does not exist" 1 fi - rm -rf ${CRASH_ROOT_PATH}/* + rm -rf ${CRASH_DUMP_PATH}/* } function wait_for_file { 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 index 7c00b99..c799e18 100755 --- 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 @@ -13,7 +13,7 @@ fi OPT_MOUNTPOINT='/opt' MTAB=`cat /etc/mtab | grep " ${OPT_MOUNTPOINT}"` -clean_crash_root +clean_crash_dump if ! umount -l ${OPT_MOUNTPOINT}; then exit_with_code "umount ${OPT_MOUNTPOINT} error" 1 @@ -46,4 +46,4 @@ done wait_for_app crash-manager -wait_for_file ${CRASH_ROOT_PATH}'/kenny*zip' +wait_for_file ${CRASH_DUMP_PATH}'/kenny*zip' diff --git a/tests/system/without_core/without_core.sh.template b/tests/system/without_core/without_core.sh.template index be8869c..5e99dba 100644 --- a/tests/system/without_core/without_core.sh.template +++ b/tests/system/without_core/without_core.sh.template @@ -10,7 +10,7 @@ fi CRASH_MANAGER_CONF=/etc/crash-manager.conf -clean_crash_root +clean_crash_dump mount -o rw,remount / backup_file ${CRASH_MANAGER_CONF} @@ -28,14 +28,14 @@ restore_file ${CRASH_MANAGER_CONF} wait_for_app crash-manager -pushd ${CRASH_ROOT_PATH} +pushd ${CRASH_DUMP_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 +if ls ${CRASH_DUMP_PATH}/kenny*/kenny*.coredump > /dev/null; then exit_with_code "FAIL: coredump file exists" 1 fi -- 2.7.4 From 68209a9b9c57e9255870f9e4628b8987e2926ff8 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Thu, 21 Feb 2019 16:36:45 +0100 Subject: [PATCH 15/16] system tests: add basic log_dump tests Change-Id: Ibcbf680ba2b4c105d66c9f0c93acf6aaababe375 --- packaging/crash-worker_system-tests.spec | 3 ++ tests/system/CMakeLists.txt | 2 ++ .../log_dump_normal/log_dump_normal.sh.template | 29 +++++++++++++++++ .../log_dump_short/log_dump_short.sh.template | 33 ++++++++++++++++++++ tests/system/run.sh.template | 3 +- tests/system/utils/minicore-utils.sh | 36 ++++++++++++++++++++++ 6 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 tests/system/log_dump_normal/log_dump_normal.sh.template create mode 100644 tests/system/log_dump_short/log_dump_short.sh.template 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} ]; -- 2.7.4 From 42e79e989e4047193e6d4bc1a46278c2adf64636 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Fri, 22 Feb 2019 15:22:42 +0100 Subject: [PATCH 16/16] util: Add make_dir There is no need to call mkdir(1) for simple cases. Change-Id: Iae4aeff8d78420f5093d946fbfe0daeb7a339b13 --- src/shared/util.c | 14 ++++++++++++++ src/shared/util.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/shared/util.c b/src/shared/util.c index 564d276..203d684 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -518,6 +518,20 @@ int fsync_path(char *const path) return ret; } +int make_dir(const char *path, const char *name, int mode) +{ + int r = -1; + + DIR *dir = opendir(path); + if (dir) { + int dfd = dirfd(dir); + r = mkdirat(dfd, name, mode); + closedir(dir); + } + + return r == 0 || (r == -1 && errno == EEXIST) ? 0 : -1; +} + static int remove_dir_internal(int fd) { DIR *dir; diff --git a/src/shared/util.h b/src/shared/util.h index c45bf3c..651a544 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -53,6 +53,8 @@ int run_command_timeout(char *path, char *args[], char *env[], int timeout); int fsync_path(char *const path); +int make_dir(const char *path, const char *name, int mode); + int remove_dir(const char *path, int del_dir); int get_exec_pid(const char *execpath); -- 2.7.4