diff --git a/src/margo-init.c b/src/margo-init.c index 0ae7f219..2b1d7ace 100644 --- a/src/margo-init.c +++ b/src/margo-init.c @@ -1381,7 +1381,9 @@ static int create_xstream_from_config(struct json_object* es_config, // get/set cpubind if (es_cpubind == -1) { ret = ABT_xstream_get_cpubind(*es, &es_cpubind); - if (ret != ABT_SUCCESS) { + if (ret == ABT_ERR_FEATURE_NA) { + /* feature not supported in this Argobots build; skip */ + } else if (ret != ABT_SUCCESS) { MARGO_WARNING( 0, "ABT_xstream_get_cpubind failed to get cpubind (ret = %d)", ret); @@ -1403,7 +1405,9 @@ static int create_xstream_from_config(struct json_object* es_config, // get affinity int num_cpus; ret = ABT_xstream_get_affinity(*es, 0, NULL, &num_cpus); - if (ret != ABT_SUCCESS) { + if (ret == ABT_ERR_FEATURE_NA) { + /* feature not supported in this Argobots build; skip */ + } else if (ret != ABT_SUCCESS) { MARGO_WARNING( 0, "ABT_xstream_get_affinity failed to get affinity (ret = %d)", ret); diff --git a/src/margo-logging.c b/src/margo-logging.c index fcda9616..d5354904 100644 --- a/src/margo-logging.c +++ b/src/margo-logging.c @@ -7,7 +7,7 @@ #include "margo-instance.h" #include -static margo_log_level global_log_level = MARGO_LOG_ERROR; +static margo_log_level global_log_level = MARGO_LOG_WARNING; static void _margo_log_trace(void* uargs, const char* str) { diff --git a/tests/unit-tests/margo-logging.c b/tests/unit-tests/margo-logging.c index c3749267..a49a06a9 100644 --- a/tests/unit-tests/margo-logging.c +++ b/tests/unit-tests/margo-logging.c @@ -3,6 +3,8 @@ #include "helper-server.h" #include "munit/munit.h" +static struct margo_logger test_logger = {0}; + struct test_context { margo_instance_id mid; char* log_buffer; @@ -30,17 +32,11 @@ static void* test_context_setup(const MunitParameter params[], void* user_data) (void)params; (void)user_data; int ret; - struct margo_logger test_logger; struct test_context* ctx = calloc(1, sizeof(*ctx)); ctx->log_buffer = calloc(102400, 1); ctx->log_buffer_size = 102400; - char* protocol = "na+sm"; - - ctx->mid = margo_init(protocol, MARGO_CLIENT_MODE, 0, 0); - munit_assert_not_null(ctx->mid); - /* set up custom logger to make it easier to validate output */ test_logger.uargs = ctx; test_logger.trace = test_log_fn; @@ -49,11 +45,17 @@ static void* test_context_setup(const MunitParameter params[], void* user_data) test_logger.warning = test_log_fn; test_logger.error = test_log_fn; test_logger.critical = test_log_fn; + ret = margo_set_global_logger(&test_logger); + munit_assert_int(ret, ==, 0); + + char* protocol = "na+sm"; + ctx->mid = margo_init(protocol, MARGO_CLIENT_MODE, 0, 0); + munit_assert_not_null(ctx->mid); + + /* associate the same logger with the instance as well */ ret = margo_set_logger(ctx->mid, &test_logger); munit_assert_int(ret, ==, 0); - ret = margo_set_global_logger(&test_logger); - munit_assert_int(ret, ==, 0); return ctx; } @@ -68,29 +70,71 @@ static void test_context_tear_down(void* data) free(ctx); } +static MunitResult init_quiet_log(const MunitParameter params[], void* data) +{ + struct test_context* ctx = (struct test_context*)data; + char* protocol = "na+sm"; + int ret; + + /* finalize and re-initialize margo and make sure that no log messages + * were emitted at the default level + */ + margo_finalize(ctx->mid); + + ctx->mid = margo_init(protocol, MARGO_CLIENT_MODE, 0, 0); + munit_assert_not_null(ctx->mid); + + /* associate logger with the new instance */ + ret = margo_set_logger(ctx->mid, &test_logger); + munit_assert_int(ret, ==, 0); + + /* check to see if any messages were emitted */ + if(ctx->log_buffer_pos != 0) + fprintf(stderr, "Test failure; spurious log messages: %s\n", ctx->log_buffer); + munit_assert_int(ctx->log_buffer_pos, ==, 0); + + return MUNIT_OK; +} + +static char* mid_params[] = {"mid", "NULL", NULL}; +static MunitParameterEnum get_mid[] = {{"mid", mid_params}, {NULL, NULL}}; + static MunitResult default_log_level(const MunitParameter params[], void* data) { struct test_context* ctx = (struct test_context*)data; + margo_instance_id mid = NULL; + const char* mid_param; + + /* test both mid-specific logger and global logger. Both should have + * same default level. + */ + mid_param = munit_parameters_get(params, "mid"); + if(strcmp("mid", mid_param) == 0) + mid = ctx->mid; + else if(strcmp("NULL", mid_param) == 0) + mid = NULL; + else + munit_assert(0); /* Expected result: default log level will record messages of level * warning and higher. */ - margo_trace(ctx->mid, "trace "); + margo_trace(mid, "trace "); munit_assert_null(strstr(ctx->log_buffer, "trace")); - margo_debug(ctx->mid, "debug "); + margo_debug(mid, "debug "); munit_assert_null(strstr(ctx->log_buffer, "debug")); - margo_info(ctx->mid, "info "); + margo_info(mid, "info "); munit_assert_null(strstr(ctx->log_buffer, "info")); - margo_warning(ctx->mid, "warning "); + margo_warning(mid, "warning "); munit_assert_not_null(strstr(ctx->log_buffer, "warning")); - margo_error(ctx->mid, "error "); + margo_error(mid, "error "); munit_assert_not_null(strstr(ctx->log_buffer, "error")); - margo_critical(ctx->mid, "critical "); + margo_critical(mid, "critical "); munit_assert_not_null(strstr(ctx->log_buffer, "critical")); return MUNIT_OK; @@ -160,9 +204,11 @@ static MunitResult vary_log_level(const MunitParameter params[], void* data) static MunitTest tests[] = {{"/default_log_level", default_log_level, test_context_setup, - test_context_tear_down, MUNIT_TEST_OPTION_NONE, NULL}, + test_context_tear_down, MUNIT_TEST_OPTION_NONE, get_mid}, {"/vary_log_level", vary_log_level, test_context_setup, test_context_tear_down, MUNIT_TEST_OPTION_NONE, get_log_level}, + {"/init_quiet_log", init_quiet_log, test_context_setup, + test_context_tear_down, MUNIT_TEST_OPTION_NONE, NULL}, {NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL}}; static const MunitSuite test_suite