// Tests if an options with MyFamily fingerprints missing '$' normalises // them correctly and also ensure it also works with multiple fingerprints static void test_config_fix_my_family(void *arg) { char *err = NULL; const char *family = "$1111111111111111111111111111111111111111, " "1111111111111111111111111111111111111112, " "$1111111111111111111111111111111111111113"; or_options_t* options = options_new(); or_options_t* defaults = options_new(); (void) arg; options_init(options); options_init(defaults); options->MyFamily = tor_strdup(family); options_validate(NULL, options, defaults, 0, &err) ; if (err != NULL) { TT_FAIL(("options_validate failed: %s", err)); } test_streq(options->MyFamily, "$1111111111111111111111111111111111111111, " "$1111111111111111111111111111111111111112, " "$1111111111111111111111111111111111111113"); done: if (err != NULL) { tor_free(err); } or_options_free(options); or_options_free(defaults); }
void mu_test_options () { struct balloon_options opts; opts.m_cost = 0; opts.t_cost = 10000llu; opts.n_neighbors = 1; opts.comp_opts.comp = 0; opts.comp_opts.comb = 0; opts.mix = 0; opts.n_threads = 1; opts.m_cost = 1024; mu_check ( !options_validate (&opts) ); opts.t_cost = 0; mu_check ( !options_validate (&opts) ); opts.t_cost = 3; opts.n_neighbors = 0; mu_check ( options_validate (&opts) ); }
int main (int argc, char *argv[]) { struct version v; show_version(&v); g_log_set_default_handler(logger_stdout_log, NULL); struct options *opt = malloc(sizeof(struct options)); memset(opt, 0, sizeof(struct options)); if( options_parse(opt, argc, argv) == false ) { g_error("Could not parse options!\n"); } if( options_validate(opt) == false ) { g_error("Invalid options"); } g_log_set_default_handler(logger_stdout_log, opt->stdOUT.filter); // gc if( opt->garbage != NULL ) { #ifdef HAVE_LIBGC g_message("gc mode %s", opt->garbage); if( g_mem_gc_friendly != TRUE ) { g_error("export G_DEBUG=gc-friendly\nexport G_SLICE=always-malloc\n for gc"); } static GMemVTable memory_vtable = { .malloc = GC_malloc, .realloc = GC_realloc, .free = GC_free, }; g_mem_set_vtable(&memory_vtable); if( strcmp(opt->garbage, "debug") == 0 ) GC_find_leak = 1; // set libev allocator typedef void *(*moron)(void *ptr, long size); ev_set_allocator((moron)GC_realloc); #endif }