diff --git a/src/api/commands.c b/src/api/commands.c index a8b0a37..131b811 100644 --- a/src/api/commands.c +++ b/src/api/commands.c @@ -34,6 +34,7 @@ static hash_table* command_handlers_map; static void write_jobs_command (int client_fd) { write(client_fd, "[", 1); + unsigned int len = array_size(job_queue); foreach (job_queue, i) { job_t* job = (job_t*)array_get_or_panic(job_queue, i); @@ -82,15 +83,17 @@ write_crontabs_command (int client_fd) { char* cmd_esc = escape_json_string(ce->cmd); char* s = s_fmt( - "{\"id\":\"%d\",\"cmd\":\"%s\",\"schedule\":\"%s\",\"owner\":\"%s\"," + "{\"id\":\"%d\",\"filepath\":\"%s\",\"cmd\":\"%s\",\"schedule\":\"%s\"," + "\"owner\":\"%s\"," "\"envp\":\"%s\",\"next\":\"%s\"}%s", ce->id, + entry->key, cmd_esc, ce->schedule, ct->uname, se, ts, - entries != 0 || i != len - 1 ? "," : "" + entries != 0 ? "," : "" ); write(client_fd, s, strlen(s)); diff --git a/t/integ/ipc_shpec.bash b/t/integ/ipc_shpec.bash index 10ae757..9e479e6 100644 --- a/t/integ/ipc_shpec.bash +++ b/t/integ/ipc_shpec.bash @@ -149,11 +149,12 @@ describe 'ipc API IPC_SHOW_INFO command' end_describe describe 'ipc API IPC_LIST_CRONTABS command' - n_syscrontabs="$(find /etc/cron.{hourly,daily,weekly,monthly} -type f 2>/dev/null | wc -l)" + n_syscrontabs="$(find /etc/cron.{hourly,daily,weekly,monthly} -type f 2>/dev/null | wc -l)" start_chronic sleep 5 - out="$(sock_call '{ "command" : "IPC_LIST_CRONTABS"}' 2>/dev/null | tr -d '\0')" + out="$(sock_call '{ "command" : "IPC_LIST_CRONTABS"}')" + echo ">>>>> $(echo "$out" | wc -l)" it 'lists all crontabs' assert equal $(jq 'length' <<< "$out") "$((n_syscrontabs + 3))" @@ -177,7 +178,8 @@ describe 'ipc API IPC_LIST_JOBS command' echo 'sleeping for 60 seconds...' sleep 60 - out="$(sock_call '{ "command" : "IPC_LIST_JOBS"}' 2>/dev/null | tr -d '\0')" + out="$(sock_call '{ "command" : "IPC_LIST_JOBS"}')" + echo ">>> $out" it 'lists all jobs' assert gt "$(jq 'length' <<< "$out")" 0 diff --git a/t/integ/utils/run.bash b/t/integ/utils/run.bash index d7303d1..ae7a349 100755 --- a/t/integ/utils/run.bash +++ b/t/integ/utils/run.bash @@ -5,12 +5,12 @@ TESTING_DIR=t/integ UTILS_F=run_utils.bash declare -a SKIP_FILES=( - # 'daemon_shpec.bash' + 'daemon_shpec.bash' # 'ipc_shpec.bash' - # 'peripherals_shpec.bash' - # 'root_shpec.bash' - # 'sig_shpec.bash' - # 'user_shpec.bash' + 'peripherals_shpec.bash' + 'root_shpec.bash' + 'sig_shpec.bash' + 'user_shpec.bash' ) run_test () {