int main(void) { sd_rtnl *rtnl; sd_rtnl_message *m; sd_rtnl_message *r; void *data; int if_loopback; uint16_t type; test_match(); test_multiple(); test_route(); test_container(); assert_se(sd_rtnl_open(&rtnl, 0) >= 0); assert_se(rtnl); if_loopback = (int) if_nametoindex("lo"); assert_se(if_loopback > 0); test_async(if_loopback); test_pipe(if_loopback); test_event_loop(if_loopback); test_link_configure(rtnl, if_loopback); assert_se(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, if_loopback) >= 0); assert_se(m); assert_se(sd_rtnl_message_get_type(m, &type) >= 0); assert_se(type == RTM_GETLINK); assert_se(sd_rtnl_message_read(m, &type, &data) == -EPERM); assert_se(sd_rtnl_call(rtnl, m, 0, &r) == 1); assert_se(sd_rtnl_message_get_type(r, &type) >= 0); assert_se(type == RTM_NEWLINK); assert_se(sd_rtnl_message_read(m, &type, &data) == 0); assert_se((r = sd_rtnl_message_unref(r)) == NULL); assert_se(sd_rtnl_call(rtnl, m, -1, &r) == -EPERM); assert_se((m = sd_rtnl_message_unref(m)) == NULL); assert_se((r = sd_rtnl_message_unref(r)) == NULL); test_link_get(rtnl, if_loopback); test_address_get(rtnl, if_loopback); assert_se(sd_rtnl_flush(rtnl) >= 0); assert_se((m = sd_rtnl_message_unref(m)) == NULL); assert_se((r = sd_rtnl_message_unref(r)) == NULL); assert_se((rtnl = sd_rtnl_unref(rtnl)) == NULL); return EXIT_SUCCESS; }
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; }*/ }
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; } }
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, const char* argv[]) { BasicConfigurator::configure(); if (argc > 1) { std::string arg1 = argv[1]; std::string arg2 = (argc > 2 ? argv[2] : ""); int num = (argc > 3 ? atol(argv[3]) : 1); if ("sharding" == arg1) { test_sharding(arg2, num); } else if ("async" == arg1) { test_async(arg2, num); } else if ("syncapi" == arg1) { test_syncapi(arg2, num); } } }
int _tmain(int argc, _TCHAR* argv[]) { LOG_F("xTest main(), 测试 \n"); int arg = 1018; switch(arg) { case 1000: { test_util_ex(); }break; case 1: { test_util(); }break; case 2: { test_container(); }break; case 3: { test_thread(); }break; case 4: { test_net(true); }break; case 5: { test_boost(); }break; case 6: { test_kbe(); }break; case 1001: { test_db(); }break; case 1002: { test_math(); }break; case 1003: { test_design(); }break; case 1005: { //test_net(false); test_async(true); }break; case 1006: { test_lua(); }break; case 1007: { test_js(); }break; case 1008: { test_proto(); }break; case 1010: { test_graph(); }break; case 1011: { test_graph_d3d(); }break; case 1013: { test_cv(); }break; case 1015: { test_battle(); }break; case 1016: { test_hacker(); }break; case 1017: { test_yh(); }break; case 1018: { test_ai(); } case 1900: { test_tool(); }break; default: { MainEx(argc, argv); }break; } // { // int n = X::Init(NULL); // LOGD_F(" n = %d", n); // // X_HSER->Init(); // X_HSER->Start(); // // X_HSER->Stop(); // X_HSER->Destroy(); // } // { // // [4/26/2015 Administrator] // HINSTANCE hnst=LoadLibrary(_T("xService.dll")); // FreeLibrary(hnst); // // HINSTANCE hnst2=LoadLibrary(_T("xService.dll")); // FreeLibrary(hnst); // // } LOG_F("xTest main(), end"); while(true) { X::Sleep_f(1); } return 0; }
int main(void) { sd_rtnl *rtnl; sd_rtnl_message *m; sd_rtnl_message *r; void *data; int if_loopback; uint16_t type; unsigned int mtu = 0; unsigned int *mtu_reply; test_multiple(); test_route(); test_container(); assert(sd_rtnl_open(0, &rtnl) >= 0); assert(rtnl); if_loopback = (int) if_nametoindex("lo"); assert(if_loopback > 0); test_async(if_loopback); test_pipe(if_loopback); test_event_loop(if_loopback); test_link_configure(rtnl, if_loopback); assert(sd_rtnl_message_link_new(RTM_GETLINK, if_loopback, 0, 0, &m) >= 0); assert(m); assert(sd_rtnl_message_get_type(m, &type) >= 0); assert(type == RTM_GETLINK); assert(sd_rtnl_message_read(m, &type, &data) == 0); assert(sd_rtnl_call(rtnl, m, 0, &r) == 1); assert(sd_rtnl_message_get_type(r, &type) >= 0); assert(type == RTM_NEWLINK); assert(sd_rtnl_message_read(m, &type, &data) == 0); assert((r = sd_rtnl_message_unref(r)) == NULL); assert(sd_rtnl_call(rtnl, m, -1, &r) == -EPERM); assert((m = sd_rtnl_message_unref(m)) == NULL); assert((r = sd_rtnl_message_unref(r)) == NULL); assert(sd_rtnl_message_link_new(RTM_GETLINK, if_loopback, 0, 0, &m) >= 0); assert(m); assert(sd_rtnl_message_append(m, IFLA_MTU, &mtu) >= 0); assert(sd_rtnl_message_read(m, &type, (void **) &mtu_reply) == 1); assert(type == IFLA_MTU); assert(*mtu_reply == 0); assert(sd_rtnl_message_read(m, &type, &data) == 0); assert(sd_rtnl_call(rtnl, m, -1, &r) == 1); while (sd_rtnl_message_read(r, &type, &data) > 0) { switch (type) { // case IFLA_MTU: // assert(*(unsigned int *) data == 65536); // break; // case IFLA_QDISC: // assert(streq((char *) data, "noqueue")); // break; case IFLA_IFNAME: assert(streq((char *) data, "lo")); break; } } assert(sd_rtnl_flush(rtnl) >= 0); assert((m = sd_rtnl_message_unref(m)) == NULL); assert((r = sd_rtnl_message_unref(r)) == NULL); assert((rtnl = sd_rtnl_unref(rtnl)) == NULL); return EXIT_SUCCESS; }