예제 #1
0
void EventTest::ProcessFunc3( Event3 *ev )
{
	TRACE_BEGIN( LOG_LVL_INFO );
	LOG_NOTICE( "p1 %d", ev->mP1 );

	mTestState++;
	if ( ev->mP1 != 3 )
		TestFailed( "P1 not expected values" );
	ev->mP1 = 1000;
}
예제 #2
0
void EventTest::ProcessFunc2( Event2 *ev )
{
	TRACE_BEGIN( LOG_LVL_INFO );

	LOG_NOTICE( "p1 %d p2 %d", ev->mP1, ev->mP2 );
	
	mTestState++;
	if ( ev->mP1 != 1 || ev->mP2 != 2 )
		TestFailed( "P1 and/or P2 not expected values" ); 		
}
void CUT_PBASE_T_USBDI_0479::DeviceRemovedL(TUint aDeviceHandle)
	{
	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0479_DEVICEREMOVEDL_ENTRY, this );
	
	// The test device should not be removed until the test case has passed
	// so this test case has not completed, and state this event as an error

	TestFailed(KErrDisconnected);
	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0479_DEVICEREMOVEDL_EXIT, this );
	}
void CUT_PBASE_T_USBDI_0479::HostRunL()
	{
	OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_0479_HOSTRUNL_ENTRY, this );
	// Obtain the completion code
	TInt completionCode(iStatus.Int());
	
	if(completionCode == KErrNone)
		{
		// Action timeout
		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0479_HOSTRUNL, "<Error> Action timeout");
		TestFailed(KErrTimedOut);
		}
	else
		{
		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0479_HOSTRUNL_DUP01, "<Error %d> Timeout timer could not complete",completionCode);
		TestFailed(completionCode);
		}
	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0479_HOSTRUNL_EXIT, this );
	}
예제 #5
0
파일: tests.cpp 프로젝트: iley/intelib
static bool Test(const char *name, long tst, long expected)
{
    if(tst == expected) {
        TestPassed(name);
        return true;
    } else {
        TestFailed(name, "result: %d, expected: %d",
                   tst, expected);
        return false;
    }
}
예제 #6
0
파일: tests.cpp 프로젝트: iley/intelib
static bool Test(const char *name, const char *tst, const char *expected)
{
    if (tst == expected ||
       (tst && expected && 0 == strcmp(tst, expected))) {
        TestPassed(name);
        return true;
    } else {
        TestFailed(name, "result: \"%s\", expected: \"%s\"",
                   tst, expected);
        return false;
    }
}
    void CUT_PBASE_T_USBDI_1231::HostRunL()
        {
        OstTraceFunctionEntry1( CUT_PBASE_T_USBDI_1231_HOSTRUNL_ENTRY, this );

        OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1231_DCUT_PBASE_T_USBDI_1231_DUP24, "====> HostRunL entry priority = %d", RThread().Priority());

        // Obtain the completion code
        TInt completionCode(iStatus.Int());

        if (completionCode == KErrNone)
            {
            // Action timeout
            OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1231_DCUT_PBASE_T_USBDI_1231_DUP25, "<Error> Action timeout");
            TestFailed(KErrTimedOut);
            }
        else
            {
            OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1231_DCUT_PBASE_T_USBDI_1231_DUP26, "<Error %d> Timeout timer could not complete",
                    completionCode);
            TestFailed(completionCode);
            }
        OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1231_HOSTRUNL_EXIT, this );
        }
예제 #8
0
	void Run()
	{	
		Regex r;
		std::string dump;
		
		JetHead::ErrCode err = r.prepare( gPrepareTests[ mTestNum ].regex );

		if ( gPrepareTests[ mTestNum ].pass && err != JetHead::kNoError )
			TestFailed( "Prepare returned error code" );
		else if ( gPrepareTests[ mTestNum ].pass == false && err == JetHead::kNoError )
			TestFailed( "Prepare did not return error code" );
			
		r.dumpTree( dump );
		if ( dump == gPrepareTests[ mTestNum ].tree )
			TestPassed();
		else
		{
			LOG_NOTICE( "dump is: %s", dump.c_str() );
			LOG_NOTICE( "expected: %s", gPrepareTests[ mTestNum ].tree );
			LOG_NOTICE( "on regex: %s", gPrepareTests[ mTestNum ].regex );
			TestFailed( "Tree dump miss-match" );
		}
	}
예제 #9
0
void CTPointerCapture::IncSubStateL(TBool aNeedsDD)
	{
	if (!aNeedsDD)
		{
		if (iDDState!=DDStateNull)
			TestFailed();
		else
			doIncSubStateL();
		}
	else if (iDDState==DDStateGot)
		doIncSubStateL();
	else
		iDDState=DDStateWaiting;
	}
예제 #10
0
    void test(const char* name, FUN jpeg_zigzag_fun) {
        printf("%20s... ", name);
        fflush(stdout);

        jpeg_zigzag_fun(in, out);
        for (int i=0; i < 64; i++) {
            if (i != out[i]) {
                printf("failed at %d\n", i);
                throw TestFailed();
            }
        }

        puts("OK");
    }
예제 #11
0
	void Run()
	{	
		Regex r;
		std::string dump;
		
		JetHead::ErrCode err = r.prepare( gParseTests[ mTestNum ].regex );

		if ( err != JetHead::kNoError )
			TestFailed( "Prepare returned error code" );

		bool res = r.parse( gParseTests[ mTestNum ].tree );
		
		if ( gParseTests[ mTestNum ].pass != res )
		{
			LOG_NOTICE( "Parse %s", res ? "succeeded" : "failed" );
			LOG_NOTICE( "string: %s", gParseTests[ mTestNum ].tree );
			LOG_NOTICE( "regex: %s", gParseTests[ mTestNum ].regex );
			TestFailed( "Parse failed to match expected result" );
		}			

		for ( int i = 0; i < 5; i++ )
		{
			if ( gParseTests[ mTestNum ].groups[ i ] != NULL )
			{
				std::string s = r.getData( i );
				if ( s != gParseTests[ mTestNum ].groups[ i ] )
				{
					LOG_NOTICE( "Got %s for group %d", s.c_str(), i );
					LOG_NOTICE( "Expected %s", gParseTests[ mTestNum ].groups[ i ] );
					TestFailed( "Group does not match" );
				}
			}
		}
		
		TestPassed();
	}
void CUT_PBASE_T_USBDI_0474::Ep0TransferCompleteL(TInt aCompletionCode)
	{
	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0474_EP0TRANSFERCOMPLETEL_ENTRY, this );
	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0474_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode);
	
	if(iCaseStep == EPassed)
		{
		TestPassed();
		}
		
	if(iCaseStep == EFailed)
		{
		TestFailed(KErrCompletion);
		}
	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0474_EP0TRANSFERCOMPLETEL_EXIT, this );
	}
예제 #13
0
파일: UnitTest.hpp 프로젝트: Sleen/Unnamed
		bool Run() {
			try {
				fun();
			}
			catch (const TestFailed& err) {
				this->err = err;
				return false;
			}
			catch (const Exception& ex) {
				this->err = TestFailed(ex.What(), ex.Where());
				return false;
			}
			catch (...) {
				return false;
			}

			return true;
		}
    void CUT_PBASE_T_USBDI_1231::Ep0TransferCompleteL(TInt aCompletionCode)
        {
        OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1231_EP0TRANSFERCOMPLETEL_ENTRY, this );
        OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1231_DCUT_PBASE_T_USBDI_1231_DUP23, "Ep0TransferCompleteL with aCompletionCode = %d",
                aCompletionCode);
        switch (iCaseStep)
            {

            default:
            case EFailed:
                TestFailed(KErrCompletion);
                break;

            case EPassed:
                TestPassed();
                break;
            }
        OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1231_EP0TRANSFERCOMPLETEL_EXIT, this );
        }
예제 #15
0
	void Run()
	{
		mTestState = 0;
		
		switch( mTestNum )
		{
			case 1:
				Func1();
				// Async Event give it 100ms to be recieved.				
				usleep( 100000 );
				if ( mTestState != 1 )
					TestFailed( "Event not recieved" );
				else if ( sEventCount != 0 )
					TestFailed( "Event count != 0 (%d)", sEventCount );					
				else
					TestPassed();
				break;
				
			case 2:
				Func2( 1, 2 );
				// Sync Event no need to sleep.
				if ( mTestState != 1 )
					TestFailed( "Event not recieved" );
				else if ( sEventCount != 0 )
					TestFailed( "Event count != 0 (%d)", sEventCount );					
				else
					TestPassed();
				break;

			case 3:
				int res = Func3( 3 );
				// Sync Event no need to sleep.
				if ( mTestState != 1 )
					TestFailed( "Event not recieved" );
				else if ( res != 1000 )
					TestFailed( "Result not valid" );					
				else if ( sEventCount != 0 )
					TestFailed( "Event count != 0 (%d)", sEventCount );					
				else
					TestPassed();
				break;
		}
	}	
void CUT_PBASE_T_USBDI_0486::DeviceRemovedL(TUint aDeviceHandle)
	{
	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_DEVICEREMOVEDL_ENTRY, this );
	Cancel();	
	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEREMOVEDL, "--->DeviceRemovedL, case step = %d", iCaseStep);

	switch(iCaseStep)
		{
		case EWaitForDeviceCDisconnection: // device C is disconnected now, interface 0 has been closed before
			{
			iCaseStep = EWaitForDeviceAConnection;
			iActorFDF->Monitor();
			}
			break;		
	
		default:
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEREMOVEDL_DUP01, "<Error> Test case actions out of sync");
			TestFailed(KErrCorrupt);
			break;
			}
	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_DEVICEREMOVEDL_EXIT, this );
	}
void CUT_PBASE_T_USBDI_0486::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
	{
	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL_ENTRY, this );
	Cancel();
	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL, "--->TransferCompleteL, case step = %d", iCaseStep);

	if(aTransferId == KBulkTranferId)
		{							
		if(aCompletionCode != KErrCancel && aCompletionCode != KErrUsbIOError)
			{
			TBuf<256> msg;
			msg.Format(_L("<Error %d> The transfer completed with no errors but should have done so"),aCompletionCode);
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL_DUP01, msg);
			TTestCaseFailed request(KErrCorrupt,msg);
			return iControlEp0->SendRequest(request,this);
			} 					
		}
	else
		{
		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL_DUP02, "<Error> a transfer completed (id=%d) that was not expected",aTransferId);
		return TestFailed(KErrCorrupt);
		}	
	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_TRANSFERCOMPLETEL_EXIT, this );
	}	
void CUT_PBASE_T_USBDI_0481::DeviceInsertedL(TUint aDeviceHandle)
	{
    OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0481_DEVICEINSERTEDL_ENTRY, this );

	// Cancel the timeout timer	
	Cancel();
	
	TInt err(KErrNone);
	
	// Validate that device is as expected	
	CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle);
	if(testDevice.SerialNumber().Compare(TestCaseId()) != 0)
		{
		// Incorrect device for this test case
		OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_0481_DEVICEINSERTEDL, "<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)",
			KErrNotFound,testDevice.SerialNumber(),TestCaseId());

		// Start the connection timeout again
		TimeoutIn(30);
		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0481_DEVICEINSERTEDL_EXIT, this );
		return;
		}	
	
	// Get the token for interface 0	
	err = testDevice.Device().GetTokenForInterface(0,iToken0);
	if(err != KErrNone)
		{
		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0481_DEVICEINSERTEDL_DUP01, "<Error %d> Unable to retrieve token for interface 0",err);
		TestFailed(err);
		}
	
	// Open interface 0
	err = iUsbInterface0.Open(iToken0);
	if(err != KErrNone)
		{
		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0481_DEVICEINSERTEDL_DUP02, "<Error %d> Unable to open interface 0", err);
		TestFailed(err);
		}
		
		// Get the token for interface 1	
	TUint32 token1(0);
	err = testDevice.Device().GetTokenForInterface(1,token1);
	if(err != KErrNone)
		{
		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0481_DEVICEINSERTEDL_DUP03, "<Error %d> token1 for interface 1",err);
		return TestFailed(err);
		}
	// Open interface 1
	err = iUsbInterface1.Open(token1); // Alternate interface setting 0
	if(err != KErrNone)
		{
		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0481_DEVICEINSERTEDL_DUP04, "<Error %d> Unable to open interface 1", err);
		return TestFailed(err);
		}

	// Get the token for interface 1 again, fails
	TUint32 token1Bis(0);
	err = testDevice.Device().GetTokenForInterface(1,token1Bis);
	if(err != KErrInUse)
		{
		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0481_DEVICEINSERTEDL_DUP05, "GetTokenForInterface(1,token1Bis), err != KErrInUse");
		return TestFailed(err);
		}
		
	// Open interface 1 again, fails
	OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0481_DEVICEINSERTEDL_DUP06, "open it twice, catch error Code");
	err = iUsbInterface1.Open(token1); // Alternate interface setting 0
	if(err != KErrInUse)
		{
		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0481_DEVICEINSERTEDL_DUP07, "iUsbInterface1.Open(token1), err != KErrInUse");
		return TestFailed(err);
		}

	// test ok
	User::After(1000000);
	iCaseStep = EPassed;
	TTestCasePassed request;
	iControlEp0->SendRequest(request,this);	
	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0481_DEVICEINSERTEDL_EXIT_DUP01, this );
	}
void CUT_PBASE_T_USBDI_0484::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
{
    OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_ENTRY, this );
    Cancel();
    TInt err(KErrNone);
    OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL, "Transfer completed (id=%d), aCompletionCode = %d",aTransferId, aCompletionCode);

    if(aTransferId == KBulkTransferId1)
    {
        if(iCaseStep == EStalled)
        {
            if(aCompletionCode != KErrUsbStalled)
            {
                TBuf<256> msg;
                msg.Format(_L("<Error %d> The transfer completed with no errors but should have stalled"),aCompletionCode);
                OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_DUP01, msg);
                TTestCaseFailed request(KErrCorrupt,msg);
                return iControlEp0->SendRequest(request,this);
            }
            else
            {
                // Acknowledge the stall and clear
                err = iTestPipeInterface1BulkIn.ClearRemoteStall();
                if(err != KErrNone)
                {
                    TBuf<256> msg;
                    msg.Format(_L("<Error %d> The remote stall cannot be cleared"),err);
                    OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_DUP02, msg);
                    iCaseStep = EFailed;
                    TTestCaseFailed request(err,msg);
                    return iControlEp0->SendRequest(request,this);
                }

                // try to get data now, after EP has been stalled
                OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_DUP03, "try to get data now, after EP has been stalled");
                iInTransfer[0]->TransferIn(KDataPayload1().Length());
                iInTransfer[1]->TransferIn(KDataPayload2().Length());
                iInTransfer[2]->TransferIn(KDataPayload3().Length());

                iCaseStep = ETransferAfterStall;
                TEndpointWriteRequest request(1,1,KDataPayload1);// EP1 because 1st writter EP
                iControlEp0->SendRequest(request,this);
                OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_EXIT, this );
                return;
            }
        }
        if(iCaseStep == ETransferAfterStall)
        {
            if(aCompletionCode != KErrNone)
            {
                TBuf<256> msg;
                msg.Format(_L("<Error %d> No data got after EP2 being stalled"),aCompletionCode);
                OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_DUP04, msg);
                iCaseStep = EFailed;
                TTestCaseFailed request(err,msg);
                return iControlEp0->SendRequest(request,this);
            }

            // else ok, compare data rcvd now
            TPtrC8 data(iInTransfer[0]->DataPolled());
            // Compare the data to what is expected
            if(data.Compare(KDataPayload1) != 0)
            {
                TBuf<256> msg;
                msg.Format(_L("<Error %d> Interrupt data received does not match data sent"),KErrCompletion);
                OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_DUP05, msg);
                iCaseStep = EFailed;
                TTestCaseFailed request(KErrCompletion,msg);
                return iControlEp0->SendRequest(request,this);
            }
            // Comparison is a match, wait for next transfer
            OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_DUP06, "Comparison is a match, wait for transfer 2");
            User::After(500000);
            TEndpointWriteRequest request(1,1,KDataPayload2);// EP1 because 1st writter EP
            iControlEp0->SendRequest(request,this);
        }
    }
    else if(aTransferId == KBulkTransferId2)
    {
        if(aCompletionCode != KErrNone)
        {
            TBuf<256> msg;
            msg.Format(_L("<Error %d> No data got after EP2 being stalled"),aCompletionCode);
            OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_DUP07, msg);
            iCaseStep = EFailed;
            TTestCaseFailed request(err,msg);
            return iControlEp0->SendRequest(request,this);
        }

        // else ok, compare data rcvd now
        TPtrC8 data(iInTransfer[1]->DataPolled());
        // Compare the data to what is expected
        if(data.Compare(KDataPayload2) != 0)
        {
            TBuf<256> msg;
            msg.Format(_L("<Error %d> Interrupt data received does not match data sent"),KErrCompletion);
            OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_DUP08, msg);
            iCaseStep = EFailed;
            TTestCaseFailed request(KErrCompletion,msg);
            return iControlEp0->SendRequest(request,this);
        }
        // Comparison is a match, wait for next transfer
        OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_DUP09, "Comparison is a match, wait for transfer 3");
        User::After(500000);
        TEndpointWriteRequest request(1,1,KDataPayload3);// EP1 because 1st writter EP
        iControlEp0->SendRequest(request,this);
    }
    else if(aTransferId == KBulkTransferId3)
    {
        if(aCompletionCode != KErrNone)
        {
            TBuf<256> msg;
            msg.Format(_L("<Error %d> No data got after EP2 being stalled"),aCompletionCode);
            OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_DUP10, msg);
            iCaseStep = EFailed;
            TTestCaseFailed request(err,msg);
            return iControlEp0->SendRequest(request,this);
        }
        // else ok, compare data rcvd now
        TPtrC8 data(iInTransfer[2]->DataPolled());
        // Compare the data to what is expected
        if(data.Compare(KDataPayload3) != 0)
        {
            TBuf<256> msg;
            msg.Format(_L("<Error %d> Interrupt data received does not match data sent"),KErrCompletion);
            OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_DUP11, msg);
            iCaseStep = EFailed;
            TTestCaseFailed request(KErrCompletion,msg);
            return iControlEp0->SendRequest(request,this);
        }
        // Comparison is a match, test passes
        iCaseStep = EPassed;
        TTestCasePassed request;
        return iControlEp0->SendRequest(request,this);
    }
    else
    {
        OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_DUP12, "<Error> a transfer completed (id=%d) that was not expected",aTransferId);
        return TestFailed(KErrCorrupt);
    }
    OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0484_TRANSFERCOMPLETEL_EXIT_DUP01, this );
}
void CUT_PBASE_T_USBDI_0486::DeviceInsertedL(TUint aDeviceHandle)
	{
	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_ENTRY, this );
	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL, "--->DeviceInsertedL, case step = %d", iCaseStep);

	// Cancel the timeout timer	
	Cancel();	
	TInt err(KErrNone);
	
	// Validate that device is as expected	
	CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle);

	// Perform the correct test step		
	switch(iCaseStep)
		{
		case EWaitForDeviceCConnection:
			{
			if(!CheckSN(testDevice.SerialNumber(), KTestDeviceC_SN()))
				{
				return TestFailed(KErrNotFound);
				}
			iCaseStep = EDeviceCConnected;
			
			err = testDevice.Device().GetTokenForInterface(0,iToken0DeviceC);
			if(err != KErrNone)
				{
				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP01, "<Error %d> Unable to retrieve token for interface 0",err);
				TestFailed(err);
				} 
			// Open the interface	
			err = iUsbInterface0.Open(iToken0DeviceC);
			if(err != KErrNone)
				{
				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP02, "<Error %d> Unable to open interface 0", err);
				TestFailed(err);
				}
				
			TUint32 token1;
			err = testDevice.Device().GetTokenForInterface(1,token1);
			if(err != KErrNone)
				{
				TBuf<256> msg;
				msg.Format(_L("<Error %d> Token for interface 1 could not be retrieved"),err);
				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP03, msg);
				iCaseStep = EFailed;
				TTestCaseFailed request(err,msg);
				return iControlEp0->SendRequest(request,this);
				}
				
				
			err = iUsbInterface1.Open(token1); // Default interface setting 0
			if(err != KErrNone)
				{
				TBuf<256> msg;
				msg.Format(_L("<Error %d> Unable to open interface 1 using token %d"),err,token1);
				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP04, msg);
				iCaseStep = EFailed;
				TTestCaseFailed request(err,msg);
				return iControlEp0->SendRequest(request,this);
				}
				
			TInt endpointAddress;
			// Queue a bulk in transfer on endpoint 2	
			err = GetEndpointAddress(iUsbInterface1,0,KTransferTypeBulk,KEpDirectionIn,endpointAddress);
			if(err != KErrNone)
				{
				TBuf<256> msg;
				msg.Format(_L("<Error %d> Address for bulk in endpoint could not be obtained"),err);
				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP05, msg);
				iCaseStep = EFailed;
				TTestCaseFailed request(err,msg);
				return iControlEp0->SendRequest(request,this);
				}
			OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP06, "Endpoint adress %08x",endpointAddress);
	
			err = iUsbInterface1.OpenPipeForEndpoint(iTestPipeInterface1BulkIn,endpointAddress,ETrue);
			if(err != KErrNone)
				{
				TBuf<256> msg;
				msg.Format(_L("<Error %d> Unable to open pipe for endpoint %08x"),err,endpointAddress);
				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP07, msg);
				iCaseStep = EFailed;
				TTestCaseFailed request(err,msg);
				return iControlEp0->SendRequest(request,this);
				}
			
			// Create the bulk transfers	
			iInTransfer[0] = new (ELeave) CBulkTransfer(iTestPipeInterface1BulkIn,iUsbInterface1,256,*this, KBulkTranferId);
		
			// Initialise the descriptors for transfer		
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP08, "Initialising the transfer descriptors");
			err = iUsbInterface1.InitialiseTransferDescriptors();
			if(err != KErrNone)
				{
				TBuf<256> msg;
				msg.Format(_L("<Error %d> Unable to initialise transfer descriptors"),err);
				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP09, msg);
				iCaseStep = EFailed;
				TTestCaseFailed request(err,msg);
				return iControlEp0->SendRequest(request,this);
				}				
			iInTransfer[0]->TransferIn(KExpectedDataSize);
					
			// 	disconnect device C and connect device A								
			TDisconnectDeviceCThenConnectDeviceARequest request;
			iControlEp0->SendRequest(request,this);	
	        										
			// Monitor for the reconnection from the client		
			iActorFDF->Monitor();
			TimeoutIn(30);
						
			}
			break; 
					
		case EWaitForDeviceAConnection:
			{
			if(!CheckSN(testDevice.SerialNumber(), TestCaseId()))
				{
				return TestFailed(KErrNotFound);
			    }
			// try to open interface 0			
			err = iUsbInterface0.Open(iToken0DeviceC);
			if(err != KErrNotFound) // invalid token
				{
				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP10, "iUsbInterface0.Open(iToken0DeviceC) === %d", err);
				TestFailed(err);
				}
			
			// get token now 
			TUint32 token0DeviceA; 
			err = testDevice.Device().GetTokenForInterface(0,token0DeviceA);
			if(err != KErrNone)
				{
				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP11, "<Error %d> Unable to retrieve token(device A) for interface 0",err);
				TestFailed(err);
				} 
			// Open the interface	
			err = iUsbInterface0.Open(token0DeviceA);
			if(err != KErrNone)
				{
				OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP12, "<Error %d> Unable to open interface 0(device A)", err);
				TestFailed(err);
				}
			
			// ok, send EPassed request			
			iCaseStep = EPassed;
			// Send test case passed request to client
			User::After(2000000);	
			TTestCasePassed request;
			iControlEp0->SendRequest(request,this);			
			} 
			break;
			
		default:
			{
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_DUP13, "<Error> Test case actions out of sync");
			TestFailed(KErrCorrupt);
			}	
			break;
		}	
	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0486_DEVICEINSERTEDL_EXIT, this );
	}
void CUT_PBASE_T_USBDI_0480::Ep0TransferCompleteL(TInt aCompletionCode)
	{
	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0480_EP0TRANSFERCOMPLETEL_ENTRY, this );
	
	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode);
	
	if(aCompletionCode != KErrNone)
		{
		if(iCaseStep == EFailed)
			{
			}
		else
			{
			TBuf<256> msg;
			msg.Format(_L("<Error %d> Transfer to control endpoint 0 was not successful"),aCompletionCode);
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_EP0TRANSFERCOMPLETEL_DUP01, msg);
			iCaseStep = EFailed;
			TTestCaseFailed request(aCompletionCode,msg);
			iControlEp0->SendRequest(request,this);
			OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_EP0TRANSFERCOMPLETEL_EXIT, this );
			return;
			}
		}
	
	switch(iCaseStep)
		{
		// Test case passed	
		case EPassed:
			TestPassed();
			break; 
		
		// Test case failed		
		case EFailed:
			TestFailed(KErrCompletion);
			break;
			
		// Send an empty interface directed request		
		case EEmptyDeviceXfer:
			{
			iCaseStep = EEmptyInterfaceXfer;
			TEmptyInterfaceRequest request(1); // Direct at interface 1
			iControlEp0->SendRequest(request,this);
			}
			break;	
		
		// Send a test payload request to device directed 		
		case EEmptyInterfaceXfer:
			{
			iCaseStep = EDataPutDeviceXfer;
			TDevicePutPayloadRequest request(KDataPayload);
			iControlEp0->SendRequest(request,this);
			}
			break;
			
		// Send a test payload request to interface directed		
		case EDataPutDeviceXfer:
			{
			iCaseStep = EDataPutInterfaceXfer;
			TInterfacePutPayloadRequest request(1,KDataPayload); // Direct at interface 1
			iControlEp0->SendRequest(request,this);
			}
			break;
			
		// Test case passed		
		case EDataPutInterfaceXfer:
			{
			iCaseStep = EPassed;
			User::After(1000000);
			TTestCasePassed request;
			iControlEp0->SendRequest(request,this);			
			}
			break;
			
		default:
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_EP0TRANSFERCOMPLETEL_DUP02, "<Error> Unknown test step");
			TestFailed(KErrUnknown);
			break;
		}
	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_EP0TRANSFERCOMPLETEL_EXIT_DUP01, this );
	}
    void CUT_PBASE_T_USBDI_1231::DeviceInsertedL(TUint aDeviceHandle)
        {
        OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_1231_DEVICEINSERTEDL_ENTRY, this );

        OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1231_DCUT_PBASE_T_USBDI_1231_DUP04, "====> DeviceInsertedL entry priority = %d", RThread().Priority());
        
        iInterface0Resumed = EFalse;
        
        Cancel(); // Cancel the timer
        TInt err(KErrNone);
        iDeviceHandle = aDeviceHandle;
        iActorFDF->Monitor();

        // Validate that device is as expected
        CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle);
        if (testDevice.SerialNumber().Compare(TestCaseId()) != 0)
            {
            // Incorrect device for this test case

            RDebug::Printf(
                    "<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)",
                    KErrNotFound, &testDevice.SerialNumber(), &TestCaseId());

            // Start the connection timeout again
            TimeoutIn(30);
            OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1231_DEVICEINSERTEDL_EXIT, this );
            return;
            }
        // Check tree now    
        CHECK(CheckTreeAfterDeviceInsertion(testDevice, _L("RDeviceA")) == KErrNone);

        // Perform the correct test step                
        switch (iCaseStep)
            {
            case EInProcess:
                {
                TUint32 token1(0);
                TUint32 token2(0);

                OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1231_DCUT_PBASE_T_USBDI_1231_DUP05, "Obtaining token for interface 0");
                err = testDevice.Device().GetTokenForInterface(0, token1);
                if (err != KErrNone)
                    {
                    RDebug::Printf(
                            "<Error %d> Token for interface 0 could not be retrieved",
                            err);
                    return TestFailed(err);
                    }
                OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_1231_DCUT_PBASE_T_USBDI_1231_DUP06, "Token 1 (%d) retrieved", token1);
                OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1231_DCUT_PBASE_T_USBDI_1231_DUP07, "Opening interface 0");
                err = iUsbInterface0.Open(token1); // Alternate interface setting 0
                if (err != KErrNone)
                    {
                    RDebug::Printf(
                            "<Error %d> Interface 0 could not be opened", err);
                    return TestFailed(err);
                    }
                OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1231_DCUT_PBASE_T_USBDI_1231_DUP08, "Interface 0 opened");

                OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1231_DCUT_PBASE_T_USBDI_1231_DUP09, "Obtaining token for interface 1");
                err = testDevice.Device().GetTokenForInterface(1, token2);
                if (err != KErrNone)
                    {
                    RDebug::Printf(
                            "<Error %d> Token for interface 1 could not be retrieved",
                            err);
                    return TestFailed(err);
                    }
                OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1231_DCUT_PBASE_T_USBDI_1231_DUP10, "Opening interface 1");
                err = iUsbInterface1.Open(token2); // Alternate interface setting 0
                if (err != KErrNone)
                    {
                    RDebug::Printf(
                            "<Error %d> Interface 1 could not be opened", err);
                    return TestFailed(err);
                    }
                OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_1231_DCUT_PBASE_T_USBDI_1231_DUP11, "Interface 1 opened");

                ResumeWhenSuspending();

                }
                break;

            default:
                TestFailed(KErrCorrupt);
                break;
            }
        OstTraceFunctionExit1( CUT_PBASE_T_USBDI_1231_DEVICEINSERTEDL_EXIT_DUP01, this );
        }
void CUT_PBASE_T_USBDI_0480::DeviceInsertedL(TUint aDeviceHandle)
	{
	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_ENTRY, this );
	
	Cancel();
	TInt err(KErrNone);
	
	// Validate that device is as expected
	CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle);
	if(testDevice.SerialNumber().Compare(TestCaseId()) != 0)
		{
		// Incorrect device for this test case	

		OstTraceExt3(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL, "<Warning %d> Incorrect device serial number (%S) connected for this test case (%S)",
			KErrNotFound,testDevice.SerialNumber(),TestCaseId());

		// Start the connection timeout again
		TimeoutIn(30);
		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_EXIT, this );
		return;
		}

	TUint32 token0,token1;
	
	err = testDevice.Device().GetTokenForInterface(0,token0);
	if(err != KErrNone)
		{
		OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_DUP01, "<Error %d> Token for interface 0 could not be retrieved",err);
		return TestFailed(err);
		}
	err = iUsbInterface0.Open(token0); // Default interface setting 0
	if(err != KErrNone)
		{
		OstTraceExt2(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_DUP02, "<Error %d> Unable to open interface 0 using token %d",err,token0);
		return TestFailed(err);
		}
	
	err = testDevice.Device().GetTokenForInterface(1,token1);
	if(err != KErrNone)
		{
		TBuf<64> msg;
		msg.Format(_L("<Error %d> Token for interface 1 could not be retrieved"),err);
		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_DUP03, msg);
		iCaseStep = EFailed;
		TTestCaseFailed request(err,msg);
		iControlEp0->SendRequest(request,this);
		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_EXIT_DUP01, this );
		return;
		}
	err = iUsbInterface1.Open(token1);
	if(err != KErrNone)
		{
		TBuf<256> msg;
		msg.Format(_L("<Error %d> Unable to open interface 1 using token %d"),err,token1);
		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_DUP04, msg);
		iCaseStep = EFailed;
		TTestCaseFailed request(err,msg);
		iControlEp0->SendRequest(request,this);
		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_EXIT_DUP02, this );
		return;
		}
	
	// Get the endpoint descriptor
	TUsbEndpointDescriptor endpointDescriptor;

	err = iUsbInterface1.GetEndpointDescriptor(0,1,endpointDescriptor);
	if(err != KErrNone)
		{
		TBuf<256> msg;
		msg.Format(_L("<Error %d> Descriptor for endpoint 0 cannot be obtained"),err);
		OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_DUP05, msg);
		iCaseStep = EFailed;
		TTestCaseFailed request(err,msg);
		iControlEp0->SendRequest(request,this);
		OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_EXIT_DUP03, this );
		return;
		}
	TUint16 maxPacketSize(endpointDescriptor.MaxPacketSize());
	
	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_DUP06, "Maximum packet size for endpoint 1 on interface 1 setting 0 is: %d",maxPacketSize);
	
	// Perform a device directed control transfer
	User::After(1000000);	
	iCaseStep = EEmptyDeviceXfer;
	TEmptyDeviceRequest request;
	iControlEp0->SendRequest(request,this);
	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0480_DEVICEINSERTEDL_EXIT_DUP04, this );
	}
예제 #24
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int main (int argc, char*  argv[])
{
  // Instantiate the QCoreApplication that we need to get the current path and load plugins.
  QCoreApplication app(argc, argv);
  QCoreApplication::setOrganizationName("BlueQuartz Software");
  QCoreApplication::setOrganizationDomain("bluequartz.net");
  QCoreApplication::setApplicationName("PipelineRunnerTest");


  // We need to change our working directory into the "DREAM3D_Data" directory because all the pipelines use relative paths
  QDir dataDir = QDir(getDream3dDataDir());
#ifdef _MSC_VER
  _chdir(dataDir.absolutePath().toLatin1().constData());
#else
  chdir(dataDir.absolutePath().toLatin1().constData());
#endif


  // Register all the filters including trying to load those from Plugins
  FilterManager* fm = FilterManager::Instance();
  SIMPLibPluginLoader::LoadPluginFilters(fm);

  // Send progress messages from PipelineBuilder to this object for display
  QMetaObjectUtilities::RegisterMetaTypes();


  int err = 0;
  // Read in the contents of the PipelineList file which contains all the Pipelines that we want
  // to execute
  QString contents;
  {
    // Read the Source File
    QFileInfo fi(getPipelineListFile());
    QFile source(getPipelineListFile());
    source.open(QFile::ReadOnly);
    contents = source.readAll();
    source.close();
  }
  // Split the file into tokens using the newline character
  QStringList list = contents.split(QRegExp("\\n"));
  QStringListIterator sourceLines(list);

  // Iterate over all the entries in the file and process each pipeline. Note that the order of the
  // pipelines will probably matter
  int testNum = 0;
  while (sourceLines.hasNext())
  {
    QString pipelineFile = sourceLines.next();
    pipelineFile = pipelineFile.trimmed();
    if(pipelineFile.isEmpty()) { continue; }
    try
    {
      QFileInfo fi(pipelineFile);

      pipelineFile = AdjustOutputDirectory(pipelineFile);

      DREAM3D::unittest::CurrentMethod = fi.fileName().toStdString();
      DREAM3D::unittest::numTests++;

      std::cout << "\"" << testNum++ << "\": {" << std::endl;

      ExecutePipeline(pipelineFile);

      TestPassed(fi.fileName().toStdString());
      std::cout << "}," << std::endl;
      DREAM3D::unittest::CurrentMethod = "";
    }
    catch (TestException& e)
    {
      TestFailed(DREAM3D::unittest::CurrentMethod);
      std::cout << e.what() << std::endl;
      err = EXIT_FAILURE;
    }
  }

  QDir tempDir(getTestTempDirectory());
  tempDir.removeRecursively();

  return err;
}
예제 #25
0
// handle event completion	
void CTestCase0676::RunStepL()
	{
	if(gVerboseOutput)
	    {
	    OstTraceFunctionEntry0(CTESTCASE0676_RUNSTEPL);
	    }
	// Obtain the completion code for this CActive obj.
	TInt completionCode(iStatus.Int()); 
	TBuf<MAX_DSTRLEN> aDescription;
	TInt err(0);


	switch(iCaseStep)
		{
		case EPreconditions:
			iCaseStep = ELoadLdd;
			if (iAutomated)
				{
				iCaseStep = ELoadLdd;
				SelfComplete();
				break;
				}
			// prompt to insert connector
			test.Printf(KInsertAConnectorPrompt);
			OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP01, KInsertAConnectorPrompt);
			test.Printf(KPressAnyKeyToContinue);
			OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP02, KPressAnyKeyToContinue);
			RequestCharacter();			
			break;
			
		case ELoadLdd:
			// 1. load the LDD and init.
			if (!StepLoadLDD())
				{
				break;
				}
			iCaseStep = EDetectAPlug;
			SelfComplete();
			break;
			
			// 2. detect 'A' plug now
		case EDetectAPlug:
			if (KTestCaseWatchdogTO == iStatus.Int())
				{
				return TestFailed(KErrAbort, _L("User response too slow - FAILED!"));
				}

			// if doing this test in /AUTO mode, we would fail this now
			// however if we can control ID_PIN through an API in future, we turn in on now.
			if (!otgIdPinPresent())
				{
				test.Printf(KInsertAConnectorPrompt);
				OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP03, KInsertAConnectorPrompt);
				test.Printf(KPressAnyKeyToContinue);
				OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP04, KPressAnyKeyToContinue);
				RequestCharacter();

				iCaseStep = EDetectAPlug;
				}
			else
				{
				iCaseStep = ELoopDriveVBus;
				SelfComplete();
				}
			break;
			
			// 3. Control/branch step in the loop
		case ELoopControl:
			if (--iRepeats)
				{
				iCaseStep = ELoopDriveVBus;
				}
			else
				{
				iCaseStep = EUnloadLdd;
				}
			SelfComplete();
			break;
			
		case ELoopDriveVBus:
			// 4. DRIVE VBUS
			iWDTimer->Cancel();
			test.Printf(_L("Drive VBus, iteration %d/%d\n"), OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
			OstTraceExt2(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP05, "Drive VBus, iteration %d/%d\n", OPEN_REPEATS-iRepeats+1, OPEN_REPEATS);
			// test for VBus rise next
			test.Printf(_L("Waiting for VBus Event\n"));
			OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP06, "Waiting for VBus Event\n");
			iStatus = KRequestPending;
			otgQueueOtgVbusNotification( iOTGVBus, iStatus );

			// turn on VBus, since the call is not a Queing a-sync call we do this after the async call
			err = otgBusRequest();	// ok to turn on VBus now
			if (KErrNone != err)
				{
				return TestFailed(KErrAbort, _L("Raise Vbus - RUsbOtgDriver::BusRequest() FAILED!"));
				}
			iCaseStep = ELoopVerifyVBus;
			iWDTimer->IssueRequest(KDelayDurationForLocalTrigger, this, &CancelNotify);
			SetActive();
			break;
			
		case ELoopVerifyVBus:
			// 5. get VBus rise event
			if (KTestCaseWatchdogTO == iStatus.Int())
				{
				return TestFailed(KErrAbort, _L("Vbus rise not signalled in time - FAILED!"));
				}
			iWDTimer->Cancel();

			otgQueueOtgVbusNotification( iOTGVBus, iStatus );
			otgCancelOtgVbusNotification();
			User::WaitForRequest(iStatus);


			if (iOTGVBus != RUsbOtgDriver::EVbusHigh)
				{
		
				return TestFailed(KErrAbort, _L("Vbus rise NOT 'seen' - FAILED!"));
				}

			// Double-check using the API in a syncronous way too
			// NOTE: once again this is to explore timing issues
			if (!otgVbusPresent())
				{
				return TestFailed(KErrAbort, _L("Vbus syncronous call error - FAILED!"));
				}
			iCaseStep = ELoopWait;
			SelfComplete();
			break;
			
		case ELoopWait:	// 6. wait 50ms after applying Vbus before we are allowed to 
			ContinueAfter(KDelayBeforeBusDropUs, ELoopDropVBus);
			break;
			
		case ELoopDropVBus:
			// 7. drop Bus
			otgQueueOtgVbusNotification(iOTGVBus, iStatus );
			// drop Vbus now, since the call is not a Queing a-sync call we do this after the async call
			otgBusDrop();
			SetActive();
			iCaseStep = ELoopVerifyDrop;
			iWDTimer->IssueRequest(KDelayDurationForLocalTrigger, this, &CancelNotify);
			break;
			
		case ELoopVerifyDrop:
			// 8. get Vbus low event
			if (KTestCaseWatchdogTO == iStatus.Int())
				{
				return TestFailed(KErrAbort, _L("Vbus drop not signalled in time - FAILED!"));
				}
			iWDTimer->Cancel();

			// fetch the value			
			otgQueueOtgVbusNotification( iOTGVBus, iStatus );
			otgCancelOtgVbusNotification();
			User::WaitForRequest(iStatus);

			if (iOTGVBus != RUsbOtgDriver::EVbusLow)
				{
				return TestFailed(KErrAbort, _L("Vbus drop NOT 'seen' - FAILED!"));
				}
				
			// test again using the 'syncronous' variation
			if (otgVbusPresent())
				{
				return TestFailed(KErrAbort, _L("Vbus syncronous call error - FAILED!"));
				}
				
			// wait 50ms and then go back to beginning
			ContinueAfter(KDelayBeforeBusDropUs, ELoopControl);
			break;
			
		case EUnloadLdd:
			// 9. unload
			if (EFalse == StepUnloadLDD())
				return TestFailed(KErrAbort,_L("unload Ldd failure"));	
			
			iCaseStep = ELastStep;
			SelfComplete();
			break;
			
		case ELastStep:
			TestPassed();
			break;
			
		default:
			test.Printf(_L("<Error> unknown test step"));
			OstTrace0(TRACE_NORMAL, CTESTCASE0676_RUNSTEPL_DUP07, "<Error> unknown test step");
			Cancel();
			return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
		}
	}
예제 #26
0
// handle event completion
void CTestCase0469::RunStepL()
{
    if(gVerboseOutput)
    {
        OstTraceFunctionEntry0(CTESTCASE0469_RUNSTEPL);
    }
    // Obtain the completion code for this CActive obj.
    TInt completionCode(iStatus.Int());
    TBuf<MAX_DSTRLEN> aDescription;
    //	15 seconds, should be plenty of time for 3 cycles of plug pulling
    const TInt KTestCase0469Timeout = 15000;

    switch(iCaseStep)
    {
    case EPreconditions:
        LOG_STEPNAME(_L("EPreconditions"))
        iCaseStep = ELoadLdd;
        // prompt to insert connectors
        test.Printf(KInsertBCablePrompt);
        OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP01, KInsertBCablePrompt);
        test.Printf(KRemoveAFromPC);
        OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP02, KRemoveAFromPC);
        test.Printf(KPressAnyKeyToContinue);
        OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP03, KPressAnyKeyToContinue);
        RequestCharacter();
        break;

    case ELoadLdd:
        LOG_STEPNAME(_L("ELoadLdd"))
        if (!StepLoadClient(0xF678/*use default settings for SRP/HNP support*/))
        {
            return TestFailed(KErrAbort, _L("Client Load Failure"));
        }

        if (!StepLoadLDD())
        {
            return TestFailed(KErrAbort, _L("OTG Load Failure"));
        }

        // subscribe to OTG states,events and messages now that it has loaded OK
        TRAPD(result, iCollector.CreateObserversL(*this));
        if (KErrNone != result)
        {
            return(TestFailed(KErrNoMemory, _L("Unable to create observers")));
        }
        iCollector.ClearAllEvents();

        iCaseStep = ELoopControl;

        iCollector.AddStepTimeout(KTestCase0469Timeout);

        SelfComplete();
        break;

    case ELoopControl:
        LOG_STEPNAME(_L("ELoopControl"))

        // Check for timeout
        if (KTestCaseWatchdogTO == iStatus.Int())
        {
            iCollector.DestroyObservers();
            return TestFailed(KErrAbort, _L("Timeout"));
        }

        if (iRepeats--)
        {
            OstTrace1(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP04, "ELoopControl around again %d", iRepeats);
            iCaseStep = ETestVbusRise;
        }
        else
        {
            OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP05, "ELoopControl we're done");
            iCaseStep = EUnloadLdd;
        }
        SelfComplete();
        break;

    case ETestVbusRise:
        LOG_STEPNAME(_L("ETestVbusRise"))
        // Check for timeout
        if (KTestCaseWatchdogTO == iStatus.Int())
        {
            iCollector.DestroyObservers();
            return TestFailed(KErrAbort, _L("Timeout"));
        }

        iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusRaised);
        iCaseStep = ETestVbusFall;
        test.Printf(KInsertAIntoPC);
        OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP06, KInsertAIntoPC);
        SetActive();
        break;

    case ETestVbusFall:
        LOG_STEPNAME(_L("ETestVbusFall"))
        // Check for timeout
        if (KTestCaseWatchdogTO == iStatus.Int())
        {
            iCollector.DestroyObservers();
            return TestFailed(KErrAbort, _L("Timeout"));
        }

        iCollector.AddRequiredNotification(EWatcherEvent, RUsbOtgDriver::EEventVbusDropped);
        iCaseStep = ELoopControl;
        test.Printf(KRemoveAFromPC);
        OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP07, KRemoveAFromPC);
        SetActive();
        break;

    case EUnloadLdd:
        LOG_STEPNAME(_L("EUnloadLdd"))
        iCollector.DestroyObservers();
        OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP08, "Destroyed observers");
        if (EFalse == StepUnloadLDD())
            return TestFailed(KErrAbort,_L("unload Ldd failure"));
        OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP09, "unloaded ldd");
        if (!StepUnloadClient())
            return TestFailed(KErrAbort,_L("Client Unload Failure"));
        OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP10, "unloaded client");

        iCaseStep = ELastStep;
        SelfComplete();
        break;

    case ELastStep:
        LOG_STEPNAME(_L("ELastStep"))
        TestPassed();
        break;

    default:
        test.Printf(_L("<Error> unknown test step"));
        OstTrace0(TRACE_NORMAL, CTESTCASE0469_RUNSTEPL_DUP11, "<Error> unknown test step");
        Cancel();
        return (TestFailed(KErrCorrupt, _L("<Error> unknown test step")));
    }
}
void CUT_PBASE_T_USBDI_0498::Ep0TransferCompleteL(TInt aCompletionCode)
	{
	OstTraceFunctionEntryExt( CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_ENTRY, this );
	
	OstTrace1(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL, "Ep0TransferCompleteL with aCompletionCode = %d",aCompletionCode);
	
	if(aCompletionCode != KErrNone)
		{
		if(iCaseStep == EFailed)
			{// ignore error, nad catch the TestFailed method called further down.
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP01, "***Failure sending FAIL message to client on endpoint 0***");
			}
		else
			{
			TBuf<256> msg;
			msg.Format(_L("<Error %d> Transfer to control endpoint 0 was not successful"),aCompletionCode);
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP02, msg);
			iCaseStep = EFailed;
			TTestCaseFailed request(aCompletionCode,msg);
			iControlEp0->SendRequest(request,this);
			OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_EXIT, this );
			return;
			}
		}
	
	switch(iCaseStep)
		{
		// Test case passed
		case EPassed:
			TestPassed();
			break;
		
		// Test case failed	
		case EFailed:
			TestFailed(KErrCompletion);
			break;
		
		case ERequestDeviceIFC1Read:
			{
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP03, "Asking client for 'Read' on interface 2");
			iCaseStep = ERequestDeviceIFC2Read;	
			TEndpointReadRequest request(2,1,KDeviceNumReadBytes);// EP1 means endpoint index 1 not the actual endpoint number
			iControlEp0->SendRequest(request,this);
			}
			break;
			
		case ERequestDeviceIFC2Read:
			{
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP04, "Asking client to 'Write' on interface 1");
			iCaseStep = ERequestDeviceIFC1Write;	
			TEndpointPatternWriteRequest request(1,1,KLiteralFrench4(),KDeviceNumWriteBytes);
			iControlEp0->SendRequest(request,this);
			}
			break;
			
		case ERequestDeviceIFC1Write:
			{
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP05, "Asking client to 'Write' on interface 2");
			iCaseStep = ERequestDeviceIFC2Write;	
			TEndpointPatternWriteRequest request(2,1,KLiteralEnglish2(),KDeviceNumWriteBytes);
			iControlEp0->SendRequest(request,this);
			}
			break;
			
		case ERequestDeviceIFC2Write:
			{
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP06, "Try to perform ALL transfers on BOTH interfaces");
	
			iCaseStep = ETransfer;	
	
			iStartTime[0].HomeTime();
			iStartTime[1].HomeTime();
			iStartTime[2].HomeTime();
			iStartTime[3].HomeTime();
	
			iIfc1OutTransfer[0]->TransferOut(KLiteralFrench4(), KHostNumWriteBytes1, EFalse);
			iIfc1OutTransfer[1]->TransferOut(KLiteralFrench4(), KHostNumWriteBytes1, KHostNumWriteBytes2, EFalse);
			iIfc2OutTransfer[0]->TransferOut(KLiteralEnglish2(), KHostNumWriteBytes1, EFalse);
			iIfc2OutTransfer[1]->TransferOut(KLiteralEnglish2(), KHostNumWriteBytes1, KHostNumWriteBytes2, EFalse);
	
			iIfc1InTransfer[0]->TransferIn(KHostNumReadBytes1);
			iIfc1InTransfer[1]->TransferIn(KHostNumReadBytes2);
			iIfc2InTransfer[0]->TransferIn(KHostNumReadBytes1);
			iIfc2InTransfer[1]->TransferIn(KHostNumReadBytes2);
			}
			break;
			
		case ERequestDeviceValidateIFC1:
			{
			iCaseStep = ERequestDeviceValidationResultIFC1;
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP07, "Interface 1: Request Client Validation Result");
			iRequestDeviceValidationResultPtr.Set(iInBuffer->Des());
			iRequestDeviceValidationResultPtr.Zero(); //reset
			iRequestDeviceValidationResultPtr.SetLength(KPassFailStringLength);
			TInterfaceGetPayloadRequest request(1,iRequestDeviceValidationResultPtr);
			iControlEp0->SendRequest(request,this);
			}
			break;
		
		case ERequestDeviceValidationResultIFC1:
			{
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP08, "Interface 1: Client Validation Result string ...");
            OstTraceData(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP58, "", iInBuffer->Ptr(), iInBuffer->Length());
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP09, "\n");
			TPtr8 ptr(iInBuffer->Des());
			if(ptr.Compare(KClientPassString) == 0)
				{
				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP10, "Client Validation Interface 1 Result is a PASS");
				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP11, "Now performing Client Validation for Interface 2");
				iCaseStep = ERequestDeviceValidateIFC2;
				TEndpointStringValidationRequest request(2,1,KLiteralEnglish2(),KDeviceNumReadBytes);
				iControlEp0->SendRequest(request,this);
				}
			else
				{
				TBuf<256> msg;
				msg.Format(_L("<Error> Bulk data VALIDATION check was NOT successful"));
				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP12, msg);
				iCaseStep = EFailed;
				TTestCaseFailed request(KErrCorrupt,msg);
				iControlEp0->SendRequest(request,this);
				}
			}
			break;
			
		case ERequestDeviceValidateIFC2:
			{
			iCaseStep = ERequestDeviceValidationResultIFC2;
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP13, "Interface 2: Request Client Validation Result");
			iRequestDeviceValidationResultPtr.Set(iInBuffer->Des());
			iRequestDeviceValidationResultPtr.Zero(); //reset
			iRequestDeviceValidationResultPtr.SetLength(KPassFailStringLength);
			TInterfaceGetPayloadRequest request(2,iRequestDeviceValidationResultPtr);
			iControlEp0->SendRequest(request,this);
			}
			break;
		
		case ERequestDeviceValidationResultIFC2:
			{
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP14, "Interface 1: Client Validation Result string ...");
            OstTraceData(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP54, "", iInBuffer->Ptr(), iInBuffer->Length());
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP15, "\n");
			TPtr8 ptr(iInBuffer->Des());
			if(ptr.Compare(KClientPassString) == 0)
				{
				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP16, "Client Validation Interface 2 Result is a PASS");
				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP17, "This is the FINAL check - the whole test has a PASSED");
				iCaseStep = EPassed;
				TTestCasePassed request;
				iControlEp0->SendRequest(request,this);
				}
			else
				{
				TBuf<256> msg;
				msg.Format(_L("<Error> Bulk data VALIDATION check was NOT successful"));
				OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP18, msg);
				iCaseStep = EFailed;
				TTestCaseFailed request(KErrCorrupt,msg);
				iControlEp0->SendRequest(request,this);
				}
			}
			break;
	
		default:
			OstTrace0(TRACE_NORMAL, CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_DUP19, "<Error> Unknown test step");
			TestFailed(KErrUnknown);
			break;
		}
	OstTraceFunctionExit1( CUT_PBASE_T_USBDI_0498_EP0TRANSFERCOMPLETEL_EXIT_DUP01, this );
	}
예제 #28
0
 [[noreturn]] void fail(const std::string & failure_message, bool remove_leading_newline) {
    if(remove_leading_newline == false) std::cout << std::endl;
    std::cout << "TEST FAILED : " << failure_message << std::endl;
    throw TestFailed();
 }