Requires: /bin/bash
Requires: /usr/bin/unzip
Requires: /usr/bin/mcookie
+Requires: /usr/bin/json-glib-validate
Requires: %{_sbindir}/minicoredumper
Requires: %{name}-system-tests-debuginfo = %{version}-%{release}
Requires: %{name}-support-livecoredump = %{version}-%{release}
%manifest %{name}.manifest
%{_bindir}/crash-worker-system-tests-run
+%{_libexecdir}/crash-worker/system-tests/bugreport_crash_info_json/bugreport_crash_info_json.sh
%{_libexecdir}/crash-worker/system-tests/check_minicore_mem/check_minicore_mem.sh
%{_libexecdir}/crash-worker/system-tests/check_minicore_mem/cp.sh
%{_libexecdir}/crash-worker/system-tests/clean_temp/clean_temp.sh
#include "shared/log.h"
#include "shared/util.h"
-enum BUGREPORT_REPORT_TYPE { BR_UNKNOWN, BR_BUGREPORT, BR_CRASHINFO };
+enum BUGREPORT_REPORT_TYPE { BR_UNKNOWN, BR_BUGREPORT, BR_CRASHINFO, BR_CRASHINFO_JSON };
struct report_file {
char *file_name;
return result;
}
-static bool write_crash_info(int fd, long time_from, long time_to)
+static bool write_crash_info(int fd, long time_from, long time_to, bool as_json)
{
bool result = true;
size_t list_count = 0;
return false;
}
- for (int i = 0; i < list_count; i++) {
- int nfd = diagnostics_report_get_file(list[i].file_path, INFO_FILE);
+
+ const enum diagnostics_entry entry_type = as_json ? INFO_JSON : INFO_FILE;
+ for (int i = 0, p = 0; i < list_count; i++) {
+ int nfd = diagnostics_report_get_file(list[i].file_path, entry_type);
if (nfd <= 0) {
_I("No INFO_FILE in %s file", list[i].file_path);
dprintf(nfd, "No INFO_FILE in %s\n", list[i].file_path);
continue;
}
- if (dprintf(fd, "%sBegin crash-info <%s>\n", (i > 0) ? "\n" : "", list[i].file_path) == -1) {
+ int res = 0;
+ if (as_json)
+ res = dprintf(fd, "%c\n", (p == 0) ? '[' : ',');
+ else
+ res = dprintf(fd, "%sBegin crash-info <%s>\n", (i > 0) ? "\n" : "", list[i].file_path);
+
+ if (res == -1) {
_E("Write error: %m");
result = false;
goto out;
result = false;
goto out;
}
+ p++;
close(nfd);
- if (dprintf(fd, "End crash-info <%s>\n", list[i].file_path) == -1) {
+ if (as_json) {
+ if (i == list_count-1)
+ res = dprintf(fd, "]\n");
+ } else {
+ res = dprintf(fd, "End crash-info <%s>\n", list[i].file_path);
+ }
+ if (res == -1) {
_E("Write error: %m");
result = false;
goto out;
dco->from_set = false;
dco->to_set = false;
- enum PARAM_NAME { PN_TYPE = 1, PN_LAST, PN_TO, PN_FROM};
+ enum PARAM_NAME { PN_TYPE = 1, PN_LAST, PN_TO, PN_FROM };
struct option long_options[] = {
{"type", required_argument, NULL, PN_TYPE},
dco->report_type = BR_BUGREPORT;
} else if (strcmp(optarg, "crash-info") == 0) {
dco->report_type = BR_CRASHINFO;
+ } else if (strcmp(optarg, "crash-info-json") == 0) {
+ dco->report_type = BR_CRASHINFO_JSON;
} else {
_E("Incorrect report type: %s", optarg);
dprintf(out_fd, "Incorrect report type: %s\n", optarg);
switch(dco.report_type) {
case BR_CRASHINFO:
- write_crash_info(fd, dco.from, dco.to);
+ write_crash_info(fd, dco.from, dco.to, false);
+ break;
+ case BR_CRASHINFO_JSON:
+ write_crash_info(fd, dco.from, dco.to, true);
break;
case BR_BUGREPORT:
write_bugreport(fd, dco.from, dco.to);
--- /dev/null
+#!/bin/bash
+
+# crash-info-json format validation
+
+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_dump
+
+TMP=$(mktemp /tmp/crash-info-test.XXXXXX)
+
+cleanup()
+{
+ rm -f "${TMP}"
+}
+
+trap cleanup 0
+
+for i in {1..3}; do
+
+ ( ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny &
+ pid=$!
+ sleep 2
+ kill -6 $pid ) &
+
+ sleep 3
+ wait_for_app crash-manager
+
+ dumpsys org.tizen.bugreport-service -- --type=crash-info-json > "${TMP}"
+
+ if [ $(wc -l "${TMP}" | cut -f1 -d' ') -lt 10 ]; then
+ fail "Output file is too short"
+ fi
+
+ if ! json-glib-validate "${TMP}"; then
+ fail "crash-info-json format error"
+ fi
+
+ if ! egrep "native_hash" "${TMP}"; then
+ fail "No native_hash in output file"
+ fi
+
+done
+
+exit_ok