int main() { #if DO_SYMBOL symbol_test(); #endif #if DO_SENTENCE sentence_test(); #endif #if DO_PARSE parse_test(); #endif #if DO_CNF cnf_test(); #endif /* kb_test(); model_test(); model_test_2(); model_test_3(); tt_entails_test(); tt_entails_test_2(); cnf_test(); */ return 0; }
int main (void) { struct peer *peer; int i, j; conf_bgp_debug_fsm = -1UL; conf_bgp_debug_events = -1UL; conf_bgp_debug_packet = -1UL; conf_bgp_debug_normal = -1UL; conf_bgp_debug_as4 = -1UL; term_bgp_debug_fsm = -1UL; term_bgp_debug_events = -1UL; term_bgp_debug_packet = -1UL; term_bgp_debug_normal = -1UL; term_bgp_debug_as4 = -1UL; master = thread_master_create (); bgp_master_init (); if (fileno (stdout) >= 0) tty = isatty (fileno (stdout)); if (bgp_get (&bgp, &asn, NULL)) return -1; peer = peer_create_accept (bgp); peer->host = "foo"; for (i = AFI_IP; i < AFI_MAX; i++) for (j = SAFI_UNICAST; j < SAFI_MAX; j++) { peer->afc[i][j] = 1; peer->afc_adv[i][j] = 1; } i = 0; while (mp_reach_segments[i].name) parse_test (peer, &mp_reach_segments[i++], BGP_ATTR_MP_REACH_NLRI); i = 0; while (mp_unreach_segments[i].name) parse_test (peer, &mp_unreach_segments[i++], BGP_ATTR_MP_UNREACH_NLRI); printf ("failures: %d\n", failed); return failed; }
int main (void) { int i = 0; bgp_master_init (); master = bm->master; bgp_option_set (BGP_OPT_NO_LISTEN); bgp_attr_init (); while (test_segments[i].name) { printf ("test %u\n", i); parse_test (&test_segments[i]); empty_prepend_test (&test_segments[i++]); } i = 0; while (prepend_tests[i].test1) { printf ("prepend test %u\n", i); prepend_test (&prepend_tests[i++]); } i = 0; while (aggregate_tests[i].test1) { printf ("aggregate test %u\n", i); aggregate_test (&aggregate_tests[i++]); } i = 0; while (reconcile_tests[i].test1) { printf ("reconcile test %u\n", i); as4_reconcile_test (&reconcile_tests[i++]); } i = 0; cmp_test(); i = 0; empty_get_test(); i = 0; while (aspath_tests[i].desc) { printf ("aspath_attr test %d\n", i); attr_test (&aspath_tests[i++]); } printf ("failures: %d\n", failed); printf ("aspath count: %ld\n", aspath_count()); return (failed + aspath_count()); }
int multipart_test(void) { int rc; rc = parse_test(); if (rc) return rc; return rc; }
int main (void) { int i = 0; ecommunity_init(); while (test_segments[i].name) parse_test (&test_segments[i++]); printf ("failures: %d\n", failed); //printf ("aspath count: %ld\n", aspath_count()); return failed; //return (failed + aspath_count()); }
/** * Execute a query over an XML document parsed from a string. */ int cparsing_example_1(XQC_Implementation* impl) { XQC_Error lError; XQC_Sequence* lDoc; // Create a sequence by parsing a document - will contain a single // document-node() item lError = impl->parse_document(impl, cparsing_xml, &lDoc); if (check_error("parse_document", lError)) return 0; // Complete test return parse_test(impl, lDoc); }
int sock_test() { int rc; pj_create_random_string(bigdata, BIG_DATA_LEN); // Enable this to demonstrate the error witn S60 3rd Edition MR2 #if 0 rc = connect_test(); if (rc != 0) return rc; #endif rc = format_test(); if (rc != 0) return rc; rc = parse_test(); if (rc != 0) return rc; rc = purity_test(); if (rc != 0) return rc; rc = gethostbyname_test(); if (rc != 0) return rc; rc = simple_sock_test(); if (rc != 0) return rc; rc = ioctl_test(); if (rc != 0) return rc; rc = udp_test(); if (rc != 0) return rc; rc = tcp_test(); if (rc != 0) return rc; return 0; }
/** * Execute a query over an XML document parsed from an XQC_InputStream. */ int cparsing_example_2(XQC_Implementation* impl) { XQC_Error lError; XQC_InputStream* lStream = (XQC_InputStream*) malloc(sizeof(XQC_InputStream)); XQC_Sequence* lDoc; lStream->read = read_document_stream; lStream->free = free_document_stream; // Create a sequence by parsing a document - will contain a single // document-node() item lError = impl->parse_document_stream(impl, lStream, &lDoc); if (check_error("parse_document_stream", lError)) return 0; // Complete test return parse_test(impl, lDoc); }
/** * Execute a query over an XML document parsed from a FILE*. */ int cparsing_example_3(XQC_Implementation* impl) { XQC_Error lError; FILE* lFile; XQC_Sequence* lDoc; // Create a sequence by parsing a document - will contain a single // document-node() item lFile = fopen("cparsing.xml", "r"); if (lFile == NULL) { printf("Could not open cparsing.xml - in wrong directory?\n"); return 0; } lError = impl->parse_document_file(impl, lFile, &lDoc); if (check_error("parse_document_file", lError)) return 0; fclose(lFile); // Complete test return parse_test(impl, lDoc); }
int main (void) { int i = 0; aspath_init(); while (test_segments[i].name) { parse_test (&test_segments[i]); empty_prepend_test (&test_segments[i++]); } i = 0; while (prepend_tests[i].test1) prepend_test (&prepend_tests[i++]); i = 0; while (aggregate_tests[i].test1) aggregate_test (&aggregate_tests[i++]); i = 0; while (reconcile_tests[i].test1) as4_reconcile_test (&reconcile_tests[i++]); i = 0; cmp_test(); i = 0; empty_get_test(); printf ("failures: %d\n", failed); printf ("aspath count: %ld\n", aspath_count()); return (failed + aspath_count()); }
/* basic parsing test */ static void parse_test (struct peer *peer, struct test_segment *t, int type) { int parse_ret = 0, nlri_ret = 0; struct attr attr = { }; struct bgp_nlri nlri = { }; struct bgp_attr_parser_args attr_args = { .peer = peer, .length = t->len, .total = 1, .attr = &attr, .type = type, .flags = BGP_ATTR_FLAG_OPTIONAL, .startp = BGP_INPUT_PNT (peer), }; #define RANDOM_FUZZ 35 stream_reset (peer->ibuf); stream_put (peer->ibuf, NULL, RANDOM_FUZZ); stream_set_getp (peer->ibuf, RANDOM_FUZZ); stream_write (peer->ibuf, t->data, t->len); printf ("%s: %s\n", t->name, t->desc); if (type == BGP_ATTR_MP_REACH_NLRI) parse_ret = bgp_mp_reach_parse (&attr_args, &nlri); else parse_ret = bgp_mp_unreach_parse (&attr_args, &nlri); if (parse_ret == 0 && t->afi_valid == VALID_AFI) assert (nlri.afi == t->afi && nlri.safi == t->safi); if (!parse_ret) { if (type == BGP_ATTR_MP_REACH_NLRI) nlri_ret = bgp_nlri_parse (peer, &attr, &nlri); else nlri_ret = bgp_nlri_parse (peer, NULL, &nlri); } handle_result (peer, t, parse_ret, nlri_ret); } static struct bgp *bgp; static as_t asn = 100; int main (void) { struct peer *peer; int i, j; conf_bgp_debug_fsm = -1UL; conf_bgp_debug_events = -1UL; conf_bgp_debug_packet = -1UL; conf_bgp_debug_normal = -1UL; conf_bgp_debug_as4 = -1UL; term_bgp_debug_fsm = -1UL; term_bgp_debug_events = -1UL; term_bgp_debug_packet = -1UL; term_bgp_debug_normal = -1UL; term_bgp_debug_as4 = -1UL; master = thread_master_create (); bgp_master_init (); bgp_option_set (BGP_OPT_NO_LISTEN); bgp_attr_init (); bgp_address_init (); if (fileno (stdout) >= 0) tty = isatty (fileno (stdout)); if (bgp_get (&bgp, &asn, NULL)) return -1; peer = peer_create_accept (bgp); peer->host = (char *)"foo"; peer->status = Established; for (i = AFI_IP; i < AFI_MAX; i++) for (j = SAFI_UNICAST; j < SAFI_MAX; j++) { peer->afc[i][j] = 1; peer->afc_adv[i][j] = 1; } i = 0; while (mp_reach_segments[i].name) parse_test (peer, &mp_reach_segments[i++], BGP_ATTR_MP_REACH_NLRI); i = 0; while (mp_unreach_segments[i].name) parse_test (peer, &mp_unreach_segments[i++], BGP_ATTR_MP_UNREACH_NLRI); printf ("failures: %d\n", failed); return failed; }
static bool parse_command_line( int argc, char *argv[] ) { int n; for (n = 1; n < argc; n++) { const char *arg = argv[n]; if (strcmp (arg, "-h") == 0 || strcmp (arg, "--help") == 0) { print_usage (argv[0]); return false; } if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0) { fprintf (stderr, "dfbg version %s\n", DIRECTFB_VERSION); return false; } if (strcmp (arg, "-T") == 0 || strcmp (arg, "--top-level") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_id( argv[n], &m_toplevel_id )) return false; continue; } if (strcmp (arg, "-W") == 0 || strcmp (arg, "--wait-at-end") == 0) { m_wait_at_end = DFB_TRUE; continue; } if (strcmp (arg, "-r") == 0 || strcmp (arg, "--run") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_test( argv[n], false )) return false; continue; } if (strcmp (arg, "-p") == 0 || strcmp (arg, "--pos") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_position( argv[n], &m_desc_top.posx, &m_desc_top.posy )) return false; continue; } if (strcmp (arg, "-s") == 0 || strcmp (arg, "--size") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_size( argv[n], &m_desc_top.width, &m_desc_top.height )) return false; continue; } if (strcmp (arg, "-f") == 0 || strcmp (arg, "--format") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_format( argv[n], &m_desc_top.pixelformat )) return false; continue; } if (strcmp (arg, "-c") == 0 || strcmp (arg, "--caps") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_caps( argv[n], &m_desc_top.caps )) return false; continue; } if (strcmp (arg, "-l") == 0 || strcmp (arg, "--color") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_color( argv[n], &m_topcolor.color )) return false; m_topcolor.valid = true; continue; } if (strcmp (arg, "-o") == 0 || strcmp (arg, "--option") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_option( argv[n], &m_desc_top.options )) return false; continue; } if (strcmp (arg, "-a") == 0 || strcmp (arg, "--associate") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_id( argv[n], &m_desc_top.parent_id )) return false; // m_desc_top.flags |= DWDESC_PARENT; m_desc_top.options |= DWOP_FOLLOW_BOUNDS; continue; } if (strcmp (arg, "-R") == 0 || strcmp (arg, "--sub-run") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_test( argv[n], true )) return false; continue; } if (strcmp (arg, "-P") == 0 || strcmp (arg, "--sub-pos") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_position( argv[n], &m_desc_sub.posx, &m_desc_sub.posy )) return false; continue; } if (strcmp (arg, "-S") == 0 || strcmp (arg, "--sub-size") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_size( argv[n], &m_desc_sub.width, &m_desc_sub.height )) return false; continue; } if (strcmp (arg, "-F") == 0 || strcmp (arg, "--sub-format") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_format( argv[n], &m_desc_sub.pixelformat )) return false; continue; } if (strcmp (arg, "-C") == 0 || strcmp (arg, "--sub-caps") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_caps( argv[n], &m_desc_sub.caps )) return false; continue; } if (strcmp (arg, "-L") == 0 || strcmp (arg, "--sub-color") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_color( argv[n], &m_subcolor.color )) return false; m_subcolor.valid = true; continue; } if (strcmp (arg, "-O") == 0 || strcmp (arg, "--sub-option") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_option( argv[n], &m_desc_sub.options )) return false; continue; } if (strcmp (arg, "-A") == 0 || strcmp (arg, "--sub-associate") == 0) { if (++n == argc) { print_usage (argv[0]); return false; } if (!parse_id( argv[n], &m_desc_sub.parent_id )) return false; // m_desc_sub.flags |= DWDESC_PARENT; m_desc_sub.options |= DWOP_FOLLOW_BOUNDS; continue; } print_usage (argv[0]); return false; } return true; }
static void parse_program (scanner_t *scanner) { while (!match_current_type (scanner, TOKEN_EOF)) parse_test (scanner); }
int main (void) { struct peer *peer; int i, j; conf_bgp_debug_fsm = -1UL; conf_bgp_debug_events = -1UL; conf_bgp_debug_packet = -1UL; conf_bgp_debug_normal = -1UL; conf_bgp_debug_as4 = -1UL; term_bgp_debug_fsm = -1UL; term_bgp_debug_events = -1UL; term_bgp_debug_packet = -1UL; term_bgp_debug_normal = -1UL; term_bgp_debug_as4 = -1UL; master = thread_master_create (); bgp_master_init (); if (fileno (stdout) >= 0) tty = isatty (fileno (stdout)); if (bgp_get (&bgp, &asn, NULL)) return -1; peer = peer_create_accept (bgp); peer->host = (char *) "foo"; for (i = AFI_IP; i < AFI_MAX; i++) for (j = SAFI_UNICAST; j < SAFI_MAX; j++) { peer->afc[i][j] = 1; peer->afc_adv[i][j] = 1; } i = 0; while (mp_segments[i].name) parse_test (peer, &mp_segments[i++], CAPABILITY); /* These tests assume mp_segments tests set at least * one of the afc_nego's */ i = 0; while (test_segments[i].name) parse_test (peer, &test_segments[i++], CAPABILITY); i = 0; while (misc_segments[i].name) parse_test (peer, &misc_segments[i++], CAPABILITY); i = 0; while (opt_params[i].name) parse_test (peer, &opt_params[i++], OPT_PARAM); SET_FLAG (peer->cap, PEER_CAP_DYNAMIC_ADV); peer->status = Established; i = 0; while (dynamic_cap_msgs[i].name) parse_test (peer, &dynamic_cap_msgs[i++], DYNCAP); printf ("failures: %d\n", failed); return failed; }
int parse_settings( int argc, char *argv[], struct settings *settings ) { int c; const char *optstring = "DhvVtTReunqs:d:p:c:i:H:r:m:"; assert ( settings != NULL ); // Default arguments settings->daemon = 0; settings->message_size = 1024; settings->socket_size = ~0; settings->rate = ~0; settings->disable_nagles = 0; settings->duration = 10; settings->server_host = NULL; settings->port = 1234; settings->verbose = 0; settings->dirty = 0; settings->timestamp = 0; settings->confidence_lvl = 0.0; settings->confidence_int = 0.0; settings->min_iterations = 1; settings->max_iterations = 1; settings->threaded_model = MODEL_THREADED; settings->reverse = 0; settings->quiet = 0; settings->type = SOCK_STREAM; settings->protocol = IPPROTO_TCP; settings->test = NULL; settings->tests = 0; if ( argc == 1 ) { print_usage(); return -1; } // A first pass of getopt to work out if we are a daemon while ((c = getopt(argc, argv, optstring)) != -1) { switch ( c ) { // daemon mode (wait for incoming tests) case 'D': settings->daemon = 1; break; case 'h': print_usage(); return -1; // Increase the verbose level case 'v': settings->verbose = 1; break; case 'V': print_version(); return -1; case ':': fprintf(stderr, "Missing argument for (%s)\n", argv[optind-1] ); return -1; case '?': fprintf(stderr, "Unknown argument (%s)\n", argv[optind-1] ); return -1; default: break; } } if ( settings->daemon && optind < argc ) { fprintf(stderr, "Tests can not be specified on the command line in daemon mode\n" ); return -1; } // Reset the parsing to the beginning optind = 1; #ifdef __FreeBSD__ optreset = 1; #endif // Second pass which actually does the work while ((c = getopt(argc, argv, optstring)) != -1) { switch ( c ) { case 'c': { double level = 95.0, interval = 5.0; if ( settings->daemon ) { fprintf(stdout, "Unable to set confidence interval when in daemon mode\n"); return -1; } if ( sscanf( optarg, "%lf,%lf", &level, &interval ) < 2 ) { fprintf(stdout, "%lf%% Confidence interval defaulted to %lf percent\n", level, interval); } if (level != 75.0 && level != 90.0 && level != 95.0 && level != 97.5 && level != 99.0 && level != 99.5 && level != 99.95) { fprintf(stderr, "Confidence Level must be {75, 90, 95, 97.5, 99, 99.5, 99.95}. Given (%s)\n", optarg); return -1; } settings->confidence_lvl = level; settings->confidence_int = interval; break; } // Duration case 'd': if ( settings->daemon ) { fprintf(stdout, "Unable to set duration when in daemon mode\n"); return -1; } settings->duration = atoi( optarg ); if ( settings->duration == 0 ) { fprintf(stderr, "Invalid duration given (%s)\n", optarg ); return -1; } break; case 'i': { // min,max interations unsigned int min = 0, max = 0; if ( settings->daemon ) { fprintf(stdout, "Unable to set iterations when in daemon mode\n"); return -1; } if ( sscanf( optarg, "%u,%u", &min, &max ) < 2 ) { if (sscanf( optarg, "%u", &max ) == 1) min = max; // Let the user specify just one value } if ( min > max || max == 0 ) { fprintf(stderr, "Invalid min/max iterations(%s)\n", optarg ); return -1; } settings->min_iterations = min; settings->max_iterations = max; break; } case 'H': { // remote host struct sockaddr_storage addr; socklen_t addr_len = sizeof(addr); if ( settings->daemon ) { fprintf(stdout, "Unable to set remote host when in daemon mode\n"); return -1; } if ( str_to_addr( optarg, (struct sockaddr *)&addr, &addr_len ) ) { fprintf(stderr, "Invalid host name (%s)\n", optarg ); return -1; } settings->server_host = optarg; break; } // Disable nagles algorithm (ie NO delay) case 'n': if ( settings->daemon ) { fprintf(stdout, "Unable to disable Nagles when in daemon mode\n"); return -1; } settings->disable_nagles = 1; break; case 'm' : if ( settings->daemon ) { fprintf(stdout, "Unable to set threading model when in daemon mode\n"); return -1; } if(strcmp(optarg, "p")==0) settings->threaded_model = MODEL_PROCESS; else if( strcmp(optarg, "t")==0) settings->threaded_model = MODEL_THREADED; else { fprintf(stderr, "Invalid threading model set to (%s)\n", optarg ); return -1; } break; case 'q': if ( settings->daemon ) { fprintf(stdout, "Unable to set quiet when in daemon mode\n"); return -1; } settings->quiet = 1; break; // Parse the message size case 's': if ( settings->daemon ) { fprintf(stdout, "Unable to set message size when in daemon mode\n"); return -1; } settings->message_size = atoi( optarg ); if ( settings->message_size == 0 ) { fprintf(stderr, "Invalid message size given (%s)\n", optarg ); return -1; } break; // Send rate case 'r': if ( settings->daemon ) { fprintf(stdout, "Unable to set send rate when in daemon mode\n"); return -1; } settings->rate = atoi( optarg ); if ( settings->rate == 0 ) { fprintf(stderr, "Invalid send rate given (%s)\n", optarg ); return -1; } break; // Parse the port case 'p': if ( settings->daemon ) { fprintf(stdout, "Unable to set port when in daemon mode\n"); return -1; } settings->port = atoi( optarg ); if ( settings->port == 0 ) { fprintf(stderr, "Invalid port number given (%s)\n", optarg ); return -1; } break; // Dirty the data case 'e': if ( settings->daemon ) { fprintf(stdout, "Unable to eat the data when in daemon mode\n"); return -1; } settings->dirty = 1; break; // Reverse mode case 'R': if ( settings->daemon ) { fprintf(stdout, "Unable to set reverse mode when in daemon mode\n"); return -1; } settings->reverse = 1; break; case 'T': #ifdef WIN32 fprintf(stdout, "Timestamps option unavailable on windows\n"); return -1; #endif if ( settings->daemon ) { fprintf(stdout, "Unable to set timestamps when in daemon mode\n"); return -1; } settings->timestamp = 1; break; // TCP/UDP case 't': if ( settings->daemon ) { fprintf(stdout, "Unable to set TCP when in daemon mode\n"); return -1; } settings->type = SOCK_STREAM; settings->protocol = IPPROTO_TCP; break; case 'u': if ( settings->daemon ) { fprintf(stdout, "Unable to set UDP when in daemon mode\n"); return -1; } settings->type = SOCK_DGRAM; settings->protocol = IPPROTO_UDP; break; // Ignore the following parameters as they have been parsed in a previous getopt loop case 'D': case 'h': case 'v': case 'V': break; default: fprintf(stderr, "Argument not implemented (yet) (%c)\n", c ); return -1; } } if ( settings->disable_nagles && settings->protocol != IPPROTO_TCP ) { fprintf(stderr, "Must use TCP when disabling Nagles\n" ); return -1; } // if( settings->timestamp && settings->message_size < sizeof(unsigned long long) ) { // fprintf(stderr, "Message size must be greater than %u when using timestamps\n", (unsigned int) sizeof(unsigned long long) ); // return -1; // } // Try and parse anything else left on the end // 1{0-0} 10{1-1} 3{0-1}, 1 connection core 0 to core 0, 10 connections core 1 to core 1, and 3 connections core 0 to core 1 while (optind < argc) { struct test * test; assert( !settings->daemon ); // Malloc space for this extra test settings->test = realloc ( settings->test, sizeof(*settings->test) * (settings->tests + 1) ); test = &settings->test [ settings->tests ]; // Parse N{C-S} if ( parse_test ( settings, argv[optind], test ) != 0 ) { fprintf(stderr, "Unknown argument (%s)\n", argv[optind] ); return -1; } // Check all the paramters make sense if ( test->clientcores == 0 || test->servercores == 0 ) { fprintf(stderr, "Cores of zero will not run on any core (%s)\n", argv[optind] ); return -1; } // TODO check if the server is remote, and then decide if the cores make sense if ( test->clientcores >= (unsigned int)(1 << max_cores) || test->servercores >= (unsigned int)(1 << max_cores) ) { fprintf(stderr, "Cores must not be greater than %d (%s)\n", max_cores, argv[optind] ); return -1; } settings->tests++; optind++; } // If there are no tests then error if ( settings->tests == 0 && !settings->daemon ) { fprintf(stderr, "No tests were specified\n"); return -1; } settings->clientcores = count_client_cores ( settings->test, settings->tests ); settings->servercores = count_server_cores ( settings->test, settings->tests ); return 0; }