void CWindowGroupListBoxData::DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& /*itemId*/) { SWgInfo& info = *reinterpret_cast<SWgInfo*>(aInfo); CApaWindowGroupName* wgName = info.iName; name.Copy(wgName->Caption()); _LIT(KUnnamed, "<Untitled window group>"); if (name.Length() == 0) name.Copy(KUnnamed); TThreadId tid; TInt res = info.iSession->GetWindowGroupClientThreadId(info.iHandle, tid); if (res == KErrNone) { res = tid; } more.Format(_L("Busy=%i System=%i Tid=%i"), wgName->IsBusy(), wgName->IsSystem(), res); }
void CWindowGroupListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* name) { SWgInfo& info = *reinterpret_cast<SWgInfo*>(iInfo); _LIT(KInfo, "Window group info"); aTitle.Copy(KInfo); CApaWindowGroupName* wg = info.iName; *name = wg->WindowGroupName(); PrettyName(EListWindowGroups, *name); inf.Append(*name); TThreadId tid; TInt res = info.iSession->GetWindowGroupClientThreadId(info.iHandle, tid); inf.AppendFormat(_L("\n\nOwner thread: %i"), res == KErrNone ? (TInt)tid : res); RThread thread; if (res == KErrNone) { res = thread.Open(tid); } if (res == KErrNone) { *name = thread.FullName(); PrettyName(EListThread, *name); inf.AppendFormat(_L(" (%S)"), name); } inf.AppendFormat(_L("\nBusy=%i System=%i Hidden=%i"), wg->IsBusy(), wg->IsSystem(), wg->Hidden()); }
void CFeatRegListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* /*name*/) { SFeature& info = *reinterpret_cast<SFeature*>(iInfo); _LIT(KInfo, "Feature info"); aTitle.Copy(KInfo); gPlugin->FormatValue(inf, MProductPlugin::EFeature, info.iFeature, 0); _LIT(KFeatureFmt, "\n0x%x\n\nFeature present: %i\n(Additional info: %i)"); inf.AppendFormat(KFeatureFmt, info.iFeature, info.iErr, info.iInfo); }
void CVideoEntry::GenerateThumbnailFileL( const TDesC& aCacheDirectory ) { delete iThumbnailFile; RBuf path; CleanupClosePushL( path ); path.Create( aCacheDirectory.Length() + iVideoId->Length() + KCacheFileExtension().Length() ); path.Copy( aCacheDirectory ); path.Append( *iVideoId ); path.Append( KCacheFileExtension() ); iThumbnailFile = path.AllocL(); CleanupStack::PopAndDestroy( &path ); }
void CTestRControlChannel::SavePreviousLogFileL() { _LIT(KInfoLogFile, "Saving Previous logs If any.... \n"); INFO_PRINTF1(KInfoLogFile); RFs fileserv; TInt error = fileserv.Connect(); if(!error) { _LIT(KlogFile, "C:\\logs\\log.txt"); _LIT(KPrefixLog, "C:\\logs\\"); _LIT(KSuffix, "_UDEB"); _LIT(KExtn, ".txt"); CFileMan* fMan = NULL; TRAP_IGNORE(fMan = CFileMan::NewL(fileserv)); if(fMan != NULL) { CleanupStack::PushL(fMan); RBuf newFileName; const TInt KTwenty = 20; newFileName.Create(ConfigSection().Length() + KTwenty ); newFileName.Copy(KPrefixLog); //Script file name iScriptName.Copy(ConfigSection()); newFileName.Append(iScriptName); newFileName.Append(KSuffix); newFileName.Append(KExtn); TInt error = fMan->Rename(KlogFile, newFileName); if (error != KErrNone) { _LIT(KErrInfo, "Unable to Save Previous logs...May be NO Previous logs exist \n"); ERR_PRINTF1(KErrInfo); } else { _LIT(KSavingInfo, "Saved Previous logs with File Name: %S \n"); INFO_PRINTF2(KSavingInfo, &newFileName); } CleanupStack::PopAndDestroy(fMan); newFileName.Close(); } } fileserv.Close(); _LIT(KInfoLogFile1, "Saving Previous logs End.... \n"); INFO_PRINTF1(KInfoLogFile1); }
void CScrHelperSession::GetFileHandleL(RFs& aFs, const RMessage2& aMessage, const TDesC& aFileName) { DEBUG_PRINTF2(_L("Returning file handle of %S."), &aFileName); RBuf filePath; filePath.CreateL(aFileName.Length()); filePath.CleanupClosePushL(); filePath.Copy(aFileName); filePath[0] = aFs.GetSystemDriveChar(); TInt err = aFs.MkDirAll(filePath); if(KErrNone != err && KErrAlreadyExists != err) { DEBUG_PRINTF3(_L("An error (%d) occured while making all directories of %S."), err, &filePath); User::Leave(err); } RFile file; TEntry entry; if(KErrNone == aFs.Entry(filePath, entry)) { // The file exists, just open it. User::LeaveIfError(file.Open(aFs, filePath, EFileShareAny|EFileWrite)); } else { // The file doesn't exist. First, check if the requested file is database or journal file. if(KScrDatabaseFilePath() == aFileName) { // This is the database file. Copy the default one into the requested location. DEBUG_PRINTF(_L8("SCR database file doesn't exist. It is being copied from ROM")); CopyDbFromROMToSystemL(aFs, filePath); // Then, open the file. User::LeaveIfError(file.Open(aFs, filePath, EFileShareAny|EFileWrite)); } else { // This is the journal file, simply create an empty file. User::LeaveIfError(file.Create(aFs, filePath, EFileShareAny|EFileWrite)); } } CleanupStack::PopAndDestroy(&filePath); CleanupClosePushL(file); // Store the RFile handle into the package buffer in slot 0 and complete the message with the RFs handle User::LeaveIfError(file.TransferToClient(aMessage, 0)); ASSERT(aMessage.IsNull()); // The message should have been completed CleanupStack::PopAndDestroy(&file); }
void CIoReadTest::ReadFileL() { RFile file; LeaveIfErr(file.Open(Fs(), iFile, EFileRead | EFileShareExclusive), _L("Cannot open file '%S'"), &iFile); CleanupClosePushL(file); TInt fileSize; User::LeaveIfError(file.Size(fileSize)); RBuf8 contents; contents.CreateL(fileSize); CleanupClosePushL(contents); User::LeaveIfError(file.Read(contents)); // convert data to 16-bit which is how it'll come out of the io server iFileContents.CreateL(fileSize); iFileContents.Copy(contents); // copy & expand CleanupStack::PopAndDestroy(2, &file); // contents, file }
CDecisionRecord* CDatabase::ParseAndCreateRecordLC(TDesC8& aLine) /** Parse a line and create a decision record from the parsed values @param aLine A line containing a decision record values quoted with double quotes and separated by semi-colon @return A newly created decision record */ { CDecisionRecord* record = NULL; TLex8 parser(aLine); TChar achar; TBool start = ETrue; TUint16 flag = 0x078F; TUint16 pos = 0x0001; TInt32 value=0; TUint32 hexVal = 0; TSecureId clientSid(0); TSecureId serverSid(0); TUid serviceId = TUid::Null(); TUid evaluatorId = TUid::Null(); TBuf8<KUpsMaxFingerprintLength*2> fingerprint; TBuf8<KUpsMaxClientEntityLength*2> clientEntity; RBuf description; TUint8 result=0; TUint32 evaluatorInfo=0; TUint16 policyVer=0; TUint32 recordId=0; while(!parser.Eos()) { //Get cyrrent char achar = parser.Get(); //Skip delimiter if(achar == ';') { start = ETrue; } //if double quote start or stop token reading if('\"' == achar) { if(start) { parser.Mark(); start = EFalse; } else { parser.UnGet(); if(flag & pos) { TLex8 intToken(parser.MarkedToken()); switch(pos) { case KLocClientSid: intToken.Val(hexVal,EHex); clientSid.iId = hexVal; break; case KLocEvaluatorId: intToken.Val(hexVal,EHex); evaluatorId.iUid = hexVal; break; case KLocServiceId: intToken.Val(hexVal,EHex); serviceId.iUid = hexVal; break; case KLocServerSid: intToken.Val(hexVal,EHex); serverSid.iId = hexVal; break; case KLocResult: intToken.Val(value); result = (TUint8)value; break; case KLocEvaluatorInfo: intToken.Val(value); evaluatorInfo = value; break; case KLocMajorPolicyVersion: intToken.Val(value); policyVer = (TUint16)value; break; case KLocRecordId: intToken.Val(value); recordId = (TUint32)value; break; default: User::Leave(KErrGeneral); } } else { switch(pos) { case KLocDescription: { TPtrC8 tmpDescription = parser.MarkedToken(); description.Create(tmpDescription.Length()); description.CleanupClosePushL(); description.Copy(tmpDescription); break; } case KLocFingerprint: { fingerprint = parser.MarkedToken(); HexToStrL(fingerprint); break; } case KLocClientEntity: { clientEntity = parser.MarkedToken(); if(!(iFlag & EPrintBinary)) { HexToStrL(clientEntity); } break; } default: User::Leave(KErrGeneral); } } start = ETrue; pos = pos<<1; } } } record = CDecisionRecord::NewL(clientSid,evaluatorId,serviceId,serverSid,fingerprint,clientEntity,description,result,policyVer,evaluatorInfo,recordId); CleanupStack::PopAndDestroy(&description); CleanupStack::PushL(record); return record; }
TVerdict CWriteStringStep::doTestStepL() /** * @return - TVerdict code * Override of base class pure virtual * Our implementation only gets called if the base class doTestStepPreambleL() did * not leave. That being the case, the current test result value will be EPass. */ { INFO_PRINTF1(_L("This step tests WriteStringToConfig function.")); SetTestStepResult(EFail); TPtrC originalValue; TBool ret = EFalse; if(!GetStringFromConfig(ConfigSection(),KTe_RegStepTestSuiteString, originalValue)) { // Leave if there's any error. User::Leave(KErrNotFound); } INFO_PRINTF2(_L("The Original String is %S"), &originalValue); // Block end RBuf buf; buf.Create(originalValue.Length()); buf.Copy(originalValue); _LIT(KText,"GoodBye Jason"); TBufC<16> buf1(KText); TPtrC TheString1(buf1); if (WriteStringToConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString1)) { if (GetStringFromConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString1) && 0==TheString1.Compare(KText())) { INFO_PRINTF2(_L("Changed String To %S"),&TheString1); ret = ETrue; } } _LIT(KText2,"Hello Jason"); TBufC<16> buf2(KText2); TPtrC TheString2(buf2); if (WriteStringToConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString2)) { if (GetStringFromConfig(ConfigSection(), KTe_RegStepTestSuiteString, TheString2) && 0==TheString2.Compare(KText2())) { INFO_PRINTF2(_L("Changed String To %S"), &TheString2); } } else { ret = EFalse; } if (!WriteStringToConfig(ConfigSection(), KTe_RegStepTestSuiteString, buf)) { ret = EFalse; } buf.Close(); if (ret) { SetTestStepResult(EPass); } return TestStepResult(); }
/** * Reads test configuration data from ini file * Leaves if expected data not found */ TVerdict CWServTestStep::doTestStepPreambleL() { TVerdict ret=CTestStep::doTestStepPreambleL(); if (!GetIntFromConfig(KDefaultSectionName, KT_WservStressInit, iData.initPeriod)|| !GetIntFromConfig(KDefaultSectionName, KT_WservStressPeriod, iData.period)|| !GetIntFromConfig(KDefaultSectionName, KT_WservStressMaxRunCycles, iData.maxRunCycles)) { INFO_PRINTF1(_L("Error reading ini file")); User::Leave(KErrNotFound); } //random_seed is not a mandatory parameter iData.randomSeed = -1; TPtrC strSeed; GetStringFromConfig(KDefaultSectionName, KT_WservStressRandomSeed, strSeed); if (strSeed.Ptr()) { TLex seed; seed.Assign(strSeed); seed.Val(iData.randomSeed); } iData.minNumWindows = 0; //unlimited GetIntFromConfig(KDefaultSectionName, KT_WservStressMinNumWindows, iData.minNumWindows); iData.windowWidth = 400; GetIntFromConfig(KDefaultSectionName, KT_WservStressWindowWidth, iData.windowWidth); iData.windowHeight = 400; GetIntFromConfig(KDefaultSectionName, KT_WservStressWindowHeight, iData.windowHeight); iData.compareBitmaps = ETrue; GetBoolFromConfig(KDefaultSectionName, KT_WservStressCompareBitmaps, iData.compareBitmaps); iData.saveOnlyDifferent = ETrue; GetBoolFromConfig(KDefaultSectionName, KT_WservStressSaveOnlyDifferent, iData.saveOnlyDifferent); iData.saveDifferenceBitmap = EFalse; GetBoolFromConfig(KDefaultSectionName, KT_WservStressSaveDifferenceBitmap, iData.saveDifferenceBitmap); iData.clearAllBackground = ETrue; GetBoolFromConfig(KDefaultSectionName, KT_WservStressClearAllBackground, iData.clearAllBackground); TPtrC path; GetStringFromConfig(KDefaultSectionName, KT_WservStressLoggingPath, path); RBuf loggingPath; loggingPath.CleanupClosePushL(); loggingPath.CreateL(path.Length() + 16); if (path.Length()) { loggingPath.Copy(path); if (path[path.Length()-1] != '\\') { loggingPath.Append('\\'); } } else { loggingPath = _L("C:\\StressLog\\"); } iData.loggingPath = loggingPath; CleanupStack::PopAndDestroy(&loggingPath); return ret; }
/** * Read command line parameters and control the launching of the agents. */ void MainL() { LOG_MSG( "ENTER: t_multi_agent_launcher MainL()"); TInt ret = KErrNone; TInt numAgents = KNumAgents; TInt numTargets = KNumTargets; TInt numTestRuns = KNumTestRuns; TInt argc = User::CommandLineLength(); HBufC* commandLine = NULL; LOG_MSG2("t_multi_agent_launcher: MainL(): argc=%d", argc); if(argc) { commandLine = HBufC::NewLC(argc); TPtr commandLineBuffer = commandLine->Des(); User::CommandLine(commandLineBuffer); RBuf printCommandLine; CleanupClosePushL( printCommandLine ); printCommandLine.CreateL( commandLine->Des().Length() ); printCommandLine.Copy( commandLine->Des() ); printCommandLine.Collapse(); LOG_MSG2("t_multi_agent_launcher: command line = %S", &printCommandLine); CleanupStack::PopAndDestroy( &printCommandLine ); // create a lexer and read through the command line TLex lex(*commandLine); while (!lex.Eos()) { // only look for options with first character '-' if (lex.Get() == '-') { TChar arg = lex.Get(); switch ( arg ) { case 'n': lex.Val( numAgents ); LOG_MSG2("t_multi_agent_launcher: parsed numAgents as %d", numAgents); break; case 'm': lex.Val( numTargets ); LOG_MSG2("t_multi_agent_launcher: parsed numTargets as %d", numTargets); break; case 't': lex.Val( numTestRuns ); LOG_MSG2("t_multi_agent_launcher: parsed numTestRuns as %d", numTestRuns); break; default: LOG_MSG("t_multi_agent_launcher: unknown argument ignoring it"); break; } } } } // Note: below is a workaround to overcome an issue with RTest server crashing // when writing to the windows console from different agents (on different CPUs // at the same time). To overcome this we get signaled by the agents when they have // completed their tests so that we can do a RTest complete RSemaphore launchSemaphore; CleanupClosePushL(launchSemaphore); ret = launchSemaphore.CreateGlobal(KLaunchSemaphoreName, 0); LOG_MSG2( ">Target Launcher : RSemaphore.CreateGlobal ret %d", ret); User::LeaveIfError( ret ); ret = launchSemaphore.OpenGlobal(KLaunchSemaphoreName); LOG_MSG2( ">Target Launcher : RSemaphore.OpenGlobal ret %d", ret); User::LeaveIfError( ret ); //Now launch the requested number of apps for the requested number of test runs for( TInt j = 0; j < numTestRuns; j++ ) { for( TInt i = 0; i < numAgents; i++ ) { RBuf targetName; targetName.CleanupClosePushL(); targetName.CreateL(KAgentExe()); RProcess aProc; CleanupClosePushL(aProc); RBuf launcherOptions; CleanupClosePushL(launcherOptions); const TInt additionalWords = 2; launcherOptions.CreateL( KAgentOptions().Length() + additionalWords ); // Apply offset: launcherOptions.Format( .., .., i * numTargets, ..) // workaround to ensure we have the same binary for multiple agents. // e.g. So if offset = 0, agent attaches to app1, app2, app3, app4, app5 // if offset = 5, agent attached to app6, app7, app8, app9, app10 etc. // Note: apps need to be in rom otherwise the agent will fail on an assert // (with KErrNotFound) launcherOptions.Format( KAgentOptions(), (TUint)numTargets, i * numTargets, 0); ret = LaunchProcess( aProc, targetName, launcherOptions ); CleanupStack::PopAndDestroy(3,&targetName); User::LeaveIfError(ret); } } // Wait for all agents to do their testing before checking the semaphore User::After(12000000); LOG_MSG( ">Target Launcher: Semaphore wait"); for (TInt i = 0; i < numAgents; i ++) { //We need this delay just in case an agent crashes and never signals the sem ret = launchSemaphore.Wait(100000); if( ret != KErrNone ) { LOG_MSG3("launchSemaphore.Wait ret %d for agent %d", ret, i); break; } } LOG_MSG2( "testing for Semaphore ret %d", ret); // We only want to have one RTest instance at any one time since otherwise RTest can panic RTest test(_L("T_MULTI_AGENT_LAUNCHER")); test.Start(_L("t_multi_agent_launcher Check for agents finishing correctly")); test(ret == KErrNone); test.End(); test.Close(); CleanupStack::PopAndDestroy(&launchSemaphore); // launchSemaphore if( commandLine ) CleanupStack::PopAndDestroy(commandLine); LOG_MSG("EXIT: t_multi_agent_launcher MainL()"); }
/** * Read command line parameters and control the launching of targets. * Create global launch semaphore KLaunchSemaphoreName */ void MainL() { TInt numApps = KNumApps; TInt numLaunches = KNumLaunches; TInt launchControl = 0; TInt argc = User::CommandLineLength(); HBufC* commandLine = NULL; RDebug::Printf( ">Launcher Process() argc=%d", argc ); if( argc ) { commandLine = HBufC::NewLC(argc); TPtr commandLineBuffer = commandLine->Des(); User::CommandLine(commandLineBuffer); RBuf printCommandLine; CleanupClosePushL( printCommandLine ); printCommandLine.CreateL( commandLine->Des().Length() ); printCommandLine.Copy( commandLine->Des() ); printCommandLine.Collapse(); RDebug::Printf( ">command line = %S", &printCommandLine ); CleanupStack::PopAndDestroy( &printCommandLine ); // create a lexer and read through the command line TLex lex(*commandLine); while (!lex.Eos()) { // only look for options with first character '+', other switches are for the targets if (lex.Get() == '+') { TChar arg = lex.Get(); switch (arg) { case 'n': lex.Val( numApps ); RDebug::Printf("parsed numApps as %d", numApps); break; case 'm': lex.Val( numLaunches ); RDebug::Printf("parsed numLaunches as %d", numLaunches ); break; case 'o': lex.Val( launchControl ); RDebug::Printf("parsed launchControl as %d", launchControl); break; default: // unknown argument ignore it break; }//switch }// if + }//while }//if argc RSemaphore launchSemaphore; TInt ret = KErrNone; CleanupClosePushL( launchSemaphore ); ret = launchSemaphore.CreateGlobal( KLaunchSemaphoreName, 0 ); RDebug::Printf( ">Target Launcher : RSemaphore.CreateGlobal ret %d", ret); User::LeaveIfError( ret ); ret = launchSemaphore.OpenGlobal( KLaunchSemaphoreName ); RDebug::Printf( ">Target Launcher : RSemaphore.OpenGlobal ret %d", ret); User::LeaveIfError( ret ); //Only now indicate to the launcher that we have fully started, so they can find and open the semaphore RProcess::Rendezvous(KErrNone); //Now launch the requested number of apps for the requested number of launches for( ; numLaunches > 0; numLaunches-- ) { for( TInt launchIndex = numApps; launchIndex > 0; launchIndex-- ) { RDebug::Printf( ">Target Launcher: Semaphore wait app %d, launch %d", launchIndex, numLaunches ); launchSemaphore.Wait(); RBuf targetName; CleanupClosePushL( targetName ); RDebug::Printf( ">Target Launcher: targetName.Create %d, launch %d", launchIndex, numLaunches ); targetName.Create( KTargetExe().Length() + 2 ); if( launchControl == 1 ) { // Reverse the order of the apps launched by reversing the index in the name RDebug::Printf( ">Target Launcher: targetName.Format %d, launch %d", numApps - launchIndex + 1, numLaunches ); targetName.Format( KTargetExe(), numApps - launchIndex + 1 ); } else { RDebug::Printf( ">Target Launcher: targetName.Format %d, launch %d", launchIndex, numLaunches ); targetName.Format( KTargetExe(), launchIndex ); } RProcess aProc; CleanupClosePushL( aProc ); RDebug::Printf( ">Target Launcher: LaunchProcess %d, launch %d", launchIndex, numLaunches ); RDebug::Printf( ">LaunchProcess %lS", &targetName ); TPtr cmdLinePtr( commandLine->Des() ); ret = LaunchProcess( aProc, targetName, cmdLinePtr ); CleanupStack::PopAndDestroy( &aProc ); RDebug::Printf( "<Target Launcher: LaunchProcess returned %d", ret ); CleanupStack::PopAndDestroy( &targetName ); User::LeaveIfError( ret ); //By now the add proc event should have been delivered to the //test app agent. } } launchSemaphore.Wait( 500000 ); CleanupStack::PopAndDestroy( &launchSemaphore ); if( commandLine ) CleanupStack::PopAndDestroy( commandLine ); }