/** @SYMTestCaseID APPFWK-APPARC-0015 @SYMPREQ PREQ1123 @SYMTestCaseDesc The Test determines that the Child dies when its Parent is terminated. @SYMTestPriority Critical @SYMTestStatus Implemented @SYMTestActions. Creates and launches a process (parent). Creates another process (child) passing the first(parent) process ID. Launches the child process. Terminates parent and checks the existance of child process. The child should die. API Calls:\n RProcess::Create(const TDesC &aFileName, const TDesC &aCommand, TOwnerType aType=EOwnerProcess);\n RProcess::Resume(); RProcess::ExitType() const; RProcess::ExitReason() const; RProcess::Id() const; CApaCommandLine::SetProcessEnvironmentL(RProcess &aProcess) const; CApaCommandLine::NewLC(); CApaCommandLine::SetParentProcessId(TProcessId); @SYMTestExpectedResults Termination of child process automatically.\n */ void CT_ProcStep::testChildSetToTerminateL(void) { TInt ret(0); //commandline for parent process CApaCommandLine* parentProcCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Parent Process created ")); //parent process RProcess parentProc; ret = parentProc.Create(KParentExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(parentProc); INFO_PRINTF2(_L(" Create Parent Process returned : %d"),ret); //attach commandline to parent process TRAP(ret,parentProcCmdln->SetProcessEnvironmentL(parentProc)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine to Process ")); INFO_PRINTF1(_L(" Run Parent Process ")); parentProc.Resume(); //Time for the parent process to launch itself User::After(500000); //commandline for child process //Get parent process ID here TUint64 parentProcId = parentProc.Id(); INFO_PRINTF2(_L(" Parent Process Id = 0x%lx "),parentProcId); CApaCommandLine* childProcCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Child Process created ")); //setting the parent process ID to child childProcCmdln->SetParentProcessId(parentProcId); INFO_PRINTF1(_L(" Set ParentProcessId to Child ")); //child process RProcess childProc; ret = childProc.Create(KChildOneExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(childProc); INFO_PRINTF2(_L(" Create Child Process returned : %d"),ret); //attach commandline to child process TRAP(ret,childProcCmdln->SetProcessEnvironmentL(childProc)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine to Process ")); INFO_PRINTF1(_L(" Run Child Process ")); childProc.Resume(); //Time for the child process to launch itself User::After(500000); //child process Id is reqd to monitor if it gets killed on its parent's termination TUint64 childProcId = childProc.Id(); INFO_PRINTF2(_L(" Child Process Id = 0x%lx "),childProcId); CChildProcess* childProcess=NULL; TRAP(ret, childProcess=CChildProcess::NewL(parentProc,childProcId)); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupStack::PushL(childProcess); TExitType exitType = parentProc.ExitType(); TEST(exitType == EExitTerminate); TInt exitReason = parentProc.ExitReason(); TEST(exitReason == 0); if(exitType==EExitTerminate && exitReason==0) { INFO_PRINTF1(_L(" Parent process is Terminated")); } exitType = childProc.ExitType(); TEST(exitType == EExitTerminate); exitReason = childProc.ExitReason(); TEST(exitReason == 0); if(exitType == EExitTerminate && exitReason==0) { INFO_PRINTF1(_L(" The child process is killed automatically ... ")); } CleanupStack::PopAndDestroy(childProcess); CleanupStack::PopAndDestroy(&childProc); CleanupStack::PopAndDestroy(childProcCmdln); CleanupStack::PopAndDestroy(&parentProc); CleanupStack::PopAndDestroy(parentProcCmdln); }
/** @SYMTestCaseID APPFWK-APPARC-0016 @SYMPREQ PREQ1123 @SYMTestCaseDesc Test determines that the Child remains when its Parent is terminated. @SYMTestPriority Critical @SYMTestStatus Implemented @SYMTestActions. Creates and launches a process (parent). Creates another process (child) without passing the first(parent) process ID. Launches the child process. Terminates parent and checks the existance of child process. The child process should be alive. API Calls:\n RProcess::Create(const TDesC &aFileName, const TDesC &aCommand, TOwnerType aType=EOwnerProcess);\n RProcess::Resume(); RProcess::ExitType() const; RProcess::ExitReason() const; RProcess::Id() const; RProcess::Terminate(TInt aReason); CApaCommandLine::SetProcessEnvironmentL(RProcess &aProcess) const; CApaCommandLine::NewLC(); @SYMTestExpectedResults Existence of child process.\n */ void CT_ProcStep::testChildSetToRemainL(void) { TInt ret(0); //commandline for parent process CApaCommandLine* parentProcCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Parent Process created ")); //parent process RProcess parentProc; ret = parentProc.Create(KParentExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(parentProc); INFO_PRINTF2(_L(" Create Parent Process returned : %d"),ret); //attach commandline to parent process TRAP(ret,parentProcCmdln->SetProcessEnvironmentL(parentProc)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine to Process ")); INFO_PRINTF1(_L(" Run Parent Process ")); parentProc.Resume(); //Time for the parent process to launch itself User::After(500000); //commandline for child process //Get parent process ID here TUint64 parentProcId = parentProc.Id(); INFO_PRINTF2(_L(" Parent Process Id = 0x%lx "),parentProcId); CApaCommandLine* childProcCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Child Process created ")); //child process RProcess childProc; ret = childProc.Create(KChildOneExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(childProc); INFO_PRINTF2(_L(" Create Child Process returned : %d"),ret); //attach commandline to child process TRAP(ret,childProcCmdln->SetProcessEnvironmentL(childProc)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine to Process ")); INFO_PRINTF1(_L(" Run Child Process ")); childProc.Resume(); //Time for the child process to launch itself User::After(500000); parentProc.Terminate(KTProcTerminatingParent); INFO_PRINTF1(_L(" Kill Parent Process ... ")); TExitType exitType = parentProc.ExitType(); TEST(exitType == EExitTerminate); TInt exitReason = parentProc.ExitReason(); TEST(exitReason == KTProcTerminatingParent); //child process Id is reqd to monitor if it gets killed on its parent's termination TUint64 childProcId = childProc.Id(); INFO_PRINTF2(_L(" Child Process Id = 0x%lx "),childProcId); //Wait for child to terminate ... if it really does User::After(10000000); exitType = childProc.ExitType(); TEST(exitType == EExitPending); if(exitType == EExitPending) { INFO_PRINTF1(_L(" Child process is still running ")); INFO_PRINTF1(_L(" so terminating it manually ...")); childProc.Terminate(KTProcTerminatingChildI); exitType = childProc.ExitType(); TEST(exitType == EExitTerminate); exitReason = childProc.ExitReason(); TEST(exitReason == KTProcTerminatingChildI); } CleanupStack::PopAndDestroy(&childProc); CleanupStack::PopAndDestroy(childProcCmdln); CleanupStack::PopAndDestroy(&parentProc); CleanupStack::PopAndDestroy(parentProcCmdln); }
EXPORT_C TInt RDRMRightsClient::StartServer() { DRMLOG( _L( "RDRMRightsClient::StartServer()" ) ); RSemaphore semaphore; RSemaphore semaphore2; TFindServer server( DRMEngine::KServerName ); TFullName name; RProcess process; TInt error = KErrNone; // "local" semaphore error = semaphore2.CreateGlobal( KRightsServerStarterSemaphore, // name 1 , // count EOwnerThread ); // owner if ( error == KErrAlreadyExists ) { error = semaphore2.OpenGlobal( KRightsServerStarterSemaphore ); } // Semaphore not created or opened, don't need to close if( error ) { return error; } // Server updated semaphore error = semaphore.CreateGlobal( DRMEngine::KDRMSemaphore, // name 0 , // count EOwnerThread ); // owner if ( error == KErrAlreadyExists ) { error = semaphore.OpenGlobal( DRMEngine::KDRMSemaphore ); } // Semaphore not created or opened, don't need to close if( error ) { semaphore2.Close(); return error; } // Wait until server has done all its things. semaphore2.Wait(); // Check if the server is already running. error = server.Next( name ); if ( !error ) { // Yep, it's already running. error = KErrNone; } else { error = process.Create( KServerFileName, KNullDesC ); if ( !error ) { User::After( 1000 ); process.Resume(); process.Close(); // Wait here for the server process startup to complete // server will signal the global semaphore semaphore.Wait(); } } // Close both semaphores and signal the "local" one. semaphore.Close(); semaphore2.Signal(); semaphore2.Close(); DRMLOG2( _L( "RDRMRightsClient::StartServer(): %d" ), error ); return error; }
/** @SYMTestCaseID APPFWK-APPARC-0022 @SYMPREQ PREQ1123 @SYMTestCaseDesc The Test determines that the child doesn't receive its parent process ID correctly, when not set during its creation. @SYMTestPriority Medium @SYMTestStatus Implemented @SYMTestActions. Creates and launches a process (parent). Creates another process (child) without setting any parent. Parent Process Id is passed to child through SetParameter API. Launches the child process. Child obtains the parent process Id from within. Child compares both the Id's. The Id's should not match each other. API Calls:\n RProcess::Create(const TDesC &aFileName, const TDesC &aCommand, TOwnerType aType=EOwnerProcess);\n RProcess::Resume(); RProcess::ExitType() const; RProcess::ExitReason() const; RProcess::Id() const; RProcess::SetParameter(TInt aSlot, TInt aData); CApaCommandLine::SetProcessEnvironmentL(RProcess &aProcess) const; CApaCommandLine::NewLC(); RFile::Open(RFs &aFs, const TDesC &aName, TUint aFileMode); RFile::Read(TInt aPos, TDes8 &aDes) const; RFile::Close(); RFs::Connect(TInt aMessageSlots=KFileServerDefaultMessageSlots); RFs::Delete(const TDesC &aName); RFs::Close(); @SYMTestExpectedResults Id received by child process should not match its parent process Id.\n */ void CT_ProcStep::testIdNotAvailableToChildL(void) { TInt ret(0); TInt exitReason(0); //commandline for parent process CApaCommandLine* parentProcCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Parent Process created ")); //parent process RProcess parentProc; ret = parentProc.Create(KParentExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(parentProc); INFO_PRINTF2(_L(" Create Parent Process returned : %d"),ret); //attach commandline to parent process TRAP(ret,parentProcCmdln->SetProcessEnvironmentL(parentProc)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine to Process ")); INFO_PRINTF1(_L(" Run Parent Process ")); parentProc.Resume(); //Time for the parent process to launch itself User::After(500000); //commandline for child process //Get parent process ID here TUint64 parentProcId = parentProc.Id(); INFO_PRINTF2(_L(" Parent Process Id = 0x%lx "),parentProcId); CApaCommandLine* childProcCmdln=CApaCommandLine::NewLC(); INFO_PRINTF1(_L(" CommandLine for Child Process created ")); //child process RProcess childProc; ret = childProc.Create(KChildThreeExe,KNullDesC); TEST(ret == KErrNone); User::LeaveIfError(ret); CleanupClosePushL(childProc); INFO_PRINTF2(_L(" Create Child Process returned : %d"),ret); //attach commandline to child process TRAP(ret,childProcCmdln->SetProcessEnvironmentL(childProc)); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Attach CommandLine to Process ")); //Setting the parent process Id in an environment slot for the child to receive. ret = childProc.SetParameter(12,parentProcId); TEST(ret == KErrNone); INFO_PRINTF2(_L(" Set the Parent Process Id - 0x%lx to Child through SetParameter API in Slot 12 "),parentProcId); INFO_PRINTF1(_L(" Run Child Process ")); TRequestStatus status; childProc.Rendezvous(status); childProc.Resume(); //Wait for the child process to launch itself User::WaitForRequest(status); RFs fs; RFile file; ret = fs.Connect(); TEST(ret == KErrNone); User::LeaveIfError(ret); INFO_PRINTF1(_L(" Create File server session ")); ret = file.Open(fs,KFilePath,EFileWrite | EFileShareAny); TEST(ret == KErrNone); if(ret == KErrNone) { INFO_PRINTF1(_L(" File opened successfully ")); TBuf8<5> readData; file.Read(0,readData); TBuf8<5> result(KTResultFail); TEST(result==readData); if(result==readData) { INFO_PRINTF1(_L(" Child did not receive the parent process ID as intended...")); } else { INFO_PRINTF1(_L(" Child received the Wrong parent process ID ...")); } file.Close(); fs.Delete(KFilePath); fs.Close(); INFO_PRINTF1(_L(" File Close & Delete and Session Close ")); } TExitType exitType = parentProc.ExitType(); TEST(exitType == EExitPending); if(exitType == EExitPending) { INFO_PRINTF1(_L(" Parent is still running ")); INFO_PRINTF1(_L(" So Terminating it manually ... ")); parentProc.Terminate(KTProcTerminatingParent); exitType = parentProc.ExitType(); TEST(exitType==EExitTerminate); exitReason = parentProc.ExitReason(); TEST(exitReason == KTProcTerminatingParent); } exitType = childProc.ExitType(); TEST(exitType == EExitPending); if(exitType == EExitPending) { INFO_PRINTF1(_L(" Child is still running ")); INFO_PRINTF1(_L(" So Terminating it manually ... ")); childProc.Terminate(KTProcTerminatingChildIII); exitType = childProc.ExitType(); TEST(exitType==EExitTerminate); exitReason = childProc.ExitReason(); TEST(exitReason == KTProcTerminatingChildIII); } CleanupStack::PopAndDestroy(&childProc); CleanupStack::PopAndDestroy(childProcCmdln); CleanupStack::PopAndDestroy(&parentProc); CleanupStack::PopAndDestroy(parentProcCmdln); }
/** * Start the server process/thread which lives in an EPOCEXE object. * * \internal * @return KErrNone if successful, any other error code otherwise */ TInt RSuplNetworkServer::StartServer() { TRequestStatus started; TInt ret; RSemaphore startupSemaphore; ret = startupSemaphore.CreateGlobal( KSuplServerStartupSemaphoreName, 0 ); if ( ret == KErrAlreadyExists ) { // The server is starting up, but has not yet started startupSemaphore.OpenGlobal( KSuplServerStartupSemaphoreName ); // wait until the server has started up, Max 5 secs. TInt err = startupSemaphore.Wait(5000000); startupSemaphore.Close(); if (err != KErrNone) return err; else return ret; } #ifdef _DEBUG RDebug::Print(_L("SuplNetworkApi: Starting SUPL Server...")); #endif const TUidType serverUid(KNullUid, KNullUid, KSuplServerUid3); // Simultaneous launching of two such processes should be detected // when the second one attempts to create the server object, // failing with KErrAlreadyExists. // RProcess server; ret = server.Create(KSuplServerImg, KNullDesC, serverUid); if (ret != KErrNone) { #ifdef _DEBUG RDebug::Print(_L("SuplApi: server start failed %d"), ret); #endif startupSemaphore.Close(); return ret; } TRequestStatus died; server.Rendezvous(died); if (died != KRequestPending) { // logon failed - server is not yet running, so cannot have terminated User::WaitForRequest(died); // eat signal server.Kill(0); // abort startup } else { server.Resume(); } User::WaitForRequest(died); // wait for start or death // we can't use the 'exit reason' if the server panicked as this // is the panic 'reason' and may be '0' which cannot be distinguished // from KErrNone ret = (server.ExitType() == EExitPanic) ? KErrGeneral : died.Int(); server.Close(); startupSemaphore.Wait(); startupSemaphore.Close(); return ret; }
// ----------------------------------------------------------------------------- // RUsbPnClient::ConnectL // (other items were commented in a header). // ----------------------------------------------------------------------------- // EXPORT_C void RUsbPnClient::ConnectL() { OstTrace0( TRACE_BORDER, RUSBPNCLIENT_CONNECTL_ENTRY, "RUsbPnClient::ConnectL" ); A_TRACE( ( _T( "RUsbPnClient::ConnectL()" ) ) ); TInt err( KErrNone ); // Create USB Phonet Link Server session err = CreateSession( KUsbPnServerName, TVersion(1,0,0)); if ( err == KErrNotFound ) { // Session not created // Find lock semaphore for server process creation TFindSemaphore lock( KUsbPnServerName ); TFullName semaphoreName; err = lock.Next( semaphoreName ); if ( err == KErrNotFound ) { // Lock is not enabled OstTrace0( TRACE_INTERNALS, RUSBPNCLIENT_CONNECTL, "RUsbPnClient::ConnectL() - semaphore not found, start server" ); E_TRACE( ( _L( "RUsbPnClient::ConnectL() - semaphore not found, start server" ) ) ); RSemaphore startLock; // Create lock User::LeaveIfError( startLock.CreateGlobal( KUsbPnServerName, 0, EOwnerProcess ) ); /********************************************/ /* Start the USB Phonet Link process process */ TRequestStatus status; RProcess server; User::LeaveIfError( server.Create( KUsbPnServerName, TPtrC( NULL, 0), EOwnerThread ) ); server.Rendezvous( status ); if( status != KRequestPending ) { server.Kill(0); // Abort startup } else { server.Resume(); // Logon OK -> start the server } OstTrace0( TRACE_INTERNALS, RUSBPNCLIENT_CONNECTL_DUP1, "RUsbPnClient::ConnectL() - waiting server response" ); E_TRACE( ( _T( "RUsbPnClient::ConnectL() - waiting server response" ) ) ); User::WaitForRequest( status ); // Wait for start or death // we can't use the 'exit reason' if the server panicked as this // is the panic 'reason' and may be '0' which cannot be distinguished // from KErrNone TInt err = status.Int(); if (err == KErrNone && (server.ExitType() == EExitPanic || server.ExitType() == EExitKill)) { err = KErrServerTerminated; } server.Close(); if( err ) { OstTrace1( TRACE_INTERNALS, RUSBPNCLIENT_CONNECTL_DUP2, "RUsbPnClient::ConnectL() - waiting server response status; err=%d", err ); E_TRACE( ( _T( "RUsbPnClient::ConnectL() - waiting server response status: %d" ), err ) ); TRACE_ASSERT_ALWAYS; User::LeaveIfError( err ); } /* End of starting process */ /********************************************/ OstTrace0( TRACE_INTERNALS, RUSBPNCLIENT_CONNECTL_DUP3, "RUsbPnClient::ConnectL() - server is started, signal other clients" ); E_TRACE( ( _L( "RUsbPnClient::ConnectL() - server is started, signal other clients" ) ) ); // Signal other clients startLock.Signal( KMaxTInt ); // Close semaphore startLock.Close(); } else { // Lock is enabled RSemaphore startLock; // Open lock semaphore User::LeaveIfError( startLock.Open( lock ) ); OstTrace0( TRACE_INTERNALS, RUSBPNCLIENT_CONNECTL_DUP4, "RUsbPnClient::ConnectL() - server is starting, wait for signal" ); E_TRACE( ( _L( "RUsbPnClient::ConnectL() - server is starting, wait for signal" ) ) ); // Wait for signal startLock.Wait(); OstTrace0( TRACE_INTERNALS, RUSBPNCLIENT_CONNECTL_DUP5, "RUsbPnClient::ConnectL() - signal received" ); E_TRACE( ( _L( "RUsbPnClient::ConnectL() - signal received" ) ) ); // Close semaphore startLock.Close(); } // Create USB Phonet Link server session OstTrace0( TRACE_INTERNALS, RUSBPNCLIENT_CONNECTL_DUP6, "RUsbPnClient::ConnectL() - Create session" ); E_TRACE( ( _L( "RUsbPnClient::ConnectL() - Create session" ) ) ); User::LeaveIfError( CreateSession( KUsbPnServerName, TVersion(1,0,0) ) ); OstTrace0( TRACE_INTERNALS, RUSBPNCLIENT_CONNECTL_DUP7, "RUsbPnClient::ConnectL() - session created1" ); E_TRACE( ( _L( "RUsbPnClient::ConnectL() - session created1" ) ) ); } else if ( err ) { OstTrace0( TRACE_INTERNALS, RUSBPNCLIENT_CONNECTL_DUP8, "RUsbPnClient::ConnectL() - session not created, reason uknown" ); E_TRACE( ( _L( "RUsbPnClient::ConnectL() - session not created, reason uknown" ) ) ); TRACE_ASSERT_ALWAYS; User::Leave( err ); } else { OstTrace0( TRACE_INTERNALS, RUSBPNCLIENT_CONNECTL_DUP9, "RUsbPnClient::ConnectL() - session created2" ); E_TRACE( ( _T( "RUsbPnClient::ConnectL() - session created2" ) ) ); } OstTrace0( TRACE_BORDER, RUSBPNCLIENT_CONNECTL_EXIT, "RUsbPnClient::ConnectL() - return void" ); A_TRACE( ( _T( "RUsbPnClient::ConnectL() - return void" ) ) ); }
TVerdict CTEventHandlingPerf::doTestStepL() { /** @SYMTestCaseID GRAPHICS-UI-BENCH-0172 */ SetTestStepID(_L("GRAPHICS-UI-BENCH-0172")); TBuf<KMaxDescLength> bufAvg; TPtr temp(NULL,0); TPtr temp1(NULL,0); TPtr temp2(NULL,0); // Here check if the HAL configuration are correct if not then finish the test case TInt maxPtr; TInt ret = HAL::Get(HALData::EPointerMaxPointers, maxPtr); if (ret != KErrNone || maxPtr < 2 || maxPtr > 8) { INFO_PRINTF1(_L("Incorrect HAL configuration. \n")); SetTestStepResult(EFail); CloseTMSGraphicsStep(); RecordTestResultL(); return TestStepResult(); } iProfiler->InitResults(); TInt minMemSize = 128; TInt maxMemSize = KMaxDescLength; // Create a shared chunk using the userheap function // Allocate some memory in that and then get the offset from it - chunk's base _LIT(KPerformanceTimingChunk, "PerformanceTimingChunk"); RHeap* heap = UserHeap::ChunkHeap(&KPerformanceTimingChunk, minMemSize, maxMemSize, 10); CleanupClosePushL(*heap); if (heap == NULL) { User::LeaveNoMemory(); } RChunk chunk; User::LeaveIfError(chunk.OpenGlobal(KPerformanceTimingChunk, ETrue)); CleanupClosePushL(chunk); TInt memSize = KMaxDescLength; TAny* perfDesc = heap->AllocL(memSize); if (!perfDesc) { User::LeaveNoMemory(); } TInt offset = reinterpret_cast<TUint8*>(perfDesc) - chunk.Base() ; // Create a process called te_multiptrperf // Pass in the offset as descriptor _LIT(KMultiPtrEventHandlingPerf,"z:\\sys\\bin\\te_multiptrperf.exe"); TBuf<128> buf; buf.Num(offset); RProcess eventHandPerf; User::LeaveIfError(eventHandPerf.Create(KMultiPtrEventHandlingPerf, buf)); TRequestStatus stat; eventHandPerf.Logon(stat); eventHandPerf.Resume(); User::WaitForRequest(stat); eventHandPerf.Close(); // Once the process finished its execution print the result by // reading the data from chunk's memory TPtr8 ptrDes((TUint8*)perfDesc, memSize, memSize); TPtr8 ptrDesDisplay((TUint8*)perfDesc, memSize, memSize); // If it has failed then just print description written in the same // when it is failed description contains '*' at the end TInt lastChar = 0; lastChar = ptrDes.Locate('*'); if (KErrNotFound != lastChar) { SetTestStepResult(EFail); TPtr8 temp = ptrDesDisplay.LeftTPtr(lastChar); TBuf<128> buf; buf.Copy(temp); INFO_PRINTF2(_L("%S"), &buf); RDebug::RawPrint(temp); goto END; } // If it has skipped then just print skip description from the chunk // when it is skipped description contains '#' at the end lastChar = ptrDes.Locate('#'); if (KErrNotFound != lastChar) { SetTestStepResult(EPass); TPtr8 temp = ptrDesDisplay.LeftTPtr(lastChar); TBuf<128> buf; buf.Copy(temp); INFO_PRINTF2(_L("%S"), &buf); RDebug::RawPrint(temp); goto END; } // If the every thing goes fine the descriptor is displayed as // "12345678,123456789,123456789" TInt avg4Events, avg8Events, avg16Events, avg32Events; bufAvg.Copy(ptrDesDisplay); for (TInt i=0; i<4; i++) { TInt locate = bufAvg.Locate(','); if (locate == KErrNotFound) { SetTestStepResult(EFail); goto END; } TLex lex(bufAvg.Left(locate)); lex.Val(avg4Events); locate++; temp.Set(bufAvg.MidTPtr(locate)); locate = temp.Locate(','); if (locate == KErrNotFound) { SetTestStepResult(EFail); goto END; } lex = temp.Left(locate); lex.Val(avg8Events); locate++; temp1.Set(temp.MidTPtr(locate)); locate = temp1.Locate(','); if (locate == KErrNotFound) { SetTestStepResult(EFail); goto END; } lex = temp.Left(locate); lex.Val(avg16Events); locate++; temp2.Set(temp1.MidTPtr(locate)); locate = temp2.Locate(','); if (locate == KErrNotFound) { SetTestStepResult(EFail); goto END; } lex = temp2.Left(locate); lex.Val(avg32Events); locate++; bufAvg.Copy(temp2.MidTPtr(locate)); switch (i) { case 0: INFO_PRINTF5(_L("TID: Average time for Single pointer(wait after each event) for 4 events:%i 8 events:%i 16 events:%i 32events:%i"), avg4Events, avg8Events, avg16Events, avg32Events); break; case 1: INFO_PRINTF5(_L("TID: Average time for Multi pointer(wait after each event) for 4 events:%i 8 events:%i 16 events:%i 32events:%i"), avg4Events, avg8Events, avg16Events, avg32Events); break; case 2: INFO_PRINTF5(_L("TID: Average time for single pointer for 4 events:%i 8 events:%i 16 events:%i 32events:%i"), avg4Events, avg8Events, avg16Events, avg32Events); break; case 3: INFO_PRINTF5(_L("TID: Average time for Multi pointer for 4 events:%i 8 events:%i 16 events:%i 32events:%i"), avg4Events, avg8Events, avg16Events, avg32Events); SetTestStepResult(EPass); break; default: break; } } iProfiler->ResultsAnalysis(KEventHandlingPerfName, 0, EColor16MA, EColor16MA, 1); END: // Once the data is printed or displyed delete the memory heap->Free(perfDesc); CleanupStack::PopAndDestroy(2, heap); RecordTestResultL(); CloseTMSGraphicsStep(); return TestStepResult(); }
GLDEF_C void CallTestsL(/*TChar aDriveLetter*/) // // Do all tests // { if( !PlatSec::IsCapabilityEnforced(ECapabilityDiskAdmin)) { test.Printf(_L("Capability ECapabilityDiskAdmin not enabled - leaving t_dcdiskadmin")); test.Printf(_L("\n")); // Prevent overwrite by next print return; } TurnAllocFailureOff(); TheFs.CharToDrive(gDriveToTest,gTheDriveNum); TBuf<30> sesspath; sesspath=_L("?:\\"); sesspath[0] = (TText)gDriveToTest; TInt r= TheFs.SetSessionPath(sesspath); test_KErrNone(r); //cleanup from previous run of this test TBuf<2> cmd; cmd.SetLength(1); cmd[0] = (TText)gDriveToTest; RProcess tp; r=tp.Create(_L("clean_prepdc.exe"),sesspath); test_KErrNone(r); { TRequestStatus ps; tp.Logon(ps); tp.Resume(); tp.Close(); User::WaitForRequest(ps); } //check double mode ie that Defpath still works RFs fs1; RFs fs2; r=fs1.Connect(); test_KErrNone(r); r=fs1.SessionPath(sesspath); test_KErrNone(r); test.Printf(_L("session1 Path=%S"),&sesspath); TBuf<30> privatepath; r=fs1.SetSessionToPrivate(gTheDriveNum); test_KErrNone(r); r=fs1.PrivatePath(privatepath); test_KErrNone(r); r=privatepath.Compare(KExpectedPrivatePath()); test_Value(r, r == 0); r=fs1.SessionPath(sesspath); test_KErrNone(r); r=privatepath.Compare(sesspath.Mid(KPathPosition)); test_Value(r, r == 0); r=fs1.CreatePrivatePath(gTheDriveNum); test_KErrNone(r); fs1.Close(); r=fs2.Connect(); test_KErrNone(r); r=fs2.SessionPath(sesspath); test_KErrNone(r); test.Printf(_L("session2 Path=%S"),&sesspath); fs2.Close(); TestCaps(); test.Printf(_L("No of files open=%d"), TheFs.ResourceCount()); CleanupL(); }
LOCAL_C TInt MainL() { RProcess delayer; delayer.Create(_L("tsysmon_app_delayshutdown.exe"),KNullDesC); delayer.Resume(); delayer.Close(); TInt runCount = 0; CCommandLineArguments* args = CCommandLineArguments::NewLC(); runCount = CSysMonTestHelper::ReadRunCountL(args->Arg(0)); CSysMonTestHelper::IncrementRunCountL(args->Arg(0)); CleanupStack::PopAndDestroy(args); TBool keepRunning = EFalse; switch (runCount) { case 0: { RProcess::Rendezvous(KErrNone); CSysMonTestHelper* helper = CSysMonTestHelper::NewLC(); RSysMonSession sysmon; sysmon.OpenL(); CleanupClosePushL(sysmon); TBuf<255> args; TBuf<255> testId; helper->GetTestId(testId); RDebug::Print(testId); args.Append(testId); args.Append(_L(" ")); args.Append(_L("5000")); CStartupProperties* props = CStartupProperties::NewLC(KFilenameDeregTimeout, args); props->SetMonitored(ETrue); props->SetStartupType(EStartProcess); props->SetStartMethod(EWaitForStart); props->SetNoOfRetries(0); props->SetTimeout(0); props->SetRecoveryParams(ERestartOS, 0); CStartupProperties* props2 = CStartupProperties::NewLC(_L("tsysmon_app_donothing.exe"), KNullDesC); props2->SetMonitored(ETrue); props2->SetStartupType(EStartProcess); props2->SetStartMethod(EWaitForStart); props2->SetNoOfRetries(1); props2->SetTimeout(0); props2->SetRecoveryParams(EIgnoreOnFailure, 0); RProcess slave1; slave1.Create(KFilenameDeregTimeout, args); CleanupClosePushL(slave1); slave1.Resume(); RProcess slave2; slave2.Create(_L("tsysmon_app_donothing.exe"), KNullDesC); CleanupClosePushL(slave2); slave2.Resume(); // Register with SysMon TInt err = 0; TRAP(err, sysmon.MonitorL(*props, slave1)); TRAP(err, sysmon.MonitorL(*props2, slave2)); slave1.Terminate(KErrNone); slave2.Terminate(KErrNone); CleanupStack::PopAndDestroy(5, helper); break; } default: //Run normally { RProcess::Rendezvous(KErrNone); keepRunning = ETrue; break; } } CSysMonTestHelper::IncrementRunCountL(args->Arg(0)); CleanupStack::PopAndDestroy(args); while (keepRunning) { User::After(5000000); // 5 seconds } return 0; }