GitLab maintenance scheduled for Today, 2019-12-05, from 17:00 to 18:00 CT - Services will be unavailable during this time.

Commit 2b89b25f authored by Jonathan Jenkins's avatar Jonathan Jenkins

better config error handling

parent 507c2c42
......@@ -11,6 +11,7 @@
#include <errno.h>
#include <libgen.h>
#include "codes/configuration.h"
#include <ross.h>
/*
* Global to hold configuration in memory
......@@ -61,7 +62,7 @@ int configuration_load (const char *filepath,
(*handle)->config_dir = strdup(dirname(tmp_path));
assert((*handle)->config_dir);
configuration_get_lpgroups(handle, "LPGROUPS", &lpconf);
rc = configuration_get_lpgroups(handle, "LPGROUPS", &lpconf);
finalize:
if (fh != MPI_FILE_NULL) MPI_File_close(&fh);
......@@ -339,9 +340,22 @@ int configuration_get_lpgroups (ConfigHandle *handle,
memset (lpgroups, 0, sizeof(*lpgroups));
cf_openSection(*handle, ROOT_SECTION, section_name, &sh);
int ret = cf_openSection(*handle, ROOT_SECTION, section_name, &sh);
if (ret == -1)
return -1;
cf_listSection(*handle, sh, se, &se_count);
#define CHECKED_STRTOL(_val, _field, _data) \
do{ \
errno = 0; \
long int _rd = strtol(_data, NULL, 10); \
if (_rd <= 0 || errno) \
tw_error(TW_LOC, "bad value (expected positive integer) for " \
"\"%s\": %s\n", _field, _data); \
else \
_val = _rd; \
}while(0);
for (i = 0; i < se_count; i++)
{
//printf("section: %s type: %d\n", se[i].name, se[i].type);
......@@ -362,7 +376,8 @@ int configuration_get_lpgroups (ConfigHandle *handle,
//printf("key: %s value: %s\n", subse[j].name, data);
if (strcmp("repetitions", subse[j].name) == 0)
{
lpgroups->lpgroups[i].repetitions = atoi(data);
CHECKED_STRTOL(lpgroups->lpgroups[i].repetitions,
"repetitions", data);
//printf("\n Repetitions: %ld ", lpgroups->lpgroups[i].repetitions);
}
else
......@@ -384,7 +399,8 @@ int configuration_get_lpgroups (ConfigHandle *handle,
}
// add to anno map
check_add_lp_type_anno(nm, anno, lpgroups);
lpgroups->lpgroups[i].lptypes[lpt].count = atoi(data);
CHECKED_STRTOL(lpgroups->lpgroups[i].lptypes[lpt].count,
nm, data);
lpgroups->lpgroups[i].lptypes_count++;
lpt++;
}
......
......@@ -128,15 +128,11 @@ void parse_args(int argc, char **argv, char **conf_path, char **test_dir)
int load_workload(char *conf_path, int rank)
{
config_lpgroups_t paramconf;
char workload_type[MAX_NAME_LENGTH_WKLD];
/* load the config file across all ranks */
configuration_load(conf_path, MPI_COMM_WORLD, &config);
/* get the PARAMS group out of the config file */
configuration_get_lpgroups(&config, "PARAMS", &paramconf);
/* get the workload type out of PARAMS */
configuration_get_value(&config, "PARAMS", "workload_type",
NULL, workload_type, MAX_NAME_LENGTH_WKLD);
......
......@@ -35,12 +35,9 @@ static int num_clients_per_lp = -1;
void workload_set_params()
{
config_lpgroups_t paramconf;
char io_kernel_meta_path[MAX_NAME_LENGTH_WKLD];
char bgp_config_file[MAX_NAME_LENGTH_WKLD];
configuration_get_lpgroups(&config, "PARAMS", &paramconf);
configuration_get_value(&config, "PARAMS", "workload_type", NULL, workload_type, MAX_NAME_LENGTH_WKLD);
if(strcmp(workload_type,"bgp_io_workload") == 0)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment