Skip to content

Commit

Permalink
Merge 36c1ce1 into f172cc3
Browse files Browse the repository at this point in the history
  • Loading branch information
chu11 committed Jan 7, 2017
2 parents f172cc3 + 36c1ce1 commit 215da3a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/broker/broker.c
Expand Up @@ -262,7 +262,7 @@ int main (int argc, char *argv[])
int security_clr = 0;
int security_set = 0;
int e;

char *endptr;

memset (&ctx, 0, sizeof (ctx));
log_init (argv[0]);
Expand Down Expand Up @@ -323,7 +323,10 @@ int main (int argc, char *argv[])
log_err_exit ("setting conf.module_path attribute");
break;
case 'k': /* --k-ary k */
errno = 0;
ctx.tbon.k = strtoul (optarg, NULL, 10);
if (errno || *endptr != '\0')
log_err_exit ("k-ary '%s'", optarg);
if (ctx.tbon.k < 1)
usage ();
break;
Expand All @@ -332,7 +335,12 @@ int main (int argc, char *argv[])
log_err_exit ("heartrate `%s'", optarg);
break;
case 'g': /* --shutdown-grace SECS */
ctx.shutdown_grace = strtod (optarg, NULL);
errno = 0;
ctx.shutdown_grace = strtod (optarg, &endptr);
if (errno || *endptr != '\0')
log_err_exit ("shutdown-grace '%s'", optarg);
if (ctx.shutdown_grace < 0)
usage ();
break;
case 'E': /* --enable-epgm */
ctx.enable_epgm = true;
Expand Down Expand Up @@ -594,7 +602,7 @@ int main (int argc, char *argv[])
log_err_exit ("runlevel_set_rc 1");
if (runlevel_set_rc (ctx.runlevel, 2, rc2, rc2_len, uri) < 0)
log_err_exit ("runlevel_set_rc 2");
if (runlevel_set_rc (ctx.runlevel, 3, rc3, rc1 ? strlen (rc3) + 1 : 0, uri) < 0)
if (runlevel_set_rc (ctx.runlevel, 3, rc3, rc3 ? strlen (rc3) + 1 : 0, uri) < 0)
log_err_exit ("runlevel_set_rc 3");
}

Expand Down
12 changes: 10 additions & 2 deletions src/cmd/flux-comms-stats.c
Expand Up @@ -29,6 +29,7 @@
#include <getopt.h>
#include <libgen.h>
#include <stdbool.h>
#include <errno.h>
#include <flux/core.h>

#include "src/common/libutil/xzmalloc.h"
Expand Down Expand Up @@ -75,6 +76,7 @@ int main (int argc, char *argv[])
bool Ropt = false;
double scale = 1.0;
json_type type = json_type_object;
char *endptr;

log_init ("flux-stats");

Expand All @@ -84,7 +86,10 @@ int main (int argc, char *argv[])
usage ();
break;
case 'r': /* --rank */
nodeid = strtoul (optarg, NULL, 10);
errno = 0;
nodeid = strtoul (optarg, &endptr, 10);
if (errno || *endptr != '\0')
usage();
break;
case 'c': /* --clear */
copt = true;
Expand All @@ -99,7 +104,10 @@ int main (int argc, char *argv[])
objname = optarg;
break;
case 's': /* --scale N */
scale = strtod (optarg, NULL);
errno = 0;
scale = strtod (optarg, &endptr);
if (errno || *endptr != '\0')
usage();
break;
case 't': /* --type TYPE */
if (!strcasecmp (optarg, "int"))
Expand Down
7 changes: 5 additions & 2 deletions t/t2006-joblog.t
Expand Up @@ -14,17 +14,20 @@ test_expect_success 'created persistdir' '
PERSISTDIR=`mktemp -d`
'

# Test can be a tad "racey" at times if grace period is too low, up to
# 5 seconds to ensure joblog can be generated properly.

test_expect_success 'joblog exists, non-empty if job(s) run' '
rm -rf $PERSISTDIR/* &&
flux start -o,--setattr=persist-directory=$PERSISTDIR \
flux start -o,--shutdown-grace=5 -o,--setattr=persist-directory=$PERSISTDIR \
flux wreckrun /bin/true &&
test -f $PERSISTDIR/joblog &&
test -s $PERSISTDIR/joblog
'

test_expect_success 'joblog exists, empty if no jobs run' '
rm -rf $PERSISTDIR/* &&
flux start -o,--setattr=persist-directory=$PERSISTDIR \
flux start -o,--shutdown-grace=5 -o,--setattr=persist-directory=$PERSISTDIR \
/bin/true &&
test -f $PERSISTDIR/joblog &&
! test -s $PERSISTDIR/joblog
Expand Down

0 comments on commit 215da3a

Please sign in to comment.