*
* @{
*/
-XBT_PUBLIC(void) xbt_cfg_register(xbt_cfg_t * cfg, const char *name, const char *description,
- e_xbt_cfgelm_type_t type, int min, xbt_cfg_cb_t cb_set);
XBT_PUBLIC(void) xbt_cfg_register_double (const char *name, const char *desc, double default_val, xbt_cfg_cb_t cb_set);
XBT_PUBLIC(void) xbt_cfg_register_int (const char *name, const char *desc, int default_val, xbt_cfg_cb_t cb_set);
XBT_PUBLIC(void) xbt_cfg_register_string (const char *name, const char *desc, const char*default_val,xbt_cfg_cb_t cb_set);
XBT_PUBLIC(void) xbt_cfg_register_alias(const char *newname, const char *oldname);
XBT_PUBLIC(void) xbt_cfg_register_str(xbt_cfg_t * cfg, const char *entry);
-XBT_PUBLIC(void) xbt_cfg_aliases(xbt_cfg_t cfg);
-XBT_PUBLIC(void) xbt_cfg_help(xbt_cfg_t cfg);
-XBT_PUBLIC(void) xbt_cfg_check(void);
+XBT_PUBLIC(void) xbt_cfg_aliases(void);
+XBT_PUBLIC(void) xbt_cfg_help(void);
XBT_PUBLIC(e_xbt_cfgelm_type_t) xbt_cfg_get_type(xbt_cfg_t cfg, const char *name);
/* @} */
/** @defgroup XBT_cfg_get Getting the stored values
SG_BEGIN_DECL()
XBT_PUBLIC(void) xbt_init(int *argc, char **argv);
-XBT_PUBLIC(void) xbt_exit(void);
SG_END_DECL()
shall_exit = 1;
} else if (!strcmp(argv[i], "--cfg-help") || !strcmp(argv[i], "--help")) {
printf("Description of the configuration accepted by this simulator:\n");
- xbt_cfg_help(simgrid_config);
+ xbt_cfg_help();
printf(
"\n"
"Each of these configurations can be used by adding\n"
shall_exit = 1;
} else if (!strcmp(argv[i], "--help-aliases")) {
printf("Here is a list of all deprecated option names, with their replacement.\n");
- xbt_cfg_aliases(simgrid_config);
+ xbt_cfg_aliases();
printf("Please consider using the recent names\n");
shall_exit = 1;
} else if (!strcmp(argv[i], "--help-models")) {
xbt_assert(_sg_cfg_init_status < 2, "Cannot load a plugin after the initialization");
char *val = xbt_cfg_get_string(name);
+ if (val==nullptr)
+ return;
+
if (!strcmp(val, "help")) {
model_help("plugin", surf_plugin_description);
sg_cfg_exit_early();
}
#if HAVE_SMPI
-/* callback of the mpi collectives */
-static void _sg_cfg_cb__coll(const char *category,
+/* callback of the mpi collectives: simply check that this is a valid name. It will be picked up in smpi_global.cpp */
+static void _check_coll(const char *category,
s_mpi_coll_description_t * table,
- const char *name, int pos)
+ const char *name)
{
- char *val;
-
- xbt_assert(_sg_cfg_init_status < 2,
- "Cannot change the model after the initialization");
+ xbt_assert(_sg_cfg_init_status < 2, "Cannot change the collective algorithm after the initialization");
- val = xbt_cfg_get_string(name);
+ char *val = xbt_cfg_get_string(name);
- if (!strcmp(val, "help")) {
+ if (val && !strcmp(val, "help")) {
coll_help(category, table);
sg_cfg_exit_early();
}
- /* New Module missing */
find_coll_description(table, val, category);
}
-static void _sg_cfg_cb__coll_gather(const char *name, int pos){
- _sg_cfg_cb__coll("gather", mpi_coll_gather_description, name, pos);
+static void _check_coll_gather(const char *name, int pos){
+ _check_coll("gather", mpi_coll_gather_description, name);
}
-static void _sg_cfg_cb__coll_allgather(const char *name, int pos){
- _sg_cfg_cb__coll("allgather", mpi_coll_allgather_description, name, pos);
+static void _check_coll_allgather(const char *name, int pos){
+ _check_coll("allgather", mpi_coll_allgather_description, name);
}
-static void _sg_cfg_cb__coll_allgatherv(const char *name, int pos){
- _sg_cfg_cb__coll("allgatherv", mpi_coll_allgatherv_description, name, pos);
+static void _check_coll_allgatherv(const char *name, int pos){
+ _check_coll("allgatherv", mpi_coll_allgatherv_description, name);
}
-static void _sg_cfg_cb__coll_allreduce(const char *name, int pos)
+static void _check_coll_allreduce(const char *name, int pos)
{
- _sg_cfg_cb__coll("allreduce", mpi_coll_allreduce_description, name, pos);
+ _check_coll("allreduce", mpi_coll_allreduce_description, name);
}
-static void _sg_cfg_cb__coll_alltoall(const char *name, int pos)
+static void _check_coll_alltoall(const char *name, int pos)
{
- _sg_cfg_cb__coll("alltoall", mpi_coll_alltoall_description, name, pos);
+ _check_coll("alltoall", mpi_coll_alltoall_description, name);
}
-static void _sg_cfg_cb__coll_alltoallv(const char *name, int pos)
+static void _check_coll_alltoallv(const char *name, int pos)
{
- _sg_cfg_cb__coll("alltoallv", mpi_coll_alltoallv_description, name, pos);
+ _check_coll("alltoallv", mpi_coll_alltoallv_description, name);
}
-static void _sg_cfg_cb__coll_bcast(const char *name, int pos)
+static void _check_coll_bcast(const char *name, int pos)
{
- _sg_cfg_cb__coll("bcast", mpi_coll_bcast_description, name, pos);
+ _check_coll("bcast", mpi_coll_bcast_description, name);
}
-static void _sg_cfg_cb__coll_reduce(const char *name, int pos)
+static void _check_coll_reduce(const char *name, int pos)
{
- _sg_cfg_cb__coll("reduce", mpi_coll_reduce_description, name, pos);
+ _check_coll("reduce", mpi_coll_reduce_description, name);
}
-static void _sg_cfg_cb__coll_reduce_scatter(const char *name, int pos){
- _sg_cfg_cb__coll("reduce_scatter", mpi_coll_reduce_scatter_description, name, pos);
+static void _check_coll_reduce_scatter(const char *name, int pos){
+ _check_coll("reduce_scatter", mpi_coll_reduce_scatter_description, name);
}
-static void _sg_cfg_cb__coll_scatter(const char *name, int pos){
- _sg_cfg_cb__coll("scatter", mpi_coll_scatter_description, name, pos);
+static void _check_coll_scatter(const char *name, int pos){
+ _check_coll("scatter", mpi_coll_scatter_description, name);
}
-static void _sg_cfg_cb__coll_barrier(const char *name, int pos){
- _sg_cfg_cb__coll("barrier", mpi_coll_barrier_description, name, pos);
+static void _check_coll_barrier(const char *name, int pos){
+ _check_coll("barrier", mpi_coll_barrier_description, name);
}
static void _sg_cfg_cb__wtime_sleep(const char *name, int pos){
/* Plugins configuration */
describe_model(description, surf_plugin_description, "plugin", "The plugins");
- xbt_cfg_register(&simgrid_config, "plugin", description, xbt_cfgelm_string, 0, &_sg_cfg_cb__plugin);
+ xbt_cfg_register_string("plugin", description, nullptr, &_sg_cfg_cb__plugin);
describe_model(description, surf_cpu_model_description, "model", "The model to use for the CPU");
xbt_cfg_register_string("cpu/model", description, "Cas01", &_sg_cfg_cb__cpu_model);
"Update the constraint set propagating recursively to others constraints (off by default when optim is set to lazy)",
"no", NULL);
/* Replay (this part is enabled even if MC it disabled) */
- xbt_cfg_register(&simgrid_config, "model-check/replay", "Enable replay mode with the given path", xbt_cfgelm_string, 0, _sg_cfg_cb_model_check_replay);
+ xbt_cfg_register_string("model-check/replay", "Enable replay mode with the given path", nullptr, _sg_cfg_cb_model_check_replay);
#if HAVE_MC
/* do model-checking-record */
xbt_cfg_register_double("smpi/test", "Minimum time to inject inside a call to MPI_Test", 1e-4, _sg_cfg_cb__test_sleep);
xbt_cfg_register_double("smpi/wtime", "Minimum time to inject inside a call to MPI_Wtime", 0.0, _sg_cfg_cb__wtime_sleep);
- xbt_cfg_register_string("smpi/coll_selector", "Which collective selector to use", "default", NULL);
-
- xbt_cfg_register(&simgrid_config, "smpi/gather", "Which collective to use for gather",
- xbt_cfgelm_string, 0, &_sg_cfg_cb__coll_gather);
-
- xbt_cfg_register(&simgrid_config, "smpi/allgather", "Which collective to use for allgather",
- xbt_cfgelm_string, 0, &_sg_cfg_cb__coll_allgather);
-
- xbt_cfg_register(&simgrid_config, "smpi/barrier", "Which collective to use for barrier",
- xbt_cfgelm_string, 0, &_sg_cfg_cb__coll_barrier);
-
- xbt_cfg_register(&simgrid_config, "smpi/reduce_scatter", "Which collective to use for reduce_scatter",
- xbt_cfgelm_string, 0, &_sg_cfg_cb__coll_reduce_scatter);
-
- xbt_cfg_register(&simgrid_config, "smpi/scatter", "Which collective to use for scatter",
- xbt_cfgelm_string, 0, &_sg_cfg_cb__coll_scatter);
-
- xbt_cfg_register(&simgrid_config, "smpi/allgatherv", "Which collective to use for allgatherv",
- xbt_cfgelm_string, 0, &_sg_cfg_cb__coll_allgatherv);
-
- xbt_cfg_register(&simgrid_config, "smpi/allreduce", "Which collective to use for allreduce",
- xbt_cfgelm_string, 0, &_sg_cfg_cb__coll_allreduce);
-
- xbt_cfg_register(&simgrid_config, "smpi/alltoall", "Which collective to use for alltoall",
- xbt_cfgelm_string, 0, &_sg_cfg_cb__coll_alltoall);
-
- xbt_cfg_register(&simgrid_config, "smpi/alltoallv", "Which collective to use for alltoallv",
- xbt_cfgelm_string, 0, &_sg_cfg_cb__coll_alltoallv);
-
- xbt_cfg_register(&simgrid_config, "smpi/bcast", "Which collective to use for bcast",
- xbt_cfgelm_string, 0, &_sg_cfg_cb__coll_bcast);
-
- xbt_cfg_register(&simgrid_config, "smpi/reduce", "Which collective to use for reduce",
- xbt_cfgelm_string, 0, &_sg_cfg_cb__coll_reduce);
+ xbt_cfg_register_string("smpi/coll_selector", "Which collective selector to use", "default", NULL);
+ xbt_cfg_register_string("smpi/gather", "Which collective to use for gather", nullptr, &_check_coll_gather);
+ xbt_cfg_register_string("smpi/allgather", "Which collective to use for allgather", nullptr, &_check_coll_allgather);
+ xbt_cfg_register_string("smpi/barrier", "Which collective to use for barrier", nullptr, &_check_coll_barrier);
+ xbt_cfg_register_string("smpi/reduce_scatter", "Which collective to use for reduce_scatter", nullptr, &_check_coll_reduce_scatter);
+ xbt_cfg_register_string("smpi/scatter", "Which collective to use for scatter", nullptr, &_check_coll_scatter);
+ xbt_cfg_register_string("smpi/allgatherv", "Which collective to use for allgatherv", nullptr, &_check_coll_allgatherv);
+ xbt_cfg_register_string("smpi/allreduce", "Which collective to use for allreduce", nullptr, &_check_coll_allreduce);
+ xbt_cfg_register_string("smpi/alltoall", "Which collective to use for alltoall", nullptr, &_check_coll_alltoall);
+ xbt_cfg_register_string("smpi/alltoallv", "Which collective to use for alltoallv", nullptr, &_check_coll_alltoallv);
+ xbt_cfg_register_string("smpi/bcast", "Which collective to use for bcast", nullptr, &_check_coll_bcast);
+ xbt_cfg_register_string("smpi/reduce", "Which collective to use for reduce", nullptr, &_check_coll_reduce);
#endif // HAVE_SMPI
xbt_cfg_register_boolean("exception/cutpath", "Whether to cut all path information from call traces, used e.g. in exceptions.", "no", NULL);
- xbt_cfg_register_boolean("clean_atexit", "Whether to cleanup SimGrid (XBT,SIMIX,MSG) at exit. Disable it if your code segfaults at ending.",
+ xbt_cfg_register_boolean("clean_atexit", "Whether to cleanup SimGrid at exit. Disable it if your code segfaults at ending.",
"yes", _sg_cfg_cb_clean_atexit);
if (!surf_path) {
xbt_cfg_setdefault_string("path", initial_path);
}
- xbt_cfg_check();
_sg_cfg_init_status = 1;
sg_config_cmd_line(argc, argv);
int find_coll_description(s_mpi_coll_description_t * table,
char *name, const char *desc)
{
- int i;
char *name_list = NULL;
int selector_on=0;
if(name==NULL){//no argument provided, use active selector's algorithm
name=(char*)sg_cfg_get_string("smpi/coll_selector");
selector_on=1;
}
- for (i = 0; table[i].name; i++)
+ for (int i = 0; table[i].name; i++)
if (!strcmp(name, table[i].name)) {
if (strcmp(table[i].name,"default"))
XBT_INFO("Switch to algorithm %s for collective %s",table[i].name,desc);
if(selector_on){
// collective seems not handled by the active selector, try with default one
name=(char*)"default";
- for (i = 0; table[i].name; i++)
+ for (int i = 0; table[i].name; i++)
if (!strcmp(name, table[i].name)) {
return i;
}
if (!table[0].name)
xbt_die("No collective is valid for '%s'! This is a bug.",name);
name_list = xbt_strdup(table[0].name);
- for (i = 1; table[i].name; i++) {
+ for (int i = 1; table[i].name; i++) {
name_list = static_cast<char*>(xbt_realloc(name_list,
strlen(name_list) + strlen(table[i].name) + 3));
strcat(name_list, ", ");
void tmgr_finalize(void)
{
- for (auto kv : trace_list)
+ for (auto kv : trace_list) {
+ xbt_free((char*)kv.first);
delete kv.second;
+ }
}
void tmgr_trace_event_unref(tmgr_trace_iterator_t *trace_event)
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_cfg, xbt, "configuration support");
xbt_cfg_t simgrid_config = NULL;
+static void xbt_cfg_register(xbt_cfg_t * cfg, const char *name, const char *desc, e_xbt_cfgelm_type_t type, xbt_cfg_cb_t cb_set);
-/* xbt_cfgelm_t: the typedef corresponding to a config variable.
-
- Both data and DTD are mixed, but fixing it now would prevent me to ever defend my thesis. */
+/* xbt_cfgelm_t: the typedef corresponding to a config variable. */
typedef struct {
/* Description */
/* Allowed type of the variable */
e_xbt_cfgelm_type_t type;
- int min;
unsigned isdefault:1;
/* Callbacks */
xbt_dynar_t content;
} s_xbt_cfgelm_t, *xbt_cfgelm_t;
-static const char *xbt_cfgelm_type_name[xbt_cfgelm_type_count] = { "int", "double", "string", "boolean", "any" };
+static const char *xbt_cfgelm_type_name[xbt_cfgelm_type_count] = { "int", "double", "string", "boolean", "any", "outofbound" };
const struct xbt_boolean_couple xbt_cfgelm_boolean_values[] = {
{ "yes", "no"},
*whereto = NULL;
xbt_assert(tocopy, "cannot copy NULL config");
- xbt_dict_foreach((xbt_dict_t) tocopy, cursor, name, variable) {
- xbt_cfg_register(whereto, name, variable->desc, variable->type, variable->min, variable->cb_set);
- }
+ xbt_dict_foreach((xbt_dict_t) tocopy, cursor, name, variable)
+ xbt_cfg_register(whereto, name, variable->desc, variable->type, variable->cb_set);
}
/** @brief Destructor */
printf("%s %s:", indent, key);
size = xbt_dynar_length(variable->content);
- printf ("%d_%s. Actual size=%d. postset=%p, List of values:\n",
- variable->min, xbt_cfgelm_type_name[variable->type], size, variable->cb_set);
+ printf ("%s. Actual size=%d. postset=%p, List of values:\n",
+ xbt_cfgelm_type_name[variable->type], size, variable->cb_set);
switch (variable->type) {
case xbt_cfgelm_int:
* @param name the name of the config element
* @param desc a description for this item (used by xbt_cfg_help())
* @param type the type of the config element
- * @param min the minimum number of values for this config element (0 for optional elements)
* @param cb_set callback function called when a value is set
*/
-void xbt_cfg_register(xbt_cfg_t * cfg, const char *name, const char *desc, e_xbt_cfgelm_type_t type, int min, xbt_cfg_cb_t cb_set)
+static void xbt_cfg_register(xbt_cfg_t * cfg, const char *name, const char *desc, e_xbt_cfgelm_type_t type, xbt_cfg_cb_t cb_set)
{
if (*cfg == NULL)
*cfg = xbt_cfg_new();
xbt_assert(NULL == res, "Refusing to register the config element '%s' twice.", name);
res = xbt_new(s_xbt_cfgelm_t, 1);
- XBT_DEBUG("Register cfg elm %s (%s) (%d %s (=%d) @%p in set %p)",
- name, desc, min, xbt_cfgelm_type_name[type], (int)type, res, *cfg);
+ XBT_DEBUG("Register cfg elm %s (%s) (%s (=%d) @%p in set %p)",
+ name, desc, xbt_cfgelm_type_name[type], (int)type, res, *cfg);
res->desc = xbt_strdup(desc);
res->type = type;
- res->min = min;
res->cb_set = cb_set;
res->isdefault = 1;
}
void xbt_cfg_register_double(const char *name, const char *desc, double default_value,xbt_cfg_cb_t cb_set){
- xbt_cfg_register(&simgrid_config,name,desc,xbt_cfgelm_double,1,cb_set);
+ xbt_cfg_register(&simgrid_config,name,desc,xbt_cfgelm_double,cb_set);
xbt_cfg_setdefault_double(name, default_value);
}
void xbt_cfg_register_int(const char *name, const char *desc, int default_value,xbt_cfg_cb_t cb_set){
- xbt_cfg_register(&simgrid_config,name,desc,xbt_cfgelm_int,1,cb_set);
+ xbt_cfg_register(&simgrid_config,name,desc,xbt_cfgelm_int,cb_set);
xbt_cfg_setdefault_int(name, default_value);
}
void xbt_cfg_register_string(const char *name, const char *desc, const char *default_value, xbt_cfg_cb_t cb_set){
- xbt_cfg_register(&simgrid_config,name,desc,xbt_cfgelm_string,1,cb_set);
+ xbt_cfg_register(&simgrid_config,name,desc,xbt_cfgelm_string,cb_set);
xbt_cfg_setdefault_string(name, default_value);
}
void xbt_cfg_register_boolean(const char *name, const char *desc, const char*default_value,xbt_cfg_cb_t cb_set){
- xbt_cfg_register(&simgrid_config,name,desc,xbt_cfgelm_boolean,1,cb_set);
+ xbt_cfg_register(&simgrid_config,name,desc,xbt_cfgelm_boolean,cb_set);
xbt_cfg_setdefault_boolean(name, default_value);
}
res->desc = bprintf("Deprecated alias for %s",newname);
res->type = xbt_cfgelm_alias;
- res->min = 1;
res->isdefault = 1;
res->content = (xbt_dynar_t)newname;
* @param entry a string describing the element to register
*
* The string may consist in several variable descriptions separated by a space.
- * Each of them must use the following syntax: \<name\>:\<min nb\>_to_\<max nb\>_\<type\>
- * with type being one of 'string','int' or 'double'.
+ * Each of them must use the following syntax: \<name\>:\<type\>
+ * with type being one of 'string','int','bool' or 'double'.
*
* Note that this does not allow to set the description, so you should prefer the other interface
*/
char *entrycpy = xbt_strdup(entry);
char *tok;
- int min;
e_xbt_cfgelm_type_t type;
XBT_DEBUG("Register string '%s'", entry);
tok = strchr(entrycpy, ':');
- xbt_assert(tok, "Invalid config element descriptor: %s%s", entry, "; Should be <name>:<min nb>_to_<max nb>_<type>");
+ xbt_assert(tok, "Invalid config element descriptor: %s; Should be <name>:<type>", entry);
*(tok++) = '\0';
- min = strtol(tok, &tok, 10);
- xbt_assert(tok, "Invalid minimum in config element descriptor %s", entry);
-
- xbt_assert(*tok == '_', "Invalid config element descriptor: %s%s", entry,
- "; Should be <name>:<min nb>_to_<max nb>_<type>");
- tok++;
-
for (type = (e_xbt_cfgelm_type_t)0; type < xbt_cfgelm_type_count && strcmp(tok, xbt_cfgelm_type_name[type]); type++);
- xbt_assert(type < xbt_cfgelm_type_count, "Invalid type in config element descriptor: %s%s", entry,
- "; Should be one of 'string', 'int' or 'double'.");
+ xbt_assert(type < xbt_cfgelm_type_count,
+ "Invalid type in config element descriptor: %s; Should be one of 'string', 'int' or 'double'.", entry);
- xbt_cfg_register(cfg, entrycpy, NULL, type, min, NULL);
+ xbt_cfg_register(cfg, entrycpy, NULL, type, NULL);
free(entrycpy); /* strdup'ed by dict mechanism, but cannot be const */
}
/** @brief Displays the declared aliases and their description */
-void xbt_cfg_aliases(xbt_cfg_t cfg)
+void xbt_cfg_aliases(void)
{
xbt_dict_cursor_t dict_cursor;
unsigned int dynar_cursor;
char *name;
xbt_dynar_t names = xbt_dynar_new(sizeof(char *), NULL);
- xbt_dict_foreach((xbt_dict_t )cfg, dict_cursor, name, variable)
+ xbt_dict_foreach((xbt_dict_t )simgrid_config, dict_cursor, name, variable)
xbt_dynar_push(names, &name);
xbt_dynar_sort_strings(names);
xbt_dynar_foreach(names, dynar_cursor, name) {
- variable = xbt_dict_get((xbt_dict_t )cfg, name);
+ variable = xbt_dict_get((xbt_dict_t )simgrid_config, name);
if (variable->type == xbt_cfgelm_alias)
printf(" %s: %s\n", name, variable->desc);
}
/** @brief Displays the declared options and their description */
-void xbt_cfg_help(xbt_cfg_t cfg)
+void xbt_cfg_help(void)
{
xbt_dict_cursor_t dict_cursor;
unsigned int dynar_cursor;
char *name;
xbt_dynar_t names = xbt_dynar_new(sizeof(char *), NULL);
- xbt_dict_foreach((xbt_dict_t )cfg, dict_cursor, name, variable)
+ xbt_dict_foreach((xbt_dict_t )simgrid_config, dict_cursor, name, variable)
xbt_dynar_push(names, &name);
xbt_dynar_sort_strings(names);
xbt_dynar_foreach(names, dynar_cursor, name) {
- int i;
int size;
- variable = xbt_dict_get((xbt_dict_t )cfg, name);
+ variable = xbt_dict_get((xbt_dict_t )simgrid_config, name);
if (variable->type == xbt_cfgelm_alias)
continue;
printf(" %s: %s\n", name, variable->desc);
printf(" Type: %s; ", xbt_cfgelm_type_name[variable->type]);
- if (variable->min != 1)
- printf("Arity: min:%d", variable->min);
size = xbt_dynar_length(variable->content);
- printf("Current value%s: ", (size <= 1 ? "" : "s"));
+ printf("Current value: ");
if (size != 1)
printf(size == 0 ? "n/a\n" : "{ ");
- for (i = 0; i < size; i++) {
+ for (int i = 0; i < size; i++) {
const char *sep = (size == 1 ? "\n" : (i < size - 1 ? ", " : " }\n"));
switch (variable->type) {
xbt_dynar_free(&names);
}
-/** @brief Check that each variable have the right amount of values */
-void xbt_cfg_check(void)
-{
- xbt_dict_cursor_t cursor;
- xbt_cfgelm_t variable;
- char *name;
-
- xbt_dict_foreach((xbt_dict_t) simgrid_config, cursor, name, variable) {
- if (variable->type == xbt_cfgelm_alias)
- continue;
-
- int size = xbt_dynar_length(variable->content);
- if (variable->min > size) {
- xbt_dict_cursor_free(&cursor);
- THROWF(mismatch_error, 0, "Config elem %s needs at least %d %s, but there is only %d values.",
- name, variable->min, xbt_cfgelm_type_name[variable->type], size);
- }
-
- if (variable->isdefault && size > variable->min) {
- xbt_dict_cursor_free(&cursor);
- THROWF(mismatch_error, 0, "Config elem %s theoretically accepts %d %s, but has a default of %d values.",
- name, variable->min, xbt_cfgelm_type_name[variable->type], size);
- }
- }
- xbt_dict_cursor_free(&cursor);
-}
-
static xbt_cfgelm_t xbt_cfgelm_get(xbt_cfg_t cfg, const char *name, e_xbt_cfgelm_type_t type)
{
xbt_cfgelm_t res = xbt_dict_get_or_null((xbt_dict_t) cfg, name);
}
if (!res) {
- xbt_cfg_help(cfg);
+ xbt_cfg_help();
fflush(stdout);
THROWF(not_found_error, 0, "No registered variable '%s' in this config set.", name);
}
char *str;
int i;
double d;
- e_xbt_cfgelm_type_t type = xbt_cfgelm_any; /* Set a dummy value to make gcc happy. It cannot get uninitialized */
+ e_xbt_cfgelm_type_t type = xbt_cfgelm_type_count; /* Set a dummy value to make gcc happy. It cannot get uninitialized */
xbt_ex_t e;
xbt_cfg_t set = NULL;
xbt_log_threshold_set(&_XBT_LOGV(xbt_cfg), xbt_log_priority_critical);
- xbt_cfg_register_str(&set, "speed:1_int");
- xbt_cfg_register_str(&set, "peername:1_string");
- xbt_cfg_register_str(&set, "user:1_string");
+ xbt_cfg_register_str(&set, "speed:int");
+ xbt_cfg_register_str(&set, "peername:string");
+ xbt_cfg_register_str(&set, "user:string");
return set;
} /* end_of_make_set */
xbt_cfg_free(&simgrid_config);
}
-XBT_TEST_UNIT("validation", test_config_validation, "Validation tests")
-{
- xbt_ex_t e;
-
- simgrid_config = make_set();
- xbt_test_add("Having too few elements for speed");
- xbt_cfg_set_parse("peername:veloce user:mquinson\nuser:oaumage\tuser:alegrand");
- TRY {
- xbt_cfg_check();
- } CATCH(e) {
- if (e.category != mismatch_error || strncmp(e.msg, "Config elem speed needs", strlen("Config elem speed needs")))
- xbt_test_fail("Got an exception. msg=%s", e.msg);
- xbt_ex_free(e);
- }
-
- xbt_test_add("Having too much values of 'speed'");
- xbt_cfg_set_parse("peername:toto:42 user:machin");
- TRY {
- xbt_cfg_set_parse("speed:42 speed:24");
- } CATCH(e) {
- if (e.category != mismatch_error ||
- strncmp(e.msg, "Cannot add value 34 to the config elem speed", strlen("Config elem speed needs")))
- xbt_test_fail("Got an exception. msg=%s", e.msg);
- xbt_ex_free(e);
- }
- xbt_cfg_check();
- xbt_cfg_free(&simgrid_config);
-}
-
XBT_TEST_UNIT("use", test_config_use, "Data retrieving tests")
{
simgrid_config = make_set();
xbt_log_init(argc, argv);
}
-/** @brief Finalize the xbt mechanisms.
- * @warning this function is deprecated. Just don't call it, there is nothing more to do to finalize xbt*/
-void xbt_exit()
-{
- XBT_WARN("This function is deprecated, you shouldn't use it");
-}
-
-
/* these two functions belong to xbt/sysdep.h, which have no corresponding .c file */
/** @brief like free, but you can be sure that it is a function */
void xbt_free_f(void *p)