char *log_path;
char appid[APPID_MAX];
char pkgid[PKGNAME_MAX];
+ char *output_path;
bool livedump;
bool kill;
bool print_result_path;
int tmp_len;
const char *crash_subdir = cinfo->livedump ? LIVE_PATH_SUBDIR : CRASH_PATH_SUBDIR;
+ if (cinfo->output_path) {
+ free(config.crash_root_path);
+ config.crash_root_path = strdup(cinfo->output_path);
+ if (!config.crash_root_path) {
+ _E("strdup() error: %m");
+ return 0;
+ }
+ }
+
tmp_len = strlen(config.crash_root_path) + strlen(crash_subdir);
crash_dump_path = (char*)malloc(tmp_len + 1);
if (crash_dump_path == NULL) {
" -l --live get coredump of running process\n"
" -k --kill-after-dump kill after dump (only with --live option)\n"
" -r --print print report path to stdout\n"
+ " -o --output output directory\n"
" -h --help this message\n"
"\n"
"for --live option only --pid is required\n"
{"live", no_argument, NULL, 'l'},
{"kill-after-dump", no_argument, NULL, 'k'},
{"print", no_argument, NULL, 'r'},
+ {"output", required_argument, NULL, 'o'},
{"help", no_argument, NULL, 'h'},
};
- while ((opt = getopt_long(argc, argv, "p:u:g:i:s:t:hlkr", long_options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "p:u:g:i:s:t:hlkro:", long_options, NULL)) != -1) {
switch (opt) {
case 'p':
GET_NUMBER(pid)
case 'r':
cinfo->print_result_path = true;
break;
+ case 'o':
+ cinfo->output_path = optarg;
+ _D("output path: %s\n", optarg);
+ break;
case 'h':
default:
print_help(argv[0]);
cinfo->print_result_path = false;
cinfo->tid_info = -1;
cinfo->time_info = 0;
+ cinfo->output_path = NULL;
}
static bool run(struct crash_info *cinfo)
--- /dev/null
+#!/bin/bash
+
+# Test --output parameter
+
+if [ -z "${CRASH_WORKER_SYSTEM_TESTS}" ]; then
+ CRASH_WORKER_SYSTEM_TESTS="@CRASH_SYSTEM_TESTS_PATH@"
+fi
+
+. ${CRASH_WORKER_SYSTEM_TESTS}/utils/minicore-utils.sh
+
+OUTPUT=/tmp/output_dir/
+mkdir -p ${OUTPUT}
+
+save_core_pattern
+trap restore_core_pattern 0
+
+echo "|/usr/bin/crash-manager -p %p -u %u -g %g -s %s -t %t --output ${OUTPUT}" > /proc/sys/kernel/core_pattern
+
+{
+ ${CRASH_WORKER_SYSTEM_TESTS}/utils/kenny 10 &
+ sleep 1
+ killall -6 kenny
+} 1> /dev/null 2>&1
+
+sleep 2
+
+wait_for_file ${OUTPUT}/dump/*zip
+rm -rf ${OUTPUT}
+
+exit_ok
+