void test_interface( std::istringstream& iss ) { { config c; comma::read< config >( c, iss ); SCOPED_TRACE( "comma::read< config >( c, iss )" ); test_config( c ); } { config c; comma::read< config >( c, iss, true ); SCOPED_TRACE( "comma::read< config >( c, iss, true )" ); test_config( c ); } { config c = comma::read< config >( iss ); SCOPED_TRACE( "comma::read< config >( iss )" ); test_config( c ); } { config c = comma::read< config >( iss, true ); SCOPED_TRACE( "comma::read< config >( iss, true )" ); test_config( c ); } }
int main(void) { test_config(); SD_test(); while (1) {} }
static int proc_args(int argc, char *argv[]) { unsigned short cnt, idle_time, tolerance; short length; /* check the function to test: if the first characters match, accept it */ if (strncmp(argv[1], "packet", strlen("packet")) == 0) { if (argc != 3) { printf( "test_packet: wrong no of arguments for test of test_packet \n"); return EXIT_FAILURE; } cnt = parse_ulong(argv[2], 10); printf("test:: packet(%d)\n", (unsigned short) cnt); if (cnt == ULONG_MAX || cnt < 1) return EXIT_FAILURE; test_packet(cnt); return EXIT_SUCCESS; } else if (strncmp(argv[1], "async", strlen("async")) == 0) { if (argc != 3) { printf( "test_async: wrong no of arguments for test of test_async() \n"); return EXIT_FAILURE; } idle_time = parse_ulong(argv[2], 10); printf("test:: async(%d)\n", (unsigned short) idle_time); if (idle_time == ULONG_MAX) return EXIT_FAILURE; test_async(idle_time); return EXIT_SUCCESS; } else if (strncmp(argv[1], "config", strlen("config")) == 0) { if (argc != 2) { printf( "test_config: wrong no of arguments for test of test_config() \n"); return EXIT_FAILURE; } printf("test:: config()\n"); test_config(); return EXIT_SUCCESS; } /*else if (strncmp(argv[1], "gesture", strlen("gesture")) == 0) { if (argc != 4) { printf( "test_gesture: wrong no of arguments for test of test_gesture() \n"); return EXIT_FAILURE; } length = parse_ulong(argv[2], 10); tolerance = parse_ulong(argv[3], 10); printf("test:: gesture(%d, %d)\n", (unsigned short) length, (unsigned short) tolerance); if (length == ULONG_MAX) return EXIT_FAILURE; if (tolerance == ULONG_MAX) return EXIT_FAILURE; test_gesture(length, tolerance); return EXIT_SUCCESS; }*/ }
void main(void) { int ret, card, ant; unsigned int my_rf_mode; unsigned int *p_rx_ant0, *p_tx_ant0; ret = openair0_open(); if ( ret != 0 ) { if (ret == -1) printf("Error opening /dev/openair0"); if (ret == -2) printf("Error mapping bigshm"); if (ret == -3) printf("Error mapping RX or TX buffer"); return; } my_rf_mode = RXEN + TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM; my_rf_mode += DMAMODE_RX + DMAMODE_TX; printf ("Detected %d number of cards.\n", openair0_num_detected_cards); card =0; ant =0; printf ("Will configure card %d, antenna %d\n", card, ant); p_exmimo_config = openair0_exmimo_pci[card].exmimo_config_ptr; p_exmimo_id = openair0_exmimo_pci[card].exmimo_id_ptr; printf("Card %d: ExpressMIMO %d, HW Rev %d, SW Rev 0x%d\n", card, p_exmimo_id->board_exmimoversion, p_exmimo_id->board_hwrev, p_exmimo_id->board_swrev); //read_firmware_buffer(card); test_config( card, ant, my_rf_mode); // pointer to data p_rx_ant0 = openair0_exmimo_pci[ card ].adc_head[ ant ]; p_tx_ant0 = openair0_exmimo_pci[ card ].dac_head[ ant ]; // do something with the data here openair0_close(); }
static void test_types(void) { print_macros(); print_types(); test_config(); test_types32(); #if SPH_64 test_types64(); #else printf("warning: no 64-bit type defined\n"); #endif }
static int proc_args(int argc, char *argv[]) { unsigned long cnt, idle_time, tolerance; long length; /* check the function to test: if the first characters match, accept it */ if (strncmp(argv[1], "packet", strlen("packet")) == 0) { if( argc != 3 ) { printf("mouse: wrong no of arguments for test of test_packet() \n"); return 1; } if( (cnt = parse_ulong(argv[2], 10)) == ULONG_MAX ) return 1; printf("mouse:: test_packet(%lu)\n", cnt); return test_packet(cnt); } else if (strncmp(argv[1], "async", strlen("async")) == 0) { if( argc != 3 ) { printf("mouse: wrong no of arguments for test_async() \n"); return 1; } if( (idle_time = parse_ulong(argv[2], 10)) == ULONG_MAX ) return 1; printf("mouse:: test_async(%lu)\n", idle_time); return test_async(idle_time); } else if (strncmp(argv[1], "config", strlen("config")) == 0) { if( argc != 2 ) { printf("mouse: wrong no of arguments for test_config() \n"); return 1; } printf("mouse:: test_config()\n"); return test_config(); } else if (strncmp(argv[1], "gesture", strlen("gesture")) == 0) { if( argc != 4 ) { printf("mouse: wrong no of arguments for test_gesture() \n"); return 1; } if( (length = parse_long(argv[2], 10)) == LONG_MAX ) return 1; if( (tolerance = parse_ulong(argv[3], 10)) == ULONG_MAX ) return 1; printf("mouse:: test_gesture(%ld, %lu)\n", length, tolerance); return test_gesture(length, tolerance); } else { printf("mouse: non valid function \"%s\" to test\n", argv[1]); return 1; } }
void test_interface( std::istringstream& iss, const char *root ) { { config c; comma::read< config >( c, iss, root ); SCOPED_TRACE( "comma::read< config >( c, iss, root )" ); test_config( c ); } { config c; comma::read< config >( c, iss, root, true ); SCOPED_TRACE( "comma::read< config >( c, iss, root, true )" ); test_config( c ); } { config c; comma::read< config >( c, iss, xpath( root ) ); SCOPED_TRACE( "comma::read< config >( c, iss, xpath( root ) )" ); test_config( c ); } { config c; comma::read< config >( c, iss, xpath( root ), true ); SCOPED_TRACE( "comma::read< config >( c, iss, xpath( root ), true )" ); test_config( c ); } { config c = comma::read< config >( iss, root ); SCOPED_TRACE( "comma::read< config >( iss, root )" ); test_config( c ); } { config c = comma::read< config >( iss, root, true ); SCOPED_TRACE( "comma::read< config >( iss, root, true )" ); test_config( c ); } { config c = comma::read< config >( iss, xpath( root ) ); SCOPED_TRACE( "comma::read< config >( iss, xpath( root ) )" ); test_config( c ); } { config c = comma::read< config >( iss, xpath( root ), true ); SCOPED_TRACE( "comma::read< config >( iss, xpath( root ), true )" ); test_config( c ); } }
static int proc_args(int argc, char *argv[]) { unsigned short number, time, tolerance; short length; /* check the function to test: if the first characters match, accept it */ if (strncmp(argv[1], "test_packet", strlen("test_packet")) == 0) { if( argc != 3 ) { printf("Keyboard: wrong no of arguments for test of test_packet() \n"); return 1; } if((number = parse_ulong(argv[2], 10)) == ULONG_MAX) return 1; printf("Mouse:: test_packet(%u)\n\n", number); /* Actually, it was already invoked */ return test_packet(number); } else if (strncmp(argv[1], "test_async", strlen("test_async")) == 0) { if( argc != 3) { printf("Mouse: wrong no of arguments for test of test_async() \n"); return 1; } if((time = parse_ulong(argv[2], 10)) == ULONG_MAX) return 1; if(time <= 0) return 1; printf("Mouse:: test_async(%u)\n\n", time); return test_async(time); } else if (strncmp(argv[1], "test_config", strlen("test_config")) == 0) { if( argc != 2 ) { printf("Mouse: wrong no of arguments for test of test_config() \n"); return 1; } printf("Mouse:: test_config()\n\n"); return test_config(); } else if (strncmp(argv[1], "test_gesture", strlen("test_gesture")) == 0) { if( argc != 4 ) { printf("Mouse: wrong no of arguments for test of test_gesture() \n"); return 1; } if((length = parse_ulong(argv[2], 10)) == ULONG_MAX) return 1; if((tolerance = parse_ulong(argv[3], 10)) == ULONG_MAX) return 1; printf("Mouse:: test_gesture(%d, %u)\n\n", length, tolerance); return test_gesture(length, tolerance); } else { printf("Mouse: non valid function \"%s\" to test\n", argv[1]); return 1; } }
static int proc_args(int argc, char *argv[]) { unsigned short cnt, tolerance, i_time; short length = 0; /* check the function to test: if the first characters match, accept it */ if (strncmp(argv[1], "packet", strlen("packet")) == 0) { if( argc != 3 ) { printf("mouse: wrong no of arguments for test of test_packet() \n"); return 1; } if( (cnt = parse_ushort(argv[2], 10)) == USHRT_MAX ) return 1; printf("mouse: test_packet()\n"); test_packet(cnt); return 0; } else if (strncmp(argv[1], "async", strlen("async")) == 0) { if( argc != 3 ) { printf("mouse: wrong no of arguments for test of test_async() \n"); return 1; } if( (i_time = parse_ushort(argv[2], 10)) == USHRT_MAX ) return 1; printf("mouse: test_async()\n"); test_async(i_time); return 0; } else if (strncmp(argv[1], "config", strlen("config")) == 0) { if( argc != 2 ) { printf("mouse: wrong no of arguments for test of test_config() \n"); return 1; } printf("mouse: test_config\n"); test_config(); return 0; } else if (strncmp(argv[1], "gesture", strlen("gesture")) == 0) { if( argc != 4 ) { printf("mouse: wrong no of arguments for test of test_gesture() \n"); return 1; } length = parse_ushort(argv[2], 10); if( (tolerance = parse_ushort(argv[3], 10)) == USHRT_MAX ) return 1; printf("mouse: test_gesture()\n"); test_gesture(length, tolerance); return 0; } else { printf("mouse: non valid function \"%s\" to test\n", argv[1]); return 1; } }
int main (int argc, char const* argv[]) { configure_logger ("INFO", "./logs/config_parser_test.log"); if (argc != 2) { std::cout << "usage: config file" << std::endl; exit (EXIT_FAILURE); } config_parser test_config (argv[1]); std::cout << "Project name: " << test_config.project_name () << std::endl; std::cout << "Project name short: " << test_config.project_name (false) << std::endl; std::cout << "v" << test_config.version () << std::endl; std::cout << "log level: " << test_config.log_level () << std::endl; std::cout << "log file: " << test_config.log_file () << std::endl; std::cout << "Client Name: " << test_config.clientid () << std::endl; std::cout << "Speaker prefix: " << test_config.speaker_prefix () << std::endl; std::cout << "Website prefix: " << test_config.site_prefix () << std::endl; std::cout << "Using broker: " << test_config.broker_selector () << std::endl; std::cout << "Name: " << test_config.broker ().name << std::endl; std::cout << "URI: " << test_config.broker ().uri << std::endl; std::cout << "Port: " << test_config.broker ().port << std::endl; std::cout << "Port encrypted: " << test_config.broker ().port_encrypted << std::endl; std::cout << "Port encrypted certificate: " << test_config.broker ().port_encrypted_certificate << std::endl; std::cout << "Port ws: " << test_config.broker ().port_ws << std::endl; std::cout << "Port ws encrypted: " << test_config.broker ().port_ws_encrypted << std::endl; std::cout << "A few topics from the config:" << std::endl; try { std::cout << "Topic root: " << test_config.topic ("root") << std::endl; std::cout << "Topic Request Online: " << test_config.topic ("request_online") << std::endl; std::cout << "Topic Request client data: " << test_config.topic ("request_client_data") << std::endl; std::cout << "Topic clients data: " << test_config.topic ("clients_data") << std::endl; } catch (std::exception const& exc) { std::cerr << "Exception " << exc.what () << std::endl; exit (EXIT_FAILURE); } catch (...) { std::cerr << "UNKNOWN EXCEPTION" << std::endl; } return 0; }
int main (int argc, char ** argv) { printf ("HEXCODE TESTS\n"); printf ("===============\n\n"); init (argc, argv); test_encode (); test_decode (); test_reversibility (); test_config (); print_result ("testmod_hexcode"); return nbError; }
int main (int argc, char ** argv) { printf ("CCODE TESTS\n"); printf ("=============\n\n"); init (argc, argv); test_encode (); test_decode (); test_reversibility (); test_decodeescape (); test_config (); test_otherescape (); printf ("\ntest_backendhelpers RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError); return nbError; }
static int proc_args(int argc, char *argv[]) { unsigned short number_packets, idle_time, length, tolerance; if (strncmp(argv[1], "packet", strlen("packet")) == 0) { if (argc != 3) { printf("mouse:: wrong no of arguments for test_packet() \n"); return 1; } number_packets = parse_ulong(argv[2], 10); printf("mouse:: packets()\n"); /* Actually, it was already invoked */ test_packet(number_packets); return 0; } else if (strncmp(argv[1], "async", strlen("async")) == 0) { if (argc != 3) { printf("mouse:: wrong no of arguments for test_async() \n"); return 1; } printf("mouse:: async()\n"); /* Actually, it was already invoked */ idle_time = parse_ulong(argv[2], 10); mouse_packet_async(idle_time); return 0; } else if (strncmp(argv[1], "config", strlen("config")) == 0) { if (argc != 2) { printf("mouse: wrong no of arguments for test of test_config() \n"); return 1; } printf("mouse:: config()\n"); /* Actually, it was already invoked */ test_config(); return 0; } else if (strncmp(argv[1], "gesture", strlen("gesture")) == 0) { if (argc != 4) { printf("mouse:: wrong no of arguments for test_gesture() \n"); return 1; } printf("mouse:: gesture()\n"); /* Actually, it was already invoked */ length = parse_ulong(argv[2], 10); tolerance = parse_ulong(argv[3], 10); mouse_gesture(length,tolerance); return 0; } }
int main (void) { extern void test_config (void); extern void test_except (void); extern void test_hashtable (void); extern void test_memory (void); extern void test_scanner (void); extern void test_template (void); #ifdef DEBUG_MALLOC GC_find_leak = 1; #endif test_config(); test_except(); test_hashtable(); test_memory(); test_scanner(); test_template(); #ifdef DEBUG_MALLOC CHECK_LEAKS(); #endif return 0; }
int main(int argc , char ** argv) { test_runpath_list(); test_config( argv[1] ); exit(0); }
int rc_read_config(char *filename) { FILE *configfd; char buffer[512], *p; OPTION *option; int line, pos; if ((configfd = fopen(filename,"r")) == NULL) { errorlog("rc_read_config: can't open %s: %m", filename); return (-1); } line = 0; while ((fgets(buffer, sizeof(buffer), configfd) != NULL)) { line++; p = buffer; if ((*p == '\n') || (*p == '#') || (*p == '\0')) continue; p[strlen(p)-1] = '\0'; if ((pos = strcspn(p, "\t ")) == 0) { errorlog("%s: line %d: bogus format: %s", filename, line, p); return (-1); } p[pos] = '\0'; if ((option = find_option(p, OT_ANY)) == NULL) { errorlog("%s: line %d: unrecognized keyword: %s", filename, line, p); return (-1); } if (option->status != ST_UNDEF) { errorlog("%s: line %d: duplicate option line: %s", filename, line, p); return (-1); } p += pos+1; while (isspace(*p)) p++; switch (option->type) { case OT_STR: if (set_option_str(filename, line, option, p) < 0) return (-1); break; case OT_INT: if (set_option_int(filename, line, option, p) < 0) return (-1); break; case OT_SRV: if (set_option_srv(filename, line, option, p) < 0) return (-1); break; case OT_AUO: if (set_option_auo(filename, line, option, p) < 0) return (-1); break; default: fatallog("rc_read_config: impossible case branch!"); abort(); } } fclose(configfd); return test_config(filename); }
int main (int argc, char **argv) { if (argc <= 1) { usage (); exit (1); } char *config_dir = DEFAULT_CONFIG_DIR; char *central_config_dir = NULL; char *seafile_dir = NULL; char *logdir = NULL; char *ccnet_debug_level_str = "info"; char *seafile_debug_level_str = "debug"; int daemon_mode = 1; gboolean test_conf = FALSE; int c; while ((c = getopt_long (argc, argv, short_opts, long_opts, NULL)) != EOF) { switch (c) { case 'h': usage (); exit(1); break; case 'v': fprintf (stderr, "seafile-controller version 1.0\n"); break; case 't': test_conf = TRUE; break; case 'c': config_dir = optarg; break; case 'F': central_config_dir = g_strdup(optarg); break; case 'd': seafile_dir = g_strdup(optarg); break; case 'f': daemon_mode = 0; break; case 'L': logdir = g_strdup(optarg); break; case 'g': ccnet_debug_level_str = optarg; break; case 'G': seafile_debug_level_str = optarg; break; case 'P': controller_pidfile = optarg; break; default: usage (); exit (1); } } #if !GLIB_CHECK_VERSION(2, 35, 0) g_type_init(); #endif #if !GLIB_CHECK_VERSION(2,32,0) g_thread_init (NULL); #endif if (!seafile_dir) { fprintf (stderr, "<seafile_dir> must be specified with --seafile-dir\n"); exit(1); } if (!central_config_dir) { fprintf (stderr, "<central_config_dir> must be specified with --central-config-dir\n"); exit(1); } central_config_dir = ccnet_expand_path (central_config_dir); config_dir = ccnet_expand_path (config_dir); seafile_dir = ccnet_expand_path (seafile_dir); if (test_conf) { test_config (central_config_dir, config_dir, seafile_dir); } ctl = g_new0 (SeafileController, 1); if (seaf_controller_init (ctl, central_config_dir, config_dir, seafile_dir, logdir) < 0) { controller_exit(1); } char *logfile = g_build_filename (ctl->logdir, "controller.log", NULL); if (seafile_log_init (logfile, ccnet_debug_level_str, seafile_debug_level_str) < 0) { seaf_warning ("Failed to init log.\n"); controller_exit (1); } if (init_syslog_config () < 0) { controller_exit (1); } set_signal_handlers (); if (seaf_controller_start () < 0) controller_exit (1); #ifndef WIN32 if (daemon_mode) { #ifndef __APPLE__ daemon (1, 0); #else /* __APPLE */ /* daemon is deprecated under APPLE * use fork() instead * */ switch (fork ()) { case -1: seaf_warning ("Failed to daemonize"); exit (-1); break; case 0: /* all good*/ break; default: /* kill origin process */ exit (0); } #endif /* __APPLE */ } #endif /* !WIN32 */ if (controller_pidfile == NULL) { controller_pidfile = g_strdup(g_getenv ("SEAFILE_PIDFILE")); } if (controller_pidfile != NULL) { if (write_controller_pidfile () < 0) { seaf_warning ("Failed to write pidfile %s\n", controller_pidfile); return -1; } } run_controller_loop (); return 0; }
rc_handle * rc_read_config(const char *filename) { FILE *configfd; char buffer[512], *p; OPTION *option; int line; size_t pos; rc_handle *rh; rh = rc_new(); if (rh == NULL) return NULL; rh->config_options = malloc(sizeof(config_options_default)); if (rh->config_options == NULL) { rc_log(LOG_CRIT, "rc_read_config: out of memory"); rc_destroy(rh); return NULL; } memcpy(rh->config_options, &config_options_default, sizeof(config_options_default)); if ((configfd = fopen(filename,"r")) == NULL) { rc_log(LOG_ERR,"rc_read_config: can't open %s: %s", filename, strerror(errno)); rc_destroy(rh); return NULL; } line = 0; while ((fgets(buffer, sizeof(buffer), configfd) != NULL)) { line++; p = buffer; if ((*p == '\n') || (*p == '#') || (*p == '\0')) continue; p[strlen(p)-1] = '\0'; if ((pos = strcspn(p, "\t ")) == 0) { rc_log(LOG_ERR, "%s: line %d: bogus format: %s", filename, line, p); fclose(configfd); rc_destroy(rh); return NULL; } p[pos] = '\0'; if ((option = find_option(rh, p, OT_ANY)) == NULL) { rc_log(LOG_ERR, "%s: line %d: unrecognized keyword: %s", filename, line, p); fclose(configfd); rc_destroy(rh); return NULL; } if (option->status != ST_UNDEF) { rc_log(LOG_ERR, "%s: line %d: duplicate option line: %s", filename, line, p); fclose(configfd); rc_destroy(rh); return NULL; } p += pos+1; while (isspace(*p)) p++; pos = strlen(p) - 1; while(pos >= 0 && isspace(p[pos])) pos--; p[pos + 1] = '\0'; switch (option->type) { case OT_STR: if (set_option_str(filename, line, option, p) < 0) { fclose(configfd); rc_destroy(rh); return NULL; } break; case OT_INT: if (set_option_int(filename, line, option, p) < 0) { fclose(configfd); rc_destroy(rh); return NULL; } break; case OT_SRV: if (set_option_srv(filename, line, option, p) < 0) { fclose(configfd); rc_destroy(rh); return NULL; } break; case OT_AUO: if (set_option_auo(filename, line, option, p) < 0) { fclose(configfd); rc_destroy(rh); return NULL; } break; default: rc_log(LOG_CRIT, "rc_read_config: impossible case branch!"); abort(); } } fclose(configfd); if (test_config(rh, filename) == -1) { rc_destroy(rh); return NULL; } return rh; }