// ------------------------- suite ------------------------------ Test *FileAccessControllerTests::suite() { StartTrace(FileAccessControllerTests.suite); TestSuite *testSuite = new TestSuite; ADD_CASE(testSuite, FileAccessControllerTests, FileUDACTest); ADD_CASE(testSuite, FileAccessControllerTests, FileTDACTest); ADD_CASE(testSuite, FileAccessControllerTests, FileEDACTest); return testSuite; }
void HTTPStringEncodeRenderer::RenderAll(std::ostream &reply, Context &ctx, const ROAnything &config) { StartTrace(HTTPStringEncodeRenderer.RenderAll); String str(32L); RenderOnString(str, ctx, config["String"]); Trace("encoded String: <" << str << ">"); // use MSUrlEncode function because it converts almost all reserved characters reply << coast::urlutils::MSUrlEncode(str); }
void GenericXMLParser::Store(Anything &cache, String &literal) { StartTrace(GenericXMLParser.Store); if (literal.Length() > 0) { cache.Append(Anything(literal)); literal = ""; } }
void UniqueIdGenTest::GetUniqueIdTest() { StartTrace(UniqueIdGenTest.GetUniqueIdTest); long iterations = 20000L; DoGetUniqueIdTest(iterations, ""); DoGetUniqueIdTest(iterations, "xxx"); }
long OptionListRenderer::EntryHeaderNrToBeRendered(Context &ctx, const ROAnything &config, Anything &anyRenderState) { StartTrace(OptionListRenderer.EntryHeaderNrToBeRendered); if ( config.IsDefined("OptionGroup") ) { return 0; } return -1; }
bool OptionListRenderer::GetEntryFooter(const ROAnything &config, ROAnything &roaEntryFooter, Anything &anyRenderState) { StartTrace(OptionListRenderer.GetEntryFooter); if ( config.LookupPath(roaEntryFooter, "OptionGroup") ) { TraceAny(roaEntryFooter, "using following optiongroup config"); } return !roaEntryFooter.IsNull(); }
int GenericXMLParser::Peek() { StartTrace(GenericXMLParser.Peek); if (fReader && !fReader->eof()) { return fReader->peek(); } return 0; }
void HandleRequest::DoWorkingHook(ROAnything workloadArgs) { StartTrace(HandleRequest.DoWorkingHook); // request specific setup fClientSocket = (Socket *)workloadArgs["socket"].AsIFAObject(0); fRequestNumber = workloadArgs["request"].AsLong(-1); TraceAny(workloadArgs, "my working arguments for request " << fRequestNumber); }
void HandleRequest::DoInit(ROAnything workerInit) { StartTrace(HandleRequest.DoInit); // request independant setup fProcessor = SafeCast(workerInit["processor"].AsIFAObject(0), RequestProcessor); fClientSocket = 0; fRequestNumber = 0; }
bool HTTPBodyResultMapper::DoFinalPutStream(const char *key, std::istream &is, Context &ctx) { StartTrace(HTTPBodyResultMapper.DoFinalPutStream); DAAccessTimer(HTTPBodyResultMapper.DoFinalPutStream, "", ctx); String body; ReadBody(body, is, ctx); Anything anyVal(body); return DoFinalPutAny(key, anyVal, ctx); }
bool SelectBoxRenderer::IsMultipleSelect(Context &context, const ROAnything &config) { StartTrace(SelectBoxRenderer.IsMultipleSelect); String str; if (config.IsDefined("Multiple")) { RenderOnString(str, context, config["Multiple"]); } return (str.AsLong(0L) == 1L); }
WorkerThread *RequestThreadsManager::DoGetWorker(long i) { StartTrace(RequestThreadsManager.DoGetWorker); // concrete subclass needs to determine the object ptr if (fRequests) { return &(fRequests[i]); } return 0; }
bool FlowController::PrepareRequest(Context &ctx) { StartTrace(FlowController.PrepareRequest); long reqNr = GetRequestNr(ctx); // number of runs of pre depends on number of slots in anything long nrOfPreRunRequests = fConfig["PreRun"].GetSize(); Anything tmpStore = ctx.GetTmpStore(); Anything flowState = tmpStore["FlowState"]; if (!flowState["PreRunDone"].AsBool(1)) { Trace("PRE RUN NOT DONE "); if (reqNr < nrOfPreRunRequests) { DoPrepare(tmpStore, fConfig["PreRun"][reqNr]); flowState["RequestNr"] = ++reqNr; TraceAny(tmpStore["FlowState"], "Flow State on exit"); return true; } else { // PreRun done , reset for normal run reqNr = 0; flowState["RunNr"] = 0L; flowState["PreRunDone"] = true; } } long nrOfRuns = 0; String appName; Application *application = Application::GetGlobalApplication(appName); if (application) { nrOfRuns = application->Lookup("NumberOfRuns", fConfig["NumberOfRuns"].AsLong(1)); Trace(appName << " application found" ); } else { nrOfRuns = fConfig["NumberOfRuns"].AsLong(1); } long runNr = flowState["RunNr"].AsLong(0); Trace("INIT Number of Run: " << runNr << " of " << nrOfRuns); while (runNr < nrOfRuns) { // loop thru steps and incr. runNr after each batch has been processed Trace("Number of Run: " << runNr << " of " << nrOfRuns); TraceAny(fConfig["Run"], "Config Run"); long nrOfRequests = fConfig["Run"].GetSize(); if (reqNr < nrOfRequests) { DoPrepare(tmpStore, fConfig["Run"][reqNr]); flowState["RequestNr"] = ++reqNr; TraceAny(tmpStore, "tmpStore on exit"); TraceAny(tmpStore["FlowState"], "Flow State on exit"); return true; } reqNr = 0; // reset request number flowState["RunNr"] = ++runNr; } TraceAny(tmpStore["FlowState"], "Flow State on exit with false"); return false; }
bool FlowControllersModule::Init(const ROAnything config) { StartTrace(FlowControllersModule.Init); TraceAny(config["FlowControllers"], " Config "); if (config.IsDefined("FlowControllers")) { AliasInstaller ai("FlowController"); return RegisterableObject::Install(config["FlowControllers"], "FlowController", &ai); } return false; }
// builds up a suite of testcases, add a line for each testmethod Test *STLStorageTest::suite () { StartTrace(STLStorageTest.suite); TestSuite *testSuite = new TestSuite; ADD_CASE(testSuite, STLStorageTest, GlobalStorageTest); ADD_CASE(testSuite, STLStorageTest, PoolStorageTest); ADD_CASE(testSuite, STLStorageTest, AllocatorUsingSMartPtrTest); return testSuite; }
void LDAPConnectionTest::ConnectionTest() { StartTrace(LDAPConnectionTest.ConnectionTest); ROAnything cConfig; AnyExtensions::Iterator<ROAnything> aEntryIterator(GetTestCaseConfig()); while ( aEntryIterator.Next(cConfig) ) { for ( long l = 0; l < cConfig["NumberOfConnects"].AsLong(1); l++ ) { Anything params; params["Server"] = cConfig["LDAPServer"].AsString(); params["Port"] = cConfig["LDAPPort"].AsLong(); params["Timeout"] = cConfig["LDAPTimeout"].AsLong(); params["ConnectionTimeout"] = cConfig["LDAPConnectionTimeout"].AsLong(0); params["BindName"] = cConfig["LDAPBindName"].AsString(); params["BindPW"] = cConfig["LDAPBindPW"].AsString(); params["PooledConnections"] = cConfig["LDAPPooledConnections"].AsLong(0L); params["RebindTimeout"] = cConfig["LDAPRebindTimeout"].AsLong(3600L); params["TryAutoRebind"] = cConfig["LDAPTryAutoRebind"].AsLong(0L); params["MaxConnections"] = cConfig["LDAPMaxConnections"].AsLong(2L); Context ctx; ParameterMapper pm("ConnectionTestParameterMapper"); ResultMapper rm("ConnectionTestResultMapper"); pm.Initialize("ParameterMapper"); rm.Initialize("ResultMapper"); String da("DataAccess_"); da << aEntryIterator.Index(); LDAPErrorHandler eh(ctx, &pm, &rm, da); eh.PutConnectionParams(params); // connect LDAPConnection lc(params); LDAPConnection::EConnectState eConnectState = lc.DoConnect(params, eh); String result(LDAPConnection::ConnectRetToString(eConnectState)); Trace("Connect result: " << result); // check for errors Anything error; if ( !eh.GetError(error) ) { Trace("No error reported."); } else { TraceAny(error, "Error description:"); } // compare result and expected error assertEqual(cConfig["ConnectRet"].AsString(), result); bool ret = LDAPConnection::IsConnectOk(eConnectState); assertEqual(cConfig["ConnectIsOk"].AsBool(1), ret); if (!ret) { String where; aEntryIterator.SlotName(where); assertAnyCompareEqual(cConfig["Error"], error, String(getConfigFileName()) << ":" << where, '.',':'); } // now release sema and lock lc.ReleaseHandleInfo(); } } }
Anything GenericXMLParser::ParseComment() { StartTrace(GenericXMLParser.ParseComment); int c; // keep comments for test cases relying on them String comment; #define GSR ((c = Get()),comment.Append(char(c))) c = Get(); if (c == '-') { c = Get(); if (c == '-') { // now we are inside a comment // skip whitespace for (;;) { GSR; if (!isspace( (unsigned char) c)) { break; } } // skip comment for (;;) { if (c == EOF || c == 0) { break; } if (c == '-') { GSR; if (c == '-') { GSR; while ( c == '-' ) { GSR; } if (c == '>') { // end of comment break; } } } GSR; } comment.Trim(comment.Length() - 3); // cut --> Anything result; result["!--"] = comment; // /"!--" marks the comment return result; } } String msg("Unexpected character or EOF in Comment: "); msg.Append((char)c); Error(msg); if ('>' != c) { comment.Append(SkipToClosingAngleBracket()); } Anything result; result["!--"] = comment; return result; }
// builds up a suite of testcases, add a line for each testmethod Test *WorkerPoolManagerTest::suite() { StartTrace(WorkerPoolManagerTest.suite); TestSuite *testSuite = new TestSuite; ADD_CASE(testSuite, WorkerPoolManagerTest, InitTest); ADD_CASE(testSuite, WorkerPoolManagerTest, EnterLeaveTests); return testSuite; }
void DecimalFormatRenderer::InsertFiller(String &sScale, String &strDecPlaces ) { StartTrace(DecimalFormatRenderer.InsertFiller); for ( long lIdx = strDecPlaces.Length(); lIdx < sScale.AsLong(0L) ; lIdx++) { strDecPlaces.Append("0"); Trace("scale [ " << strDecPlaces << "] index [ " << lIdx << " ]"); } }
void InterruptHandler::Run() { StartTrace(InterruptHandler.Run); // the just wait for the signal to happen Trace("Thread: " << Thread::MyId()); Trace("Pid: " << (long)coast::system::getpid()); Trace("Server [" << (fServer ? (const char *)(fServer->fName) : "no-name") << "]"); if ( fServer ) { fServer->WritePIDFile(coast::system::getpid()); } sigset_t set; int isignal; // setup the signal set that catches control-c sigemptyset(&set); sigaddset(&set, SIGINT); sigaddset(&set, SIGTERM); sigaddset(&set, SIGHUP); handlesignal: SetWorking(); Trace("calling sigwait"); sigwait(&set, &isignal); SetReady(); Trace("got signal: " << (long)isignal); if (fServer) { String sigName; sigName << (long)isignal; if ( isignal == SIGHUP ) { SYSINFO("caught SIGHUP, resetting server"); int retVal = fServer->GlobalReinit(); if ( retVal == 0 ) { // everything ok, wait on next signal goto handlesignal; } sigName = "SIGHUP"; // shutdown if any mishap happens SYSERROR("GlobalReinit failed, shutting down..."); } else if ( isignal == SIGINT ) { sigName = "SIGINT"; } else if ( isignal == SIGTERM ) { sigName = "SIGTERM"; } else { SYSINFO("caught unknown signal " << sigName << " ...ignoring!"); goto handlesignal; } SYSINFO("caught " << sigName << " shutting down server"); // prepare the server for shutdown // by causing him to leave the accept-loop fServer->PrepareShutdown(); } // the job is done, just die... }
ETW::Status ETW::Start() { if (!isActive) { ULONG bufferSize = sizeof(EVENT_TRACE_PROPERTIES) + sizeof(KERNEL_LOGGER_NAME); ZeroMemory(sessionProperties, bufferSize); sessionProperties->Wnode.BufferSize = bufferSize; sessionProperties->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES); sessionProperties->EnableFlags = EVENT_TRACE_FLAG_CSWITCH; sessionProperties->LogFileMode = EVENT_TRACE_REAL_TIME_MODE; sessionProperties->Wnode.Flags = WNODE_FLAG_TRACED_GUID; sessionProperties->Wnode.ClientContext = 1; sessionProperties->Wnode.Guid = SystemTraceControlGuid; // ERROR_BAD_LENGTH(24): The Wnode.BufferSize member of Properties specifies an incorrect size. Properties does not have sufficient space allocated to hold a copy of SessionName. // ERROR_ALREADY_EXISTS(183): A session with the same name or GUID is already running. // ERROR_ACCESS_DENIED(5): Only users with administrative privileges, users in the Performance Log Users group, and services running as LocalSystem, LocalService, NetworkService can control event tracing sessions. // ERROR_INVALID_PARAMETER(87) // ERROR_BAD_PATHNAME(161) // ERROR_DISK_FULL(112) ULONG status = StartTrace(&sessionHandle, KERNEL_LOGGER_NAME, sessionProperties); if (status != ERROR_SUCCESS) { switch (status) { case ERROR_ALREADY_EXISTS: return ETW_ERROR_ALREADY_EXISTS; case ERROR_ACCESS_DENIED: return ETW_ERROR_ACCESS_DENIED; default: return ETW_FAILED; } } ZeroMemory(&logFile, sizeof(EVENT_TRACE_LOGFILE)); logFile.LoggerName = KERNEL_LOGGER_NAME; logFile.ProcessTraceMode = (PROCESS_TRACE_MODE_REAL_TIME | PROCESS_TRACE_MODE_EVENT_RECORD | PROCESS_TRACE_MODE_RAW_TIMESTAMP); logFile.EventRecordCallback = OnRecordEvent; openedHandle = OpenTrace(&logFile); if (openedHandle == INVALID_TRACEHANDLE) return ETW_FAILED; DWORD threadID; processThreadHandle = CreateThread(0, 0, RunProcessTraceThreadFunction, this, 0, &threadID); isActive = true; } return ETW_OK; }
void StresserThread::DoTerminatedHook() { StartTrace(StresserThread.DoTerminatedHook); // synchronize with main thread (StressApp) LockUnlockEntry me(*fMutex); (*fPending)--; // give StressApp the opportunity to check if this is // the last thread it is waiting for.. fCond->Signal(); }
String GenericXMLParser::SkipToClosingAngleBracket() { StartTrace(GenericXMLParser.SkipToClosingAngleBracket); int c; String result; while ((c = Get()) != 0 && c != '>' && c != EOF) { result.Append(char(c)); } return result; }
void GenericXMLParser::PutBack(char c) { StartTrace(GenericXMLParser.PutBack); if (fReader) { fReader->putback(c); } if ('\n' == c) { --fLine; } }
bool SybCTnewDAImpl::DoPrepareSQL( String &command, Context &ctx, ParameterMapper *in) { StartTrace(SybCTnewDAImpl.DoPrepareSQL); DAAccessTimer(SybCTnewDAImpl.DoPrepareSQL, fName, ctx); OStringStream os(command); in->Get("SQL", os, ctx); os.flush(); SubTrace (Query, "QUERY IS [" << command << "]"); return (command.Length() > 0L); }
String GenericXMLParser::ParseToSemicolon() { StartTrace(GenericXMLParser.ParseToSemicolon); String value; int c; while (!IsEof() && ';' != (c = Get())) { value.Append(char(c)); } return value; }
OracleConnection::~OracleConnection() { StartTrace(OracleConnection.~OracleConnection); Close(); fSrvhp.reset(); fSvchp.reset(); fErrhp.reset(); fUsrhp.reset(); fStatus = eUnitialized; }
void LeaderFollowerPoolTest::NoAcceptorsTest() { StartTrace(LeaderFollowerPoolTest.NoAcceptorsTest); LeaderFollowerPool lfp(new TestReactor(this)); Anything lfpConfig; if (t_assertm( !lfp.Init(2, lfpConfig), "no acceptors are configured; init should fail")) { t_assertm(lfp.GetPoolSize() == 0, "expected no threads in pool"); t_assertm(lfp.Start(true, 1000, 11) == -1, "expected Start to fail"); } }
void ServerTest::setUp() { StartTrace(ServerTest.setUp); t_assert(GetConfig().IsDefined("Modules")); Server *s; if (t_assert((s = Server::FindServer("Server")) != NULL)) { ROAnything result; t_assert(s->Lookup("TCP5010", result)); TraceAny(result, "server lookup TCP5010"); } }
void HTMLTemplateRenderer::BuildCache(const ROAnything config) { StartTrace(HTMLTemplateRenderer.BuildCache); HTMLTemplateCacheBuilder htcb; htcb.BuildCache(config); fgTemplates = CacheHandler::instance().GetGroup("HTML"); TraceAny(fgTemplates, "Cache Templates"); fgNameMap = CacheHandler::instance().Get("HTMLMappings", "HTMLTemplNameMap"); TraceAny(fgNameMap, "Cache Map"); }