Esempio n. 1
0
/**
*   Load network iformation (hosts names) from ini file.
*
*   @param aNetworkInfo ref. to the TNetworkInfo structure, which will be populated
*/
void   CTestStepLLMNR_Init::LoadNetworkConfigFromIniL(TNetworkInfo&  aNetworkInfo)
    {
    TName   tmpBuf;
    TInt    nRes;
    
    //-- get number of hosts which are supposed to be running
    //-- there should be at last 2 host names in the list
    TESTL(GetIntFromConfig(KNodesSection, _L("NumNodes"), nRes) && nRes >= KMinNodes);
    const TInt numNodes = nRes;  
    
    //-- get maximal number of trials of host hame resolution
    TESTL(GetIntFromConfig(KNodesSection, _L("ConnectTrials"), nRes) && nRes >= 1);
    const TInt maxTrials = nRes;  
    
    //-- populate NetworkInfo array with information from ini file.
    TNodeInfo nodeInfo;
    
    for(TInt i=0; i<numNodes; ++i)
        {
        //-- get host name from ini file
        tmpBuf.Format(_L("HostName%d"),i+1);
        if(!GetIniFileString(KNodesSection, tmpBuf, nodeInfo.iHostName))  
            continue;
        
        //-- put host info to the array
        nodeInfo.iCntTrials = maxTrials;
        aNetworkInfo.AppendNode(nodeInfo);
        }
    
    //-- check number of hosts to communicate with.
    TESTL(aNetworkInfo.NodesCount() >= KMinNodes);
    }
Esempio n. 2
0
void CTestList::SelectedL(TInt aIndex)
{
#if USE_PROCESS
    TThreadParams params;
    params.iIndex=aIndex;
    TName name;
    name.Format(_L("TimeTest-%x"),iCount++);
    params.iGroupId=Client()->iGroup->GroupWin()->Identifier();
    User::LeaveIfError(iTimeTest.Create(name,TimeThread,KDefaultStackSize*2,KHeapSize,KHeapSize,&params,EOwnerThread));
    TRequestStatus status;
    iTimeTest.Logon(status);
    __PROFILE_RESET(8);
    iTimeTest.Resume();
    User::WaitForRequest(status);
#else
    TThreadParams params;
    params.iIndex=aIndex;
    TimeThread(&params);
#endif
    TBuf<64> buf;
    TBuf<64> buf2;
    TBuf<64> buf3;
    CResultDialog *dialog=new(ELeave) CResultDialog(Client()->iGroup, iGc);
    dialog->ConstructLD();
#if USE_PROCESS
    if (status.Int()==KErrNone)
    {
#endif
#if !defined(__PROFILING__)
        buf=_L("Profiling information not available");
#else
        TProfile profile[6];
        __PROFILE_DISPLAY(6);
        for (TInt index=1; index<6; index++)
            AppendProfileNum(buf2,profile[index].iTime);
        for (TInt index2=1; index2<6; index2++)
            AppendProfileCount(buf3,profile[index2].iCount);
        buf.Format(_L("Time=%d.%2d"),profile[0].iTime/1000000,(profile[0].iTime%1000000)/10000);
#endif
        dialog->SetTitle(buf);
#if USE_PROCESS
    }
    else
    {
        dialog->SetTitle(_L("Error in test"));
        buf.Format(_L("Error=%d"),status.Int());
        buf2=iTimeTest.ExitCategory();
    }
#endif
    dialog->SetLine1(buf2);
    dialog->SetLine2(buf3);
    dialog->SetNumButtons(1);
    dialog->SetButtonText(0,_L("Okay"));
    if (dialog->Display()!=0)
        Panic(0);
}
Esempio n. 3
0
// ---------------------------------------------------------------------------
// Creates server name
// ---------------------------------------------------------------------------
//    
EXPORT_C void RAlfClientBase::ConstructServerName( TName& aServerName, 
                                        TUid aAppServerUid, 
                                        TUint aServerDifferentiator )
    {

    _LIT(KServerNameFormat, "%08x_%08x_AppServer");
    aServerName.Format( 
        KServerNameFormat, 
        aServerDifferentiator, 
        aAppServerUid.iUid );
    }    
Esempio n. 4
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1191
@SYMTestCaseDesc	    Lock out of dictionary files test
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt for opening of same dictionary file.Tests for file in use error
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
void ContentionTestL()
	{
	test.Start(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1191 Contention tests "));
	
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse testIniFile;
	testIniFile.Set(drive.Name(), &KTestIniFile, NULL);
	
	CDictionaryStore* dict=CDictionaryFileStore::OpenLC(TheFs,testIniFile.FullName(),KTestUid);
	TIniData data;
	data.SaveL(*dict);
	CleanupStack::PopAndDestroy(); // dict

	test.Next(_L("Lock-out test"));
	CDictionaryFileStore::OpenLC(TheFs,testIniFile.FullName(),KTestUid);
	TUint tick=User::TickCount();
	TRAPD(r,CDictionaryFileStore::OpenL(TheFs,testIniFile.FullName(),KTestUid));
	tick=User::TickCount()-tick;
	test (r==KErrInUse);
	test.Printf(_L("Lock-out discovered: %d ticks\r\n"),tick);
	CleanupStack::PopAndDestroy();

	test.Next(_L("Creating threads"));
	RThread threads[KNumThreads];
	TRequestStatus status[KNumThreads];
	TInt ii;
	for (ii=0;ii<KNumThreads;++ii)
		{
		TName name;
		name.Format(_L("Test_%d"),ii);
		test (threads[ii].Create(name,ThreadTest,KThreadStack,KThreadHeap,KThreadHeapMax,(TAny*)ii,EOwnerThread)==KErrNone);
		threads[ii].SetPriority(EPriorityLess);
		threads[ii].Logon(status[ii]);
		test (status[ii]==KRequestPending);
		}

	for (ii=0;ii<KNumThreads;++ii)
		threads[ii].Resume();

	test.Next(_L("Waiting for completion"));
	for (ii=0;ii<KNumThreads;++ii)
		User::WaitForAnyRequest();
	TInt success=0;
	for (ii=0;ii<KNumThreads;++ii)
		{
		test (status[ii]!=KRequestPending);
		if (status[ii].Int()==KErrNone)
			++success;
		}
	test.Printf(_L("Thread success: %d of %d\r\n"),success,KNumThreads);
	test.End();
	}
Esempio n. 5
0
/**
*   List existing network interfaces, IP addresses bound to them 
*   and fill up array of IP addresses for all interfaces.
*/
void CTestStepLLMNR_Init::ListInterfacesL()
    {
    
    RSocket socket;
    TInt    nRes;
    TInt    exceed;
    TInt    idx;
    TName   tmpBuf;
    TName   tmpBuf1;
    
    nRes = socket.Open(ipTestServer->iSocketServer, KAfInet, KSockStream, KProtocolInetTcp);
    TESTL(nRes == KErrNone);
    
    TUint   bufsize = 2048;
    
    HBufC8 *buffer =NULL;
    buffer = GetBuffer(buffer, bufsize);
    TESTL(buffer != NULL);
    
    TPtr8 bufdes = buffer->Des();
    
    //-- reset array of local addresses
    ipTestServer->iLocalAddrs.Reset();
    
    //-- list all available network interfaces
    INFO_PRINTF1(KNewLine);
    INFO_PRINTF1(_L("--- available network interfaces:"));
    
    do
        {//-- get list of network interfaces
        // if exceed>0, all interface could not fit into the buffer.
        // In that case allocate a bigger buffer and retry.
        // There should be no reason for this while loop to take more than 2 rounds.
        bufdes.Set(buffer->Des());
        exceed = socket.GetOpt(KSoInetInterfaceInfo, KSolInetIfQuery, bufdes);
        if(exceed > 0)
            {
            bufsize += exceed * sizeof(TInetInterfaceInfo);
            buffer = GetBuffer(buffer, bufsize);
            TESTL(buffer != NULL);
            }
        } while (exceed > 0);
        
        if (exceed < 0)
            {
            INFO_PRINTF1(_L("socket.GetOpt() error!"));
            TESTL(EFalse);
            }
        
        TOverlayArray<TInetInterfaceInfo> infoIface(bufdes);
        
        for(idx=0; idx < infoIface.Length(); ++idx)
            {
            TInetInterfaceInfo& iface = infoIface[idx];
            
            tmpBuf.Format(_L("index:%d, name: "),iface.iIndex);
            tmpBuf.Append(iface.iName );
            tmpBuf.AppendFormat(_L(" state:%d"), iface.iState);
            INFO_PRINTF1(tmpBuf);
            }
        
        //-- list all IP addresses, bound to the interfaces
        //-- and append this address to the array of host-local addresses
        INFO_PRINTF1(KNewLine);
        INFO_PRINTF1(_L("--- IP addresses bound to the interfaces:"));
        
        do
            {
            // if exceed>0, all interface could not fit into the buffer.
            // In that case allocate a bigger buffer and retry.
            // There should be no reason for this while loop to take more than 2 rounds.
	        bufdes.Set(buffer->Des());
            exceed = socket.GetOpt(KSoInetAddressInfo, KSolInetIfQuery, bufdes);
            if(exceed > 0)
                {
                bufsize += exceed * sizeof(TInetAddressInfo);
                buffer = GetBuffer(buffer, bufsize);
                }
            } while (exceed > 0);
            
            if (exceed < 0)
                {
                INFO_PRINTF1(_L("socket.GetOpt() error!"));
                TESTL(EFalse);
                }
            
            
            //-- print out IP addresses
            TOverlayArray<TInetAddressInfo> infoAddr(bufdes);
            TInetAddr inetAddr;
            
            for(idx=0; idx < infoAddr.Length(); ++idx)
                {
                TInetAddressInfo& addr = infoAddr[idx];
                
                tmpBuf.Format(_L("iface index: %d, scopeID: %d, state: %d, IP addr: "), addr.iInterface, addr.iScopeId, addr.iState);
                inetAddr.SetAddress(addr.iAddress);
                inetAddr.Output(tmpBuf1);
                tmpBuf.Append(tmpBuf1);
                INFO_PRINTF1(tmpBuf);
                
                //-- if obtained IP address is valid and not loopback, add it to the array.
                if(inetAddr.IsLoopback() || inetAddr.IsUnspecified())
                    {}
                else
                    ipTestServer->iLocalAddrs.Append(inetAddr);
                
                }
            
            
            delete buffer;
            socket.Close();
            
            INFO_PRINTF1(KNewLine);
}
TVerdict CUpsClientStep::doTestStepPreambleL()
/**
 * @return - TVerdict code
 * Override of base class virtual
 */
	{
	
 	__UHEAP_MARK;
 	
	// Read values to config servers from INI file. (ARRAY of values)
 	
    // Read how many times the test step needs to be repeated.
    TName fStepRepeat(_L("StepRepeat"));
    TInt  repeats;
    
    if(GetIntFromConfig(ConfigSection(),fStepRepeat,repeats))
	    {
	   	iStepRepeat=repeats;
	    }
	else
		{
		iStepRepeat=1;		
		}
    
    // Read values for test sequence from INI file. (ARRAY of values)
	TInt index=0;
	TName fUseServiceUID;
	fUseServiceUID.Format(_L("UseServiceUID_%d"),index);
	TName fUseServerName;
	fUseServerName.Format(_L("UseServerName_%d"),index);
	TName fDestination;
	fDestination.Format(_L("Destination_%d"),index);
	TName fExpectedError;
	fExpectedError.Format(_L("ExpectedError_%d"),index);
	TName fUseOpaqueData;
	fUseOpaqueData.Format(_L("UseOpaqueData_%d"),index);
	TName fSelectDialogOption;
	fSelectDialogOption.Format(_L("SelectDialogOption_%d"),index); 
	TName fButtonsDisplayed;
	fButtonsDisplayed.Format(_L("ButtonsDisplayed_%d"),index);
	TName fDialogCreatorInvoked;
	fDialogCreatorInvoked.Format(_L("DialogCreatorInvoked_%d"),index);
	TName fPolicyEvaluatorInvoked;
	fPolicyEvaluatorInvoked.Format(_L("PolicyEvaluatorInvoked_%d"),index);
	TName fAccessGranted;
	fAccessGranted.Format(_L("AccessGranted_%d"), index);
	TName fCloseSession;
	fCloseSession.Format(_L("CloseSession_%d"), index);
	TName fHoldEvaluatorOpen;
	fHoldEvaluatorOpen.Format(_L("HoldEvaluatorOpen_%d"), index);
	TName fHoldPrepareDialogOpen;
	fHoldPrepareDialogOpen.Format(_L("HoldPrepareDialogOpen_%d"), index);
	TName fHoldDisplayDialogOpen;
	fHoldDisplayDialogOpen.Format(_L("HoldDisplayDialogOpen_%d"), index);
	TName fRequestDurationThreshold;
	fRequestDurationThreshold.Format(_L("RequestDurationThreshold_%d"), index);
	TName fLeaveDialog;
	fLeaveDialog.Format(_L("LeaveDialog_%d"), index);
	TName fLeaveEvaluator;
	fLeaveEvaluator.Format(_L("LeaveEvaluator_%d"), index);
	TName fCancelUpsRequest;
	fCancelUpsRequest.Format(_L("CancelUpsRequest_%d"), index);
	TName fPlatSecPass;
	fPlatSecPass.Format(_L("PlatSecPass_%d"), index);
	TName fForcePrompt;
	fForcePrompt.Format(_L("ForcePrompt_%d"), index);
	TName fExpectedEvaInfo;
	fExpectedEvaInfo.Format(_L("ExpectedEvaluatorInfo_%d"), index);
	TName fSelectFingerprint;
	fSelectFingerprint.Format(_L("SelectFingerprint_%d"), index);
	TName fWaitUntilFileAppears;
	fWaitUntilFileAppears.Format(_L("WaitUntilFileAppears_%d"), index);
	
	TInt	useServiceUID;
	TPtrC   useServerName;
	TPtrC   destination;
	TInt	expectedError;
	TPtrC   useOpaqueData;
    TPtrC	selectDialogOption;
	TInt	buttonsDisplayed;
	TInt    dialogCreatorInvoked;
	TInt	policyEvaluatorInvoked;
	TPtrC	accessGranted;
	TBool	closeSession;
	TBool   holdEvaluatorOpen;
	TBool   holdPrepareDialogOpen;
	TBool   holdDisplayDialogOpen;
	TInt 	requestDurationThreshold;
	TBool   leaveDialog;
	TBool   leaveEvaluator;
	TBool   cancelUpsRequest;
	TBool   platSecPass;
	TBool   forcePrompt;
	TInt    expectedEvaInfo;
	TInt	selectFingerprint;
	TPtrC   waitUntilFileAppears;	
	
	while (GetHexFromConfig(ConfigSection(), fUseServiceUID,useServiceUID)
		&& GetStringFromConfig(ConfigSection(),fUseServerName,useServerName)
		&& GetStringFromConfig(ConfigSection(),fDestination,destination)
	  	&& GetStringFromConfig(ConfigSection(),fAccessGranted,accessGranted))
		{
	    TServiceRequestParameters newSerReq;
	    newSerReq.iServiceUID = useServiceUID; 
	    newSerReq.iServerName = useServerName;
	    newSerReq.iDestination = destination;
	    newSerReq.iAccessGranted = accessGranted;
	    
        // Close session is optional.
        if(GetBoolFromConfig(ConfigSection(),fCloseSession,closeSession))
	    	{
	    	newSerReq.iCloseSession = closeSession;
	    	}
	    
	    // use of dialog creator is optional.
	    if(GetStringFromConfig(ConfigSection(),fSelectDialogOption,selectDialogOption)
		&& GetIntFromConfig(ConfigSection(),fButtonsDisplayed,buttonsDisplayed)
		&& GetIntFromConfig(ConfigSection(),fDialogCreatorInvoked,dialogCreatorInvoked))
	    	{
		    newSerReq.iSelectDialogOption = selectDialogOption;
		    newSerReq.iButtonsDisplayed	= buttonsDisplayed;
		    newSerReq.iDialogCreatorInvoked	= dialogCreatorInvoked;
	    	} 
	    
	    // use of policy evaluator is optional.
	    if(GetIntFromConfig(ConfigSection(),fPolicyEvaluatorInvoked,policyEvaluatorInvoked))
	    	{
	       	newSerReq.iPolicyEvaluatorInvoked = policyEvaluatorInvoked;
	    	}
	    	    
	    // Opaque data is optional
	    if(GetStringFromConfig(ConfigSection(),fUseOpaqueData,useOpaqueData))
	    	{
	       	HBufC8* converter = HBufC8::NewLC(useOpaqueData.Length());
			converter->Des().Copy(useOpaqueData);	
             
	       	newSerReq.iOpaqueData = converter->Ptr() ;	
	       	CleanupStack::PopAndDestroy(); //converter 
	    	}
	    
	    // Expected error is optional.
	    if(GetIntFromConfig(ConfigSection(),fExpectedError,expectedError))
	    	{
			newSerReq.iExpectedError = expectedError;
	    	}
	    	
	    // hold policy evaluator open is optional.
	    if(GetBoolFromConfig(ConfigSection(),fHoldEvaluatorOpen, holdEvaluatorOpen))
	    	{
			newSerReq.iHoldEvaluatorOpen =	holdEvaluatorOpen;
	    	}
	    
	    // hold prepare dialog open is optional.
	    if(GetBoolFromConfig(ConfigSection(),fHoldPrepareDialogOpen, holdPrepareDialogOpen))
	    	{
			newSerReq.iHoldPrepareDialogOpen =	holdPrepareDialogOpen;
	    	}
	    	
	    // hold display dialog open is optional.
	    if(GetBoolFromConfig(ConfigSection(),fHoldDisplayDialogOpen, holdDisplayDialogOpen))
	    	{
			newSerReq.iHoldDisplayDialogOpen =	holdDisplayDialogOpen;
	    	}
	    
	    // request duration threshold - if a request takes 
	    // longer than this threshold it will fail the test
	    if(GetIntFromConfig(ConfigSection(),fRequestDurationThreshold, requestDurationThreshold))
	    	{
	       	newSerReq.iRequestDurationThreshold = requestDurationThreshold;
	    	}

	    // leave dialog is optional.
	    if(GetBoolFromConfig(ConfigSection(),fLeaveDialog,leaveDialog))
	    	{
	    	newSerReq.iLeaveDialog = leaveDialog;
	   		}
	    
	    // leave Evaluator is optional.
	    if(GetBoolFromConfig(ConfigSection(),fLeaveEvaluator,leaveEvaluator))
	    	{
			newSerReq.iLeaveEvaluator = leaveEvaluator;	
	    	}
		       
	    // Cancel ups request is optional.
	    if(GetBoolFromConfig(ConfigSection(),fCancelUpsRequest,cancelUpsRequest))
	    	{
	  		newSerReq.iCancelUpsRequest = cancelUpsRequest;		
	    	}
    
	    // plat sec pass is optional.
	    if(GetBoolFromConfig(ConfigSection(),fPlatSecPass,platSecPass))
	    	{
			newSerReq.iPlatSecPass = platSecPass;
	    	}
	    
	    // Force prompt is optional.
	    if(GetBoolFromConfig(ConfigSection(),fForcePrompt,forcePrompt))
	    	{
			newSerReq.iForcePrompt = forcePrompt;
	    	}
	    
	    // use of policy evaluator is optional.
	    if(GetIntFromConfig(ConfigSection(),fExpectedEvaInfo,expectedEvaInfo))
	    	{
	       	newSerReq.iExpectedEvaluatorInfo = expectedEvaInfo;
	    	}
	    
	    // Fingerprint selection is optional.
	    if(GetIntFromConfig(ConfigSection(),fSelectFingerprint,selectFingerprint))
	    	{
	       	newSerReq.iSelectFingerprint = selectFingerprint;
	    	}
	    
	    // iRepeatUntilFileAppears is optional.
	    if(GetStringFromConfig(ConfigSection(),fWaitUntilFileAppears,waitUntilFileAppears))
	    	{
	    	newSerReq.iWaitUntilFileAppears = waitUntilFileAppears;
	    	}
	    
	    // Add the new service to be requested to array.
	    iArraySersToRequest.Append(newSerReq);
	       
	    index++;
	    fUseServiceUID.Format(_L("UseServiceUID_%d"),index);
	    fUseServerName.Format(_L("UseServerName_%d"),index);
	    fDestination.Format(_L("Destination_%d"),index);
	    fExpectedError.Format(_L("ExpectedError_%d"),index);
	    fUseOpaqueData.Format(_L("UseOpaqueData_%d"),index);
	    fSelectDialogOption.Format(_L("SelectDialogOption_%d"),index);
	    fButtonsDisplayed.Format(_L("ButtonsDisplayed_%d"),index);
	    fDialogCreatorInvoked.Format(_L("DialogCreatorInvoked_%d"),index); 
	    fPolicyEvaluatorInvoked.Format(_L("PolicyEvaluatorInvoked_%d"),index);
	    fAccessGranted.Format(_L("AccessGranted_%d"), index);  
	    fCloseSession.Format(_L("CloseSession_%d"), index);
	    fHoldEvaluatorOpen.Format(_L("HoldEvaluatorOpen_%d"), index);
	    fHoldPrepareDialogOpen.Format(_L("HoldPrepareDialogOpen_%d"), index);
	    fHoldDisplayDialogOpen.Format(_L("HoldDisplayDialogOpen_%d"), index);
		fRequestDurationThreshold.Format(_L("RequestDurationThreshold_%d"), index);
	    fLeaveDialog.Format(_L("LeaveDialog_%d"), index);
	    fLeaveEvaluator.Format(_L("LeaveEvaluator_%d"), index);
	    fCancelUpsRequest.Format(_L("CancelUpsRequest_%d"), index);
	    fPlatSecPass.Format(_L("PlatSecPass_%d"), index);
	    fForcePrompt.Format(_L("ForcePrompt_%d"), index);
	   	fExpectedEvaInfo.Format(_L("ExpectedEvaluatorInfo_%d"), index);
	   	fSelectFingerprint.Format(_L("SelectFingerprint_%d"), index);
	   	fWaitUntilFileAppears.Format(_L("WaitUntilFileAppears_%d"), index);
	   	}	

	// now try for some clientStep specific stuff
	// this ini file entry specifies the property key value for the hold flag
	// If the hold flag property is true then monitor it until it becomes false
	// then continue
	TInt holdKey;
    if(GetIntFromConfig(ConfigSection(),_L("HoldClientStepKey"), holdKey))
	    {
		iHoldClientStepKey = holdKey;

		// as this property is present then set it to true using a direct call to p&s api because
		// the ups p&s api only handles policy evaluators and dialog creators and not test steps
		User::LeaveIfError(RProperty::Set(KPropertyCreatorUid, iHoldClientStepKey, 2));
	    }

	// Instantiates property reader and seter
	iPropertyReader= CUpsProperty::NewL(KPropertyCreatorUid); 

	// reads client name and SID
	TParse clientFullName;
	RThread client;
	clientFullName.Set(client.FullName(),NULL, NULL);
	iTEFServerName=clientFullName.Name();
	iExpectedClientSid = client.SecureId() ;
	client.Close();
			
	SetTestStepResult(EPass);
	return TestStepResult();
	}
Esempio n. 7
0
/**
Second phase constructor
@internalComponent
*/
void CVideoRenderer::ConstructL()
	{
	User::LeaveIfError(iSurfaceManager.Open());

	User::LeaveIfError(iWsSession.Connect());
	
	CResourceFileReader* reader = CResourceFileReader::NewLC(KResourceFileName);
	reader->ReadSupportedFormatL(iSupportedFormat);

	if (iTimed)
		{
		// Create a high priority thread for timed mode

		// get timer info for timed mode
		TInt64 defaultDelay;
		TInt64 maxDelay;
		reader->ReadTimerInfoL(defaultDelay, maxDelay);

		//Get a reference to this thread's heap
		RHeap& thisHeap = User::Heap();

		//Parameters to send to the sub thread
		TThreadRelayParam param;
		param.iObserver = &iObserver;
		param.iThreadRelay = &iRendererRelay; // return pointer to allow direct calls

		//Get the id of this thread
		RThread thisThread;
		TThreadId thisThreadId = thisThread.Id();
		param.iMainThreadId = thisThreadId;

		//Get a request to signal for setup completion
		TRequestStatus setupComplete = KRequestPending;
		param.iSetupComplete = &setupComplete;
		
		//current time and the "this" pointer for a unique key
		_LIT(KFormatString,"%S.%020Lu.%08X");
	   	TName threadName;
		TTime now;
		now.UniversalTime();
		threadName.Format(KFormatString, &KVideoRendererThreadName, now.Int64(), reinterpret_cast<TUint>(this));

		//Create a new thread using the same heap as this thread
		TInt result = iRendererThread.Create(threadName,
										ThreadCreateFunction,
										KSubThreadStackSize,
										&thisHeap,
										&param);
		User::LeaveIfError(result);

		//Run the thread under high priority
		iRendererThread.SetPriority(KSubThreadPriority); 

		//Wait for thread startup to complete
		TRequestStatus threadStatus = KRequestPending;
		iRendererThread.Logon(threadStatus);

		//Start the thread
		iRendererThread.Resume();
		User::WaitForRequest(threadStatus, setupComplete);
		if(threadStatus != KRequestPending)
			{
			//Thread creation failed
			TInt reason = iRendererThread.ExitReason();
			DEBUGPRINT3(_L("Renderer thread died with type=%d, reason=%d"), iRendererThread.ExitType(), reason);
			User::Leave(reason);
			}

		// Thread creation was successfull
		TInt error = iRendererThread.LogonCancel(threadStatus);
		User::LeaveIfError(error); // There is no outstanding request
		User::WaitForRequest(threadStatus); // Consume the signal

		__ASSERT_DEBUG(iRendererRelay != NULL, User::Panic(_L("CVR::ConstructL"), KErrCorrupt));
		iRendererRelay->SetRendererThread(&iRendererThread);
		iRendererRelay->SetTimerInfo(defaultDelay, maxDelay);
		
		iThreadCreated = ETrue;
		User::LeaveIfError(setupComplete.Int());

		//Create a listener that will monitor the thread
		iRendererThreadUndertaker = CThreadUndertaker::NewL(iRendererThread);
		}
	else
		{
		iRendererRelay = CRendererRelay::NewL(iObserver);
		}

	CleanupStack::PopAndDestroy(reader);
	}
TVerdict CUPSDbManagementStep::doTestStepPreambleL()
/**
 * @return - TVerdict code
 * Override of base class virtual
 */
	{
 	__UHEAP_MARK;
 	
 	INFO_PRINTF2(_L("START CELLS: %d"), User::CountAllocCells());
 	
 	// reads client name and SID
	TParse clientFullName;
	RThread client;
	clientFullName.Set(client.FullName(),NULL, NULL);
	iTEFServerName=clientFullName.Name();
	iExpectedClientSid = client.SecureId() ;
	client.Close();
 	
    // Read how many times the test step needs to be repeated.
    TName fStepRepeat(_L("StepRepeat"));
    TInt  repeats;
    
    if(GetIntFromConfig(ConfigSection(),fStepRepeat,repeats))
    	{
    	iStepRepeat=repeats;
    	}
	else
		{	
		iStepRepeat=1;		
		}
    
    // Read values for test sequence from INI file. (ARRAY of values)
	TInt index=0;
	TName fOperation;
	fOperation.Format(_L("Operation_%d"), index);
	TName fClientSid;
	fClientSid.Format(_L("ClientSid_%d"),index);
	TName fEvaluatorId;
	fEvaluatorId.Format(_L("EvaluatorId_%d"),index);
	TName fServiceId;
	fServiceId.Format(_L("ServiceId_%d"),index);
	TName fServerSid;
	fServerSid.Format(_L("ServerSid_%d"),index);
	TName fFingerprint;
	fFingerprint.Format(_L("Fingerprint_%d"),index);
	TName fClientEntity;
	fClientEntity.Format(_L("ClientEntity_%d"),index);
	TName fDescription;
	fDescription.Format(_L("Description_%d"),index);
	TName fDecisionResult;
	fDecisionResult.Format(_L("DecisionResult_%d"),index);
	TName fMajorPolicyVersion;
	fMajorPolicyVersion.Format(_L("MajorPolicyVersion_%d"),index);
	TName fRecordId;
	fRecordId.Format(_L("RecordId_%d"),index);
	TName fEvaluatorInfo;
	fEvaluatorInfo.Format(_L("EvaluatorInfo_%d"),index);
	TName fExpectedDecisionCount;
	fExpectedDecisionCount.Format(_L("ExpectedDecisionCount_%d"),index);
	
	TPtrC 	operation;
	TInt	clientSid;
	TInt	evaluatorId;
	TInt	serviceId;
	TInt	serverSid;
	TPtrC	fingerprint;
	TPtrC	clientEntity;
	TPtrC	description;
	TPtrC	decisionResult;
	TInt	majorPolicyVersion;
	TInt 	recordId;
	TInt	evaluatorInfo;
	TInt 	expectedDecisionCount;
	
	while (GetStringFromConfig(ConfigSection(),fOperation,operation))
		{
		
		// Create an instance of a new request
		CUpsDbRequest* newRequest = CUpsDbRequest::NewL();
		CleanupStack::PushL(newRequest);
		
		// Set the operation to be performed
	    newRequest->iOperation = operation;
	    
	    if(GetHexFromConfig(ConfigSection(),fClientSid,clientSid))
		    {
		    newRequest->iClientSid = clientSid;
		  	newRequest->iDecisionFilter->SetClientSid(TSecureId(clientSid),EEqual);
		    }
	    
		if(GetHexFromConfig(ConfigSection(),fEvaluatorId,evaluatorId))
			{
			newRequest->iEvaluatorId = evaluatorId;	
			newRequest->iDecisionFilter->SetEvaluatorId(TUid::Uid(evaluatorId),EEqual);
			}
		
		if(GetHexFromConfig(ConfigSection(),fServiceId,serviceId))
			{
			newRequest->iServiceId = serviceId;	
			newRequest->iDecisionFilter->SetServiceId(TUid::Uid(serviceId),EEqual);
			}
	
		if(GetHexFromConfig(ConfigSection(),fServerSid,serverSid))
			{
			newRequest->iServerSid = serverSid;	
			newRequest->iDecisionFilter->SetServerSid(TSecureId(serverSid),EEqual);
			}
			
		if(GetStringFromConfig(ConfigSection(),fFingerprint,fingerprint))
			{
			HBufC8* fingerprintConverter = HBufC8::NewLC(fingerprint.Length());
			TPtr8 fingerprintPtr = fingerprintConverter->Des();
			fingerprintPtr.Copy(fingerprint); 	
             
	       	newRequest->iFingerprint = fingerprintPtr;
	       	
	       	HBufC8* binaryFingerprint = StringToBinaryLC(fingerprintPtr);
	       	
	      	newRequest->iDecisionFilter->SetFingerprintL(*binaryFingerprint,EEqual);	
	       	CleanupStack::PopAndDestroy(binaryFingerprint);
	       	CleanupStack::PopAndDestroy(fingerprintConverter); 
			}

		if(GetStringFromConfig(ConfigSection(),fClientEntity,clientEntity))
			{
			HBufC8* clientEntityConverter = HBufC8::NewLC(clientEntity.Length());
			TPtr8 clientEntityPtr = clientEntityConverter->Des();
			clientEntityPtr.Copy(clientEntity); 	
             
	       	newRequest->iClientEntity = clientEntityPtr;
	       	newRequest->iDecisionFilter->SetClientEntityL(clientEntityPtr,EEqual);		
	       	CleanupStack::PopAndDestroy(clientEntityConverter); 
			}
			
		if(GetStringFromConfig(ConfigSection(),fDescription,description))
			{
		    newRequest->iDescription = description;
			}
			
		if(GetStringFromConfig(ConfigSection(),fDecisionResult,decisionResult))
			{
			if(decisionResult.CompareF(_L("Yes"))==0 || decisionResult.CompareF(_L("No"))==0 || decisionResult.CompareF(_L(""))==0 )
				{
				newRequest->iDecisionResult = decisionResult;	
				}
			else 
				{
				ERR_PRINTF3(_L("%S: Unexpected Decision Result - %S"),&iTEFServerName, &decisionResult);
				}
			}

		if(GetIntFromConfig(ConfigSection(),fMajorPolicyVersion,majorPolicyVersion)) 
			{
			newRequest->iMajorPolicyVersion = majorPolicyVersion;
			newRequest->iDecisionFilter->SetMajorPolicyVersion(majorPolicyVersion,EEqual);		
			}
		
		if(GetIntFromConfig(ConfigSection(),fRecordId,recordId))
			{
			newRequest->iRecordId = recordId;
			newRequest->iDecisionFilter->SetRecordId(recordId,EEqual);		
			}
			
		if(GetIntFromConfig(ConfigSection(),fEvaluatorInfo,evaluatorInfo))
			{
			newRequest->iEvaluatorInfo = evaluatorInfo;		
			}
			
		if(GetIntFromConfig(ConfigSection(),fExpectedDecisionCount,expectedDecisionCount))
			{
			newRequest->iExpectedDecisionCount = expectedDecisionCount;		
			}
	    
	    // Add the new service to be requested to array.
	    iArraySersToRequest.AppendL(newRequest);
	    
	    CleanupStack::Pop(newRequest);
	       
	    index++;
	    fOperation.Format(_L("Operation_%d"), index);
	    fClientSid.Format(_L("ClientSid_%d"),index);
		fEvaluatorId.Format(_L("EvaluatorId_%d"),index);
		fServiceId.Format(_L("ServiceId_%d"),index);
		fServerSid.Format(_L("ServerSid_%d"),index);
		fFingerprint.Format(_L("Fingerprint_%d"),index);
		fClientEntity.Format(_L("ClientEntity_%d"),index);
		fDescription.Format(_L("Description_%d"),index);
		fDecisionResult.Format(_L("DecisionResult_%d"),index);
		fMajorPolicyVersion.Format(_L("MajorPolicyVersion_%d"),index);
		fRecordId.Format(_L("RecordId_%d"),index);
		fEvaluatorInfo.Format(_L("EvaluatorInfo_%d"),index);
		fExpectedDecisionCount.Format(_L("ExpectedDecisionCount_%d"),index);
		}
	
	SetTestStepResult(EPass);
	return TestStepResult();
	}
Esempio n. 9
0
LOCAL_C void DoTests()
//
//  multiple threads
//
    {

	TInt r=KErrNone;
	test.Next(_L("Start continuous file Write/Read/Verify operation"));
	RThread t[KMaxNumberThreads];
	TRequestStatus tStat[KMaxNumberThreads];

	TInt i=0;

	TName threadName;
	TRequestStatus kStat=KRequestPending;
	test.Console()->Read(kStat);
	for (i=0;i<KMaxNumberThreads;i++)
		{
		ThreadTestInfo[i].iCycles=0;
		ThreadTestInfo[i].iErrors=0;
		ThreadTestInfo[i].iSizeArrayPos=(i%KMaxSizeArray);
		ThreadTestInfo[i].iErrorInfo=0;
		if (i<(KMaxNumberThreads-1))
			{
			threadName.Format(_L("MakeAndDeleteFiles%d"),i);
	    	r=t[i].Create(threadName,MakeAndDeleteFilesThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i);
			}
		else
			{
			// Last thread fills/empties disk
			threadName.Format(_L("FillAndEmptyDisk%d"),i);
	    	r=t[i].Create(threadName,FillAndEmptyDiskThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i);
			}
		if (r!=KErrNone)
   			test.Printf(_L("Error(%d) creating thread(%d)\r\n"),r,i);
	    test(r==KErrNone);
	    t[i].Logon(tStat[i]);
		t[i].Resume();
		}
	CurrentlyFillingDisk=ETrue;
	FillDiskCount=0;

    TInt totalTime = 0;
    TTime cycleTime;
    TTime startTime;
    TTime time;
    startTime.UniversalTime();
    cycleTime.UniversalTime();
    
	TVolumeInfo v;
	r=TheFs.Volume(v,gDriveNumber);
	test(r==KErrNone);
//	TInt initialFreeSpace = I64LOW(v.iFree / 1024);

#ifdef __LIMIT_EXECUTION_TIME__
	RTimer timer;
	timer.CreateLocal();
	TRequestStatus reqStat;
	timer.After(reqStat,60000000); // After 60 secs
#endif

#ifdef REUSE_THREAD
	RTimer displayTimer;
	displayTimer.CreateLocal();
	TRequestStatus displayStat;
	displayTimer.After(displayStat, KNotificationInterval); // after 10 secs
#endif

	TInt ypos=test.Console()->WhereY();
	FOREVER
		{
		User::WaitForAnyRequest();
		if (kStat!=KRequestPending)
			{
			// user requested to end - let threads die
#ifdef REUSE_THREAD				
			gRequestEnd = ETrue;
#endif			
			for (i=0;i<KMaxNumberThreads;i++)
				{
				User::WaitForRequest(tStat[i]);
				}
			break;
			}
#ifdef __LIMIT_EXECUTION_TIME__
		else if (reqStat != KRequestPending)
			{
			// max execution exceeded - wait for threads to die
			TInt totalCycles = 0;
			for (i=0;i<KMaxNumberThreads;i++)
				{
				totalCycles+= ThreadTestInfo[i].iCycles;
				}
			test.Printf(_L("Total cycles = %d\r\n"), totalCycles);
			test.Printf(_L("Waiting for thread death...\r\n"));
			for (i=0;i<KMaxNumberThreads;i++)
				{
				User::WaitForRequest(tStat[i]);
				}
			break;
			}
#endif
		else
			{
			// other notification
			TBool threadFinished=EFalse;
			for (i=0;i<KMaxNumberThreads;i++)
				{
				if (tStat[i]!=KRequestPending && !threadFinished)
					{
					t[i].Close();
					(ThreadTestInfo[i].iCycles)++;
					if (tStat[i]!=KErrNone)
						(ThreadTestInfo[i].iErrors)++;
					threadFinished=ETrue;

					// Launch another thread
					TInt threadNameId=((ThreadTestInfo[i].iCycles)%2)?(i+KMaxNumberThreads):i; // Alternate thread name
					if (i<(KMaxNumberThreads-1))
						{
						threadName.Format(_L("MakeAndDeleteFiles%d"),threadNameId);
	    				r=t[i].Create(threadName,MakeAndDeleteFilesThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i);
						}
					else
						{
						// Last thread fills/empties disk
						threadName.Format(_L("FillAndEmptyDisk%d"),threadNameId);
	    				r=t[i].Create(threadName,FillAndEmptyDiskThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i);
						}
					if (r!=KErrNone)
   						test.Printf(_L("Error(%d) creating thread(%d)\r\n"),r,i);
	    			test(r==KErrNone);
	    			t[i].Logon(tStat[i]);
					t[i].Resume();
					}
				test.Console()->SetPos(0,(ypos+i));
   				test.Printf(_L("Thread(%d): % 4d errors in % 4d cycles (%d)\r\n"),i,ThreadTestInfo[i].iErrors,ThreadTestInfo[i].iCycles,ThreadTestInfo[i].iErrorInfo);
				}
				
#ifdef REUSE_THREAD
			if(displayStat != KRequestPending)
				{
				// re-request notification
				displayTimer.After(displayStat, KNotificationInterval);
				}
			else if (!threadFinished)
				{
				test.Printf(_L("Semaphore death"));
				break;
				}
#else 
			if (!threadFinished)
				{
				test.Printf(_L("Semaphore death"));
				break;
				}
#endif					
				
			r=TheFs.Volume(v,gDriveNumber);
			test(r==KErrNone);
			test.Console()->SetPos(0,(ypos+KMaxNumberThreads));
			
			TInt  freeSpace;
			TInt8 freeSpaceUnit;
			TInt  totalSpace;
			TInt8 totalSpaceUnit;
			
			// switch t
			if(v.iFree > KDiskUnitThreshold)
				{
				// display in MB
				freeSpace = I64LOW(v.iFree / (1024 * 1024));
				freeSpaceUnit = 'M';
				}
			else
				{
				// display in KB
				freeSpace = I64LOW(v.iFree/1024);
				freeSpaceUnit = 'K';
				}
			
			if(v.iSize > KDiskUnitThreshold)
				{
				// display in MB
				totalSpace = I64LOW(v.iSize / (1024 * 1024));
				totalSpaceUnit = 'M';
				}
			else
				{
				// display in KB
				totalSpace = I64LOW(v.iSize/1024);
				totalSpaceUnit = 'K';
				}
			
			test.Printf(_L("Free space on disk: %u %cB (of %u %cB)\r\n"), 
						freeSpace, freeSpaceUnit, totalSpace, totalSpaceUnit);

            TTimeIntervalSeconds timeTaken;
            time.UniversalTime();            
            r=time.SecondsFrom(startTime,timeTaken);
            test(r==KErrNone);
            totalTime=timeTaken.Int();

            TInt seconds = totalTime % 60;
            TInt minutes = (totalTime / 60) % 60;
            TInt hours   = (totalTime / 3600) % 24;
            TInt days    = totalTime / (60 * 60 * 24);
            test.Printf(_L("Elapsed Time (%d): %d d %02d:%02d:%02d\r\n"), FillDiskCycle, days, hours, minutes, seconds);
            
            if(CurrentlyFillingDisk)
            	{
            	// work out ETA to full disk
	            r = time.SecondsFrom(cycleTime, timeTaken);
    	        if((r == KErrNone) && (v.iSize > v.iFree))
    	        	{
		            	totalTime = (TInt) ((v.iFree/1024 * (TInt64) timeTaken.Int()) / (v.iSize/1024 - v.iFree/1024));
		    	        seconds = totalTime % 60;
    		    	    minutes = (totalTime / 60) % 60;
        		    	hours   = (totalTime / 3600) % 24;
	            		days    = totalTime / (60 * 60 * 24);
            	
    	        		test.Printf(_L("ETA to full disk: %d d %02d:%02d:%02d\r\n"), days, hours, minutes, seconds);
        	    	}
            	}
            else 
            	{
            	// currently emptying disk, update time metrics
            	cycleTime.UniversalTime();
            	}            	
           	
			}
						
			test.Printf(_L("\n"));
		}
    }
Esempio n. 10
0
LOCAL_C void DoTests()
//
//  single thread
//
    {

	TInt r=KErrNone;
	test.Next(_L("Start continuous file Write/Read/Verify operation"));
	RThread t[KMaxNumberThreads];
	TRequestStatus tStat[KMaxNumberThreads];

	TInt i=0;

	TName threadName;
	TRequestStatus kStat=KRequestPending;
	test.Console()->Read(kStat);
	ThreadTestInfo[i].iCycles=0;
	ThreadTestInfo[i].iErrors=0;
	ThreadTestInfo[i].iSizeArrayPos=(i%KMaxSizeArray);
	ThreadTestInfo[i].iErrorInfo=0;
	if (i<(KMaxNumberThreads-1))
		{
		threadName.Format(_L("MakeAndDeleteFiles%d"),i);
    	r=t[i].Create(threadName,MakeAndDeleteFilesThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i);
		}
	else
		{
		// Last thread fills/empties disk
		threadName.Format(_L("FillAndEmptyDisk%d"),i);
    	r=t[i].Create(threadName,FillAndEmptyDiskThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i);
		}
	if (r!=KErrNone)
		test.Printf(_L("Error(%d) creating thread(%d)\r\n"),r,i);
	test(r==KErrNone);
	t[i].Logon(tStat[i]);
	t[i].Resume();
	CurrentlyFillingDisk=ETrue;
	FillDiskCount=0;

    TInt totalTime=0;
    TTime startTime;
    TTime time;
    startTime.UniversalTime();

	TInt ypos=test.Console()->WhereY();
	FOREVER
		{
		User::WaitForAnyRequest();
		if (kStat!=KRequestPending)
			{
    		t[i].LogonCancel(tStat[i]);
			User::WaitForRequest(tStat[i]);
			break;
			}
		else
			{
			TBool threadFinished=EFalse;
			if (tStat[i]!=KRequestPending && !threadFinished)
				{
				t[i].Close();
				(ThreadTestInfo[i].iCycles)++;
				if (tStat[i]!=KErrNone)
					(ThreadTestInfo[i].iErrors)++;
				threadFinished=ETrue;

				// Launch another thread
				TInt threadNameId=((ThreadTestInfo[i].iCycles)%2)?(i+KMaxNumberThreads):i; // Alternate thread name
				threadName.Format(_L("FillAndEmptyDisk%d"),threadNameId);
   				r=t[i].Create(threadName,FillAndEmptyDiskThread,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)i);
				if (r!=KErrNone)
					test.Printf(_L("Error(%d) creating thread(%d)\r\n"),r,i);
    			test(r==KErrNone);
    			t[i].Logon(tStat[i]);
				t[i].Resume();
				}
				
			test.Console()->SetPos(0,(ypos+i));
			test.Printf(_L("Thread(%d): % 4d errors in % 4d cycles (%d)\r\n"),i,ThreadTestInfo[i].iErrors,ThreadTestInfo[i].iCycles,ThreadTestInfo[i].iErrorInfo);
			if (!threadFinished)
				{
				test.Printf(_L("Semaphore death"));
				break;
				}
			TVolumeInfo v;
			r=TheFs.Volume(v,gDriveNumber);
			test(r==KErrNone);
			test.Console()->SetPos(0,(ypos+KMaxNumberThreads));
			test.Printf(_L("Free space on disk: %u K(of %u K)\r\n"),(v.iFree/1024).Low(),(v.iSize/1024).Low());

            TTimeIntervalSeconds timeTaken;
            time.UniversalTime();
            r=time.SecondsFrom(startTime,timeTaken);
            test(r==KErrNone);
            totalTime=timeTaken.Int();

            TInt seconds = totalTime % 60;
            TInt minutes = (totalTime / 60) % 60;
            TInt hours   = (totalTime / 3600) % 24;
            TInt days    = totalTime / (60 * 60 * 24);
            test.Printf(_L("Elapsed Time: %d d %02d:%02d:%02d\r\n"), days, hours, minutes, seconds);
			}
		}
    }