Skip to content

Commit

Permalink
Merge pull request #1636 from chu11/misccleanup13
Browse files Browse the repository at this point in the history
Misc cleanup & fixes
  • Loading branch information
grondo committed Aug 31, 2018
2 parents bf5af45 + c2ddf7f commit 29c0c6c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/broker/broker.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ typedef struct {

char *init_shell_cmd;
size_t init_shell_cmd_len;
struct subprocess *init_shell;
} broker_ctx_t;

static int broker_event_sendmsg (broker_ctx_t *ctx, const flux_msg_t *msg);
Expand Down
5 changes: 2 additions & 3 deletions src/broker/runlevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ static int subprocess_io_cb (struct subprocess *p, const char *json_str)
char *s = NULL, *argz = NULL, *line = NULL;
size_t argz_len;

r = subprocess_get_context (p, "runlevel_t");
r = subprocess_get_context (p, "runlevel");
assert (r != NULL);
assert (r->level == 1|| r->level == 3);

if (!r->io_cb)
goto done;
Expand Down Expand Up @@ -385,8 +386,6 @@ int runlevel_set_rc (runlevel_t *r, int level, const char *cmd_argz,
goto error;
if (subprocess_set_io_callback (p, subprocess_io_cb) < 0)
goto error;
if (subprocess_set_context (p, "runlevel_t", r) < 0)
goto error;
}
r->rc[level].subprocess = p;
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/flux-start.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ void add_args_list (char **argz, size_t *argz_len, optparse_t *opt, const char *
optparse_getopt_iterator_reset (opt, name);
while ((arg = optparse_getopt_next (opt, name)))
if (argz_add (argz, argz_len, arg) != 0)
log_err_exit ("subprocess_argv_append");
log_err_exit ("argz_add");
}

char *create_scratch_dir (const char *session_id)
Expand Down
18 changes: 9 additions & 9 deletions src/common/libflux/test/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ void basic (void)
"flux_buffer_peek with specific length works");

ok (!memcmp (ptr, "fo", 2),
"flux_buffer_peek returns exepected data");
"flux_buffer_peek returns expected data");

ok ((ptr = flux_buffer_peek (fb, -1, &len)) != NULL
&& len == 3,
"flux_buffer_peek with length -1 works");

ok (!memcmp (ptr, "foo", 3),
"flux_buffer_peek returns exepected data");
"flux_buffer_peek returns expected data");

ok (flux_buffer_bytes (fb) == 3,
"flux_buffer_bytes returns unchanged length after peek");
Expand Down Expand Up @@ -100,7 +100,7 @@ void basic (void)
"flux_buffer_read with specific length works");

ok (!memcmp (ptr, "fo", 2),
"flux_buffer_read returns exepected data");
"flux_buffer_read returns expected data");

ok (flux_buffer_bytes (fb) == 1,
"flux_buffer_bytes returns new length after read");
Expand All @@ -110,7 +110,7 @@ void basic (void)
"flux_buffer_peek with length -1 works");

ok (!memcmp (ptr, "o", 1),
"flux_buffer_peek returns exepected data");
"flux_buffer_peek returns expected data");

ok (flux_buffer_bytes (fb) == 0,
"flux_buffer_bytes returns 0 with all bytes read");
Expand Down Expand Up @@ -140,7 +140,7 @@ void basic (void)
"flux_buffer_peek_line works");

ok (!memcmp (ptr, "foo\n", 4),
"flux_buffer_peek_line returns exepected data");
"flux_buffer_peek_line returns expected data");

ok (flux_buffer_bytes (fb) == 4,
"flux_buffer_bytes returns unchanged length after peek_line");
Expand Down Expand Up @@ -176,10 +176,10 @@ void basic (void)

ok ((ptr = flux_buffer_read_line (fb, &len)) != NULL
&& len == 4,
"flux_buffer_peek_line works");
"flux_buffer_read_line works");

ok (!memcmp (ptr, "foo\n", 4),
"flux_buffer_peek_line returns exepected data");
"flux_buffer_read_line returns expected data");

ok (flux_buffer_bytes (fb) == 0,
"flux_buffer_bytes returns 0 after read_line");
Expand Down Expand Up @@ -268,7 +268,7 @@ void basic (void)
"flux_buffer_read with specific length works");

ok (!memcmp (ptr, "fo", 2),
"flux_buffer_read returns exepected data");
"flux_buffer_read returns expected data");

ok (flux_buffer_bytes (fb) == 1,
"flux_buffer_bytes returns new length after read");
Expand All @@ -278,7 +278,7 @@ void basic (void)
"flux_buffer_peek with length -1 works");

ok (!memcmp (ptr, "o", 1),
"flux_buffer_peek returns exepected data");
"flux_buffer_peek returns expected data");

ok (flux_buffer_bytes (fb) == 0,
"flux_buffer_bytes returns 0 with all bytes read");
Expand Down
4 changes: 4 additions & 0 deletions src/modules/cron/cron.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ static void cron_entry_completion_handler (flux_t *h, cron_task_t *t, void *arg)
flux_log_error (h, "cron-%ju: failed to run %s", e->id, e->command);
cron_entry_failure (e);
}
else if (strcmp (cron_task_state (t), "Rexec Failure") == 0) {
flux_log_error (h, "cron-%ju: failure running %s", e->id, e->command);
cron_entry_failure (e);
}
else if (cron_task_status (t) != 0) {
flux_log (h, LOG_ERR, "cron-%ju: \"%s\": Failed: %s",
e->id, e->command, cron_task_state (t));
Expand Down
2 changes: 1 addition & 1 deletion src/modules/cron/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct cron_entry {
char * command; /* Command to execute */
char * cwd; /* Change working directory */
json_t * env; /* Optional environment for cmd,
(encoded as json array) */
(encoded as json object) */

int repeat; /* Total number of times to run */

Expand Down
19 changes: 18 additions & 1 deletion t/t0015-cron.t
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ test_expect_success 'cron interval --after= works' '
flux cron dump ${id} &&
cron_entry_check ${id} task.1.state Exited
'

wait_cron_delete () {
i=0
flux cron dump ${id}
while [ $? -eq 0 ] && [ $i -lt 50 ]
do
sleep 0.1
i=$((i + 1))
flux cron dump ${id}
done
if [ "$i" -eq "50" ]
then
return 1
fi
return 0;
}

test_expect_success 'cron delete leaves running task - --kill works' '
id=$(flux_cron interval --after=.01s 0 sleep 100) &&
sleep .1 &&
Expand All @@ -64,7 +81,7 @@ test_expect_success 'cron delete leaves running task - --kill works' '
grep "sleep still running" delete.${id}.out &&
cron_entry_check ${id} task.1.state Running &&
flux cron delete --kill ${id} &&
test_expect_code 1 flux cron dump ${id}
wait_cron_delete
'
test_expect_success 'repeat count works' '
id=$(flux_cron interval -c1 .01s echo hi) &&
Expand Down

0 comments on commit 29c0c6c

Please sign in to comment.