Skip to content

Commit

Permalink
fixed getopt problem on Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorier committed Jul 3, 2023
1 parent 38f4c8d commit 517eeac
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions tests/margo-test-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ int main(int argc, char** argv)
static void usage(int argc, char** argv)
{
(void)argc;
fprintf(stderr, "Usage: %s listen_address [-s] [-f filename]\n", argv[0]);
fprintf(stderr, "Usage: %s -a listen_address [-s] [-f filename]\n", argv[0]);
fprintf(
stderr,
" listen_address is the address or protocol for the server to use\n");
fprintf(stderr, " [-a address] address to pass to margo_init\n");
fprintf(stderr, " [-s] for single pool mode\n");
fprintf(stderr, " [-f filename] to write the server address to a file\n");
fprintf(stderr, " [-p pool kind] to specify kind of ABT pools to use\n");
Expand All @@ -147,8 +148,11 @@ static void parse_args(int argc, char** argv, struct options* opts)

memset(opts, 0, sizeof(*opts));

while ((opt = getopt(argc, argv, "f:sp:")) != -1) {
while ((opt = getopt(argc, argv, "a:f:sp:")) != -1) {
switch (opt) {
case 'a':
opts->listen_addr = strdup(optarg);
break;
case 's':
opts->single_pool_mode = 1;
break;
Expand All @@ -164,14 +168,12 @@ static void parse_args(int argc, char** argv, struct options* opts)
}
}

if (optind >= argc) {
if (optind > argc) {
usage(argc, argv);
exit(EXIT_FAILURE);
}

if (!opts->pool_kind) opts->pool_kind = strdup("fifo_wait");

opts->listen_addr = strdup(argv[optind]);

return;
}
2 changes: 1 addition & 1 deletion tests/test-util-ded-pool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function test_start_servers ()
for i in `seq 1 $nservers`
do
hostfile=`mktemp`
$TIMEOUT --signal=9 ${maxtime} tests/margo-test-server na+sm:// -f $hostfile -p $poolkind &
$TIMEOUT --signal=9 ${maxtime} tests/margo-test-server -a na+sm:// -f $hostfile -p $poolkind &
if [ $? -ne 0 ]; then
# TODO: this doesn't actually work; can't check return code of
# something executing in background. We have to rely on the
Expand Down
2 changes: 1 addition & 1 deletion tests/test-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function test_start_servers ()
for i in `seq 1 $nservers`
do
hostfile=`mktemp`
$TIMEOUT --signal=9 ${maxtime} tests/margo-test-server na+sm:// -s -f $hostfile -p $poolkind &
$TIMEOUT --signal=9 ${maxtime} tests/margo-test-server -a na+sm:// -s -f $hostfile -p $poolkind &
if [ $? -ne 0 ]; then
# TODO: this doesn't actually work; can't check return code of
# something executing in background. We have to rely on the
Expand Down
2 changes: 1 addition & 1 deletion tests/timeout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fi

source $srcdir/tests/test-util.sh

TMPOUT=$($MKTEMP --tmpdir test-XXXXXX)
TMPOUT=$($MKTEMP test-XXXXXX)

# start 1 server with 2 second wait, 8s timeout
test_start_servers 1 2 10
Expand Down

0 comments on commit 517eeac

Please sign in to comment.