static void run( Competitor& client ) { const std::string root = "./resources/"; const std::string problemClassFile = root + "classFolder.txt"; const std::vector< std::string > lines = read_text_file( problemClassFile ); if( lines.empty() ) throw std::runtime_error( "bad format for classFolder.txt" ); const std::string problemClassName = lines.front(); const std::string problemFolder( root + problemClassName ); ProblemClass problemClass( problemFolder, client.getTrainingCategory() ); long long actualTestingTime = -1, actualTrainingTime = -1; switch( client.getTrainingCategory() ) { case TrainingCategory::NONE : { actualTestingTime = testClient( client, problemClass.getTestingInstances() ); std::clog << "actualTestingTime:" << actualTestingTime << std::endl; } break; case TrainingCategory::SHORT : case TrainingCategory::LONG : { actualTrainingTime = trainClient( client, problemClass.getTrainingInstances() ); std::clog <<"actualTrainingTime:" << actualTrainingTime << std::endl; actualTestingTime = testClient( client, problemClass.getTestingInstances() ); std::clog <<"actualTestingTime:" << actualTestingTime << std::endl; } break; default : throw std::logic_error( "Bad training category in CBBOC2015.run()" ); } /////////////////////////// const std::time_t now = std::time(NULL); char buffer[ 1024 ]; std::strftime( buffer, sizeof(buffer), "%Y-%m-%d-%H-%M-%S", // "%T", std::localtime(&now)); const std::string timestamp( buffer ); const std::string className = classname( client ); OutputResults results( className, timestamp, problemClassName, problemClass, actualTrainingTime, actualTestingTime ); std::string outputPath = problemFolder + "/results/"; outputPath += "CBBOC2015results-" + className + "-" + problemClassName + "-" + timestamp + ".json"; std::ofstream out( outputPath ); out << results.toJSonString() << std::endl; /////////////////////////// std::cout << results.toJSonString() << std::endl; }
int main (int argc, const char * argv[]) #endif { talk_base::AutoThread auto_thread; talk_base::Thread* thread = talk_base::Thread::Current(); #if !defined(MAC_IPHONE) GoCast::ThreadSafeMessageQueue mq; #endif if (!parsecmd(argc, (char**)argv)) { std::cout << "Error parsing command line arguments." << endl; exit(-1); } #if(defined(GOCAST_ENABLE_VIDEO) && defined(GOCAST_LINUX)) gtk_init(&argc, (char***)&argv); #endif GoCast::SocketServer socket_server; thread->set_socketserver(&socket_server); //Declare client only after set_socketserver() #if(defined(GOCAST_ENABLE_VIDEO) && !defined(GOCAST_WINDOWS)) GoCast::PeerConnectionClient testClient(&mq, NULL, peername, mainserver, mainserver_port, false); #else GoCast::PeerConnectionClient testClient(&mq, NULL, peername, mainserver, mainserver_port); #endif socket_server.SetPeerConnectionClient(&testClient); #if !defined(MAC_IPHONE) //Run client shell TestClientShell shell(&mq); shell.startThread(); #endif //Run client thread->Run(); //Set thread's socket server to NULL before exiting thread->set_socketserver(NULL); #if !defined(MAC_IPHONE) //Stop shell thread shell.stopThread(); #endif return 0; }
Tests() { // #if USE_SSL // // Init SSL Context // SSLContext::Ptr ptrContext = new // SSLContext(SSLContext::CLIENT_USE, "", "", "", // SSLContext::VERIFY_NONE, 9, true, // "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); // SSLManager::instance().initializeClient(ptrContext); // // sockio::SSLClient client(app.loop); // #else // sockio::TCPClient client(app.loop); // #endif // // client.StateChange += sdelegate(this, // &Tests::onClientStateChange); // client.connect(SERVER_HOST, SERVER_PORT); // // app.run(); // // // TODO: Benchmarks // // TODO: Transaction tests // // #if USE_SSL // SSLManager::instance().shutdown(); // #endif // app.finalize(); testClient(); }
Tests() { // TODO: // - Obtain authentication token // - Transaction test // - Presence test // - Ack test // - Benchmarks testClient(); #if 0 testAddress(); #endif }
int PluginMainThread::workerBee(void) { talk_base::AutoThread autoThread; GoCast::SocketServer socketServer; talk_base::Thread::Current()->set_socketserver(&socketServer); GoCast::PeerConnectionClient testClient(m_pMsgQ, m_pEvtQ, "", "", -1); socketServer.SetPeerConnectionClient(&testClient); talk_base::Thread::Current()->Run(); talk_base::Thread::Current()->set_socketserver(NULL); return 0; }
THREADRET WINAPI clientCallback(void* param) { testClient(); return 0; }
void subc_ActivateList ( pool_sQlink *lh, pwr_tObjid oid ) { pwr_tStatus sts; tree_sTable *add; #if 0 tree_sTable *remove; sRemove *rep; #endif net_sSubSpec *specp; qcom_sQid tgt; pool_sQlink *my_lh; pwr_tUInt32 my_subc_lc; gdb_sNode *np; gdb_sNode *old_np; sub_sClient *cp; pool_sQlink *cl; sAdd *aep; /* Test each client. If existing object, fill in nid field and move the client to the appropriate nodes's subc_lh list. Turn on timeouts. Put request in subadd message buffer. We must do it all in one pass, since a user can come in during a cache query for a later subcli and cancel the subscription for an earlier subcli. */ add = tree_CreateTable(&sts, sizeof(pwr_tNodeId), offsetof(sAdd, nid), sizeof(sAdd), 10, tree_Comp_nid); #if 0 remove = tree_CreateTable(&sts, sizeof(pwr_tNodeId), offsetof(sRemove, nid), sizeof(sRemove), 10, tree_eComp_nid); #endif /* Move all objects to a new, temporary root */ my_lh = pool_Qalloc(NULL, gdbroot->pool); my_subc_lc = 0; for (cl = pool_Qsucc(NULL, gdbroot->pool, lh); cl != lh;) { cp = pool_Qitem(cl, sub_sClient, subc_ll); cl = pool_Qsucc(NULL, gdbroot->pool, cl); if (cdh_ObjidIsNull(oid) || cdh_ObjidIsEqual(oid, cp->aref.Objid)) { pool_Qremove(NULL, gdbroot->pool, &cp->subc_ll); pool_QinsertPred(NULL, gdbroot->pool, &cp->subc_ll, my_lh); my_subc_lc++; } } /* Now start testing clients from 'my_lh', and move them to other lists Make sure the clients are still there after the test. */ for (cl = pool_Qsucc(NULL, gdbroot->pool, my_lh); cl != my_lh; ) { cp = pool_Qitem(cl, sub_sClient, subc_ll); cl = pool_Qsucc(NULL, gdbroot->pool, cl); np = testClient(&sts, cp); /* If an error is returned the client doesn't exist anymore. Some other user removed it while TestSubcli had the database unlocked. Just go on with the next client... */ if (np == NULL) continue; /* Move the client to the list for the node where the object resides. nid = pwr_cNNodeId is used for all objects we don't know. */ old_np = hash_Search(&sts, gdbroot->nid_ht, &cp->nid); if (old_np == NULL) errh_Bugcheck(GDH__WEIRD, ""); pool_Qremove(NULL, gdbroot->pool, &cp->subc_ll); old_np->subc_lc--; pool_QinsertPred(NULL, gdbroot->pool, &cp->subc_ll, &np->subc_lh); np->subc_lc++; cp->nid = np->nid; /* If the object's nid changed, then take the appropriate actions. */ if (np != old_np) { if (np->nid != pwr_cNNodeId) { /* Object is known. */ activateTimeoutWatch(cp); aep = tree_Insert(&sts, add, &np->nid); if (aep == NULL) errh_Bugcheck(GDH__WEIRD, ""); if (aep->msg == NULL) { aep->cnt = MIN(my_subc_lc, net_cSubMaxAdd); aep->msg = malloc(sizeof(net_sSubAdd) + sizeof(net_sSubSpec) * aep->cnt); aep->msg->count = 0; } /* If there was no message allocated */ specp = &aep->msg->spec[aep->msg->count]; specp->sid = cp->sid; specp->dt = cp->dt; specp->sub_by_name = cp->sub_by_name; specp->aref = cp->cclass != pool_cNRef ? cp->raref : cp->aref; if (++aep->msg->count >= aep->cnt) { /* The message buffer is full and must be sent. */ tgt = np->handler; pwr_Assert(tgt.nid != pwr_cNNodeId); gdb_Unlock; net_Put(NULL, &tgt, aep->msg, net_eMsg_subAdd, 0, pwr_Offset(aep->msg, spec[aep->msg->count]), 0); gdb_Lock; aep->msg->count = 0; } } else { /* The object became unknown... */ cancelTimeoutWatch(cp); subc_SetOld(cp); /* Data gets old immediately */ #if 0 /** @todo Maybe we should unlock the cached class? */ if (cp->cclass != pwr_cNRefId) { ccp = pool_Address(NULL, gdbroot->pool, cp->cclass); if (ccp == NULL) errh_Bugcheck(GDH__WEIRD, "Cached class address"); cmvolc_UnlockClass(NULL, ccp); cp->cclass = pwr_cNRefId; } #endif #if 0 if (old_np->nid != pwr_cNNodeId) { rep = tree_Insert(&sts, remove, &old_np->nid); if (rep == NULL) errh_Bugcheck(GDH__WEIRD, ""); if (rep->msg == NULL) { rep->nid = old_np->nid; rep->cnt = MIN(my_subc_lc, net_cSubMaxRemove); rep->msg = malloc(sizeof(net_sSubRemove) + sizeof(rep->msg->sid[0]) * rep->cnt); rep->msg->count = 0; } rep->msg->sid[rep->msg->count++] = cp->sid; if (rep->msg->count >= net_cSubMaxRemove) { np = hash_Search(&sts, gdbroot->nid_ht, &old_np->nid); if (np == NULL) errh_Bugcheck(sts, ""); tgt.nid = rep->nid; pwr_Assert(tgt.nid != pwr_cNNodeId); gdb_Unlock; net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0); gdb_Lock; rep->msg->count = 0; } } #endif } } } pool_Free(NULL, gdbroot->pool, my_lh); /* Now walk through the addmsg & remmsg and send all unsent messages. */ gdb_Unlock; #if 0 for (rep = tree_Minimum(remove); rep != NULL; rep = tree_Successor(remove, rep)) { if (rep->msg != NULL) { if (rep->msg->count > 0) { tgt.nid = rep->nid; pwr_Assert(tgt.nid != pwr_cNNodeId); net_Put(NULL, &tgt, rep->msg, net_eMsg_subRemove, 0, pwr_Offset(rep->msg, sid[rep->msg->count]), 0); } free(rep->msg); } } #endif for (aep = tree_Minimum(&sts, add); aep != NULL; aep = tree_Successor(&sts, add, aep)) { if (aep->msg != NULL) { if (aep->msg->count > 0) { np = hash_Search(&sts, gdbroot->nid_ht, &aep->nid); if (np == NULL) errh_Bugcheck(GDH__WEIRD, ""); tgt = np->handler; pwr_Assert(tgt.nid != pwr_cNNodeId); net_Put(NULL, &tgt, aep->msg, net_eMsg_subAdd, 0, pwr_Offset(aep->msg, spec[aep->msg->count]), 0); } free(aep->msg); } } gdb_Lock; tree_DeleteTable(&sts, add); #if 0 tree_DeleteTable(remove); #endif }
int main(int argc, char** argv) { char *ptr; Uint32 port = 0; String host = "localhost:5988"; String userName; String password; Boolean enumInst = true; Boolean enumInstNames = true; Boolean getInst = true; Boolean verboseTest = false; // check if have a "verbose" on the command line if (argv[1] != 0) { const char *arg = argv[1]; if ((strcmp(arg, "-verbose") == 0) || (strcmp(arg, "verbose") == 0)) verboseTest = true; } ptr = getenv("CIM_HOST"); if (ptr != NULL) host.assign(ptr); ptr = getenv("CIM_PORT"); if (ptr != NULL) port = atol(ptr); ptr = getenv("CIM_USER"); if (ptr != NULL) userName.assign(ptr); ptr = getenv("CIM_PASSWORD"); if (ptr != NULL) password.assign(ptr); // need to first connect to the CIMOM // use null string for user and password, port 5988 if (verboseTest) cout << "Starting NIS Client test" << endl; try { if (verboseTest) cout << "Create client" << endl; // specify the timeout value for the connection (if inactive) // in milliseconds, thus setting to one minute CIMClient client; client.setTimeout(60 * 1000); if (verboseTest) cout << "Client created" << endl; cout << "NISTestClient connecting to " << host << endl; if (port == 0) { // Connect to local host client.connectLocal(); } else { // Conect to remote host client.connect(host, port, userName, password); } cout << "NISTestClient Connected" << endl; NISTestClient testClient(client); if (enumInstNames) { testClient.testEnumerateInstanceNames(client, verboseTest); } if (enumInst) { testClient.testEnumerateInstances(client, verboseTest); } if (getInst) { testClient.testGetInstance(client, verboseTest); } cout << "NISTestClient disconnecting from CIMOM " << endl; client.disconnect(); } catch (Exception& e) { cout << "---- NIS Provider Test Failed " << e.getMessage() << endl; } return 0; }
int main(int argc, char** argv) { Boolean enumInst = true; Boolean enumInstNames = true; Boolean getInst = true; Boolean verboseTest = false; // check if have a "verbose" on the command line if (argv[1] != 0) { const char *arg = argv[1]; if ((strcmp(arg, "-verbose") == 0) || (strcmp(arg, "verbose") == 0)) verboseTest = true; } // need to first connect to the CIMOM // use null string for user and password, port 5988 if (verboseTest) cout << "Starting OS Client test" << endl; try { if (verboseTest) cout << "Create client" << endl; // specify the timeout value for the connection (if inactive) // in milliseconds, thus setting to one minute CIMClient client; client.setTimeout(60 * 1000); if (verboseTest) cout << "Client created" << endl; cout << "OSTestClient connecting via connectLocal() " << endl; client.connectLocal (); cout << "OSTestClient Connected" << endl; OSTestClient testClient(client); if (enumInstNames) { testClient.testEnumerateInstanceNames(client, verboseTest); } if (enumInst) { testClient.testEnumerateInstances(client, verboseTest); } if (getInst) { testClient.testGetInstance(client, verboseTest); } cout << "OSTestClient disconnecting from CIMOM " << endl; client.disconnect(); } catch(Exception& e) { cout << "---- OS Provider Test Failed " << e.getMessage() << endl; } return 0; }