kerneltest/e32test/device/t_usbcsc.cpp
changeset 271 dc268b18d709
parent 269 d57b86b1867a
child 273 6a75fa55495f
equal deleted inserted replaced
269:d57b86b1867a 271:dc268b18d709
    87 TInt gInterruptInEpFound = 0;
    87 TInt gInterruptInEpFound = 0;
    88 
    88 
    89 //Command Line parameters 
    89 //Command Line parameters 
    90 TBool gRealHardware = EFalse;
    90 TBool gRealHardware = EFalse;
    91 TInt gVerbose = 0;
    91 TInt gVerbose = 0;
    92 enum TSpecTestType {EAll=0,EBufRead,EBufWrite,EEp0, EAltSet, EInterface, ECancel, EInvalidApi, EDescriptor, /*insert new non-bil here*/ EBilRw=100, EBilEp0, EBilAlt};
    92 enum TSpecTestType {EAll=0,EBufRead,EBufWrite,EEp0, EAltSet, EInterface, ECancel, EInvalidApi, EDescriptor,EHaltEndpoint, /*insert new non-bil here*/ EBilRw=100, EBilEp0, EBilAlt};
    93 TSpecTestType gSpecTest = EAll;
    93 TSpecTestType gSpecTest = EAll;
    94 
    94 
    95 RChunk gChunk;
    95 RChunk gChunk;
    96 static const TInt gBytesReceived = 128;
    96 static const TInt gBytesReceived = 128;
    97 static const TInt KMaxBufSize = 1024 * 1024;				// max data buffer size: 1MB
    97 static const TInt KMaxBufSize = 1024 * 1024;				// max data buffer size: 1MB
  1537 			r = gPort.ReadDataNotify(outBuffNum,status);
  1537 			r = gPort.ReadDataNotify(outBuffNum,status);
  1538 			DEBUGPRINT(test.Printf(_L("header->iTail 0x%x header->iHead 0x%x\n"), header->iTail, header->iHead));
  1538 			DEBUGPRINT(test.Printf(_L("header->iTail 0x%x header->iHead 0x%x\n"), header->iTail, header->iHead));
  1539 			DEBUGPRINT(OstTraceExt2(TRACE_NORMAL, TESTCANCEL_TESTCANCEL_DUP02, "header->iTail 0x%x header->iHead 0x%x\n", header->iTail, header->iHead));
  1539 			DEBUGPRINT(OstTraceExt2(TRACE_NORMAL, TESTCANCEL_TESTCANCEL_DUP02, "header->iTail 0x%x header->iHead 0x%x\n", header->iTail, header->iHead));
  1540 			transfer = (TUsbcScTransferHeader*) (header->iTail + base);
  1540 			transfer = (TUsbcScTransferHeader*) (header->iTail + base);
  1541 			header->iTail = transfer->iNext;
  1541 			header->iTail = transfer->iNext;
       
  1542 			header->iBilTail = transfer->iNext; 
  1542 			}
  1543 			}
  1543 		while (r != KErrNone);	
  1544 		while (r != KErrNone);	
  1544 
  1545 
  1545 		gPort.ReadCancel(outBuffNum);
  1546 		gPort.ReadCancel(outBuffNum);
  1546 		test_KErrNone(WaitUntilTimeout(timeOut, status));	
  1547 		test_KErrNone(WaitUntilTimeout(timeOut, status));	
  1560 		gPort.WriteData(inBuffNum,  bufferOffset, length, 1, status);
  1561 		gPort.WriteData(inBuffNum,  bufferOffset, length, 1, status);
  1561 		gPort.WriteCancel(inBuffNum);
  1562 		gPort.WriteCancel(inBuffNum);
  1562 		test_KErrNone(WaitUntilTimeout(timeOut, status));	
  1563 		test_KErrNone(WaitUntilTimeout(timeOut, status));	
  1563 		test_Equal(status.Int(), KErrCancel);
  1564 		test_Equal(status.Int(), KErrCancel);
  1564 		
  1565 		
  1565 	}//grealhardware
  1566 		}//grealhardware
  1566 
  1567 
  1567 	CloseStackIfOtg();
  1568 	CloseStackIfOtg();
  1568 	CloseChannel();
  1569 	CloseChannel();
  1569 	UnloadDriver();
  1570 	UnloadDriver();
  1570 
  1571 
  3127 		test.End();
  3128 		test.End();
  3128 		return;
  3129 		return;
  3129 		}
  3130 		}
  3130 
  3131 
  3131 	test.Next(_L("Endpoint stall status"));
  3132 	test.Next(_L("Endpoint stall status"));
  3132 	TEndpointState epState = EEndpointStateUnknown;
  3133 	
  3133 	test_Equal(EEndpointStateNotStalled, QueryEndpointState(1));
  3134 	LoadDriver();
  3134 	test_Equal(EEndpointStateNotStalled, QueryEndpointState(2));
  3135 	OpenChannel();
  3135 
  3136 	
  3136 	test.Next(_L("Stall Ep1"));
  3137 	TInt r; 
  3137 	gPort.HaltEndpoint(1);
  3138 	r = SettingOne(0);  
  3138 	epState = QueryEndpointState(1);
  3139 	test_KErrNone(r);
  3139 	test(epState == EEndpointStateStalled);
  3140  
  3140 
  3141 	r = gPort.RealizeInterface(gChunk);
  3141 	test.Next(_L("Clear Stall Ep1"));
  3142 	test_KErrNone(r);
  3142 	gPort.ClearHaltEndpoint(1);
  3143     
  3143 	epState = QueryEndpointState(1);
  3144 	OpenStackIfOtg();
  3144 	test(epState == EEndpointStateNotStalled);
  3145     
  3145 
  3146 	if (gRealHardware)
  3146 	test.Next(_L("Stall Ep2"));
  3147 		{       
  3147 	gPort.HaltEndpoint(2);
  3148 		test.Printf(_L("\n\n Trying hardware\nPlease start the Host side application...\n"));
  3148 	epState = QueryEndpointState(2);
  3149 		OstTrace0(TRACE_NORMAL, TESTENDPOINTSTALLSTATUS_TESTENDPOINTSTALLSTATUS_DUP01, "\n \n Trying hardware\nPlease start the Host side application...\n");
  3149 	test(epState == EEndpointStateStalled);
  3150     
  3150 
  3151 		TRequestStatus status;
  3151 	test.Next(_L("Clear Stall Ep2"));
  3152 		gPort.ReEnumerate(status);
  3152 	gPort.ClearHaltEndpoint(2);
  3153 		User::WaitForRequest(status);
  3153 	epState = QueryEndpointState(2);
  3154 		test.Printf(_L("Enumerated status = %d\n"), status.Int());
  3154 	test(epState == EEndpointStateNotStalled);
  3155 		OstTrace1(TRACE_NORMAL, TESTENDPOINTSTALLSTATUS_TESTENDPOINTSTALLSTATUS_DUP02, "Enumerated status = %d\n", status.Int());
  3155 
  3156         
       
  3157 		TEndpointState epState = EEndpointStateUnknown;
       
  3158 		test_Equal(EEndpointStateNotStalled, QueryEndpointState(1));
       
  3159 		test_Equal(EEndpointStateNotStalled, QueryEndpointState(2));
       
  3160     
       
  3161 		test.Next(_L("Stall Ep1"));
       
  3162 		gPort.HaltEndpoint(1);
       
  3163 		epState = QueryEndpointState(1);
       
  3164 		test(epState == EEndpointStateStalled);
       
  3165     
       
  3166 		test.Next(_L("Clear Stall Ep1"));
       
  3167 		gPort.ClearHaltEndpoint(1);
       
  3168 		epState = QueryEndpointState(1);
       
  3169 		test(epState == EEndpointStateNotStalled);
       
  3170     
       
  3171 		test.Next(_L("Stall Ep2"));
       
  3172 		gPort.HaltEndpoint(2);
       
  3173 		epState = QueryEndpointState(2);
       
  3174 		test(epState == EEndpointStateStalled);
       
  3175     
       
  3176 		test.Next(_L("Clear Stall Ep2"));
       
  3177 		gPort.ClearHaltEndpoint(2);
       
  3178 		epState = QueryEndpointState(2);
       
  3179 		test(epState == EEndpointStateNotStalled);
       
  3180 		}
       
  3181 
       
  3182 	CloseStackIfOtg();
       
  3183 	CloseChannel();
       
  3184 	UnloadDriver();  
       
  3185 	
  3156 	test.End();
  3186 	test.End();
  3157 	}
  3187 	}
  3158 
  3188 
  3159 static void TestEndpointStatusNotify()
  3189 static void TestEndpointStatusNotify()
  3160 	{
  3190 	{
  3300 	TestAlternateInterfaceManipulation();
  3330 	TestAlternateInterfaceManipulation();
  3301 
  3331 
  3302 	TestExtendedEndpointDescriptor();
  3332 	TestExtendedEndpointDescriptor();
  3303 
  3333 
  3304 	TestArbitraryStringDescriptors();
  3334 	TestArbitraryStringDescriptors();
  3305 	
       
  3306 	TestEndpointStallStatus();
       
  3307 
  3335 
  3308 	TestEndpointStatusNotify();
  3336 	TestEndpointStatusNotify();
  3309 
  3337 
  3310 	CloseChannel();
  3338 	CloseChannel();
  3311 	UnloadDriver();
  3339 	UnloadDriver();
  4292 		test.Start(_L("PBASE-USB-SC-1224 Descriptor Tests \n"));
  4320 		test.Start(_L("PBASE-USB-SC-1224 Descriptor Tests \n"));
  4293 		TestDescriptorManipulation();
  4321 		TestDescriptorManipulation();
  4294 		test.End();
  4322 		test.End();
  4295 		break;
  4323 		break;
  4296 		}
  4324 		}
       
  4325 	case EHaltEndpoint:
       
  4326 		{
       
  4327 		test.Start(_L("Halt Endpoint Tests \n"));
       
  4328 		TestEndpointStallStatus();
       
  4329 		test.End();
       
  4330 		break;
       
  4331 		}
  4297 	default:
  4332 	default:
  4298 		if (gSpecTest>=EBilRw)
  4333 		if (gSpecTest>=EBilRw)
  4299 			TestBIL();
  4334 			TestBIL();
  4300 		else
  4335 		else
  4301 			{
  4336 			{
  4348 	CloseChannel();
  4383 	CloseChannel();
  4349 	UnloadDriver();
  4384 	UnloadDriver();
  4350 		
  4385 		
  4351 	if (gSpecTest == EAll)
  4386 	if (gSpecTest == EAll)
  4352 		{
  4387 		{
  4353 		for (TInt i = 1; i <= 7; i++)
  4388 		for (TInt i = 1; i <= 9; i++)
  4354 			{
  4389 			{
  4355 			gSpecTest = (TSpecTestType) i;
  4390 			gSpecTest = (TSpecTestType) i;
  4356 			StartTests();
  4391 			StartTests();
  4357 			}
  4392 			}
  4358 		for (TInt i = 100; i <= 102; i++)
  4393 		for (TInt i = 100; i <= 102; i++)
  4393 				{
  4428 				{
  4394 				test.Printf(_L("\nThis tests the Shared chunk version of the USBC driver.  It focuses on the elements specific to this driver and should be used in conjuntion with other USBC tests in order to validate the driver.\n\n"));
  4429 				test.Printf(_L("\nThis tests the Shared chunk version of the USBC driver.  It focuses on the elements specific to this driver and should be used in conjuntion with other USBC tests in order to validate the driver.\n\n"));
  4395 				OstTrace0(TRACE_NORMAL, PARSECOMMANDLINE_PARSECOMMANDLINE, "\nThis tests the Shared chunk version of the USBC driver.  It focuses on the elements specific to this driver and should be used in conjuntion with other USBC tests in order to validate the driver.\n\n");
  4430 				OstTrace0(TRACE_NORMAL, PARSECOMMANDLINE_PARSECOMMANDLINE, "\nThis tests the Shared chunk version of the USBC driver.  It focuses on the elements specific to this driver and should be used in conjuntion with other USBC tests in order to validate the driver.\n\n");
  4396 				test.Printf(_L("\n -h : Help.\n -r : test on Real hardware\n -v : Verbose\n -V : Very verbose\n-t <test> : Run a specific test.\n"));   
  4431 				test.Printf(_L("\n -h : Help.\n -r : test on Real hardware\n -v : Verbose\n -V : Very verbose\n-t <test> : Run a specific test.\n"));   
  4397 				OstTrace0(TRACE_NORMAL, PARSECOMMANDLINE_PARSECOMMANDLINE_DUP01, "\n -h : Help.\n -r : test on Real hardware\n -v : Verbose\n -V : Very verbose\n-t <test> : Run a specific test.\n");   
  4432 				OstTrace0(TRACE_NORMAL, PARSECOMMANDLINE_PARSECOMMANDLINE_DUP01, "\n -h : Help.\n -r : test on Real hardware\n -v : Verbose\n -V : Very verbose\n-t <test> : Run a specific test.\n");   
  4398 				test.Printf(_L("\nAvailable tests:  buf_read, buf_write, ep0, altset, interface, cancel, api, descriptor, bil_rw, bil_ep0, bil_alt\n"));
  4433 				test.Printf(_L("\nAvailable tests:  buf_read, buf_write, ep0, altset, interface, cancel, api, descriptor, bil_rw, bil_ep0, bil_alt, halt_endpoint\n"));
  4399 				OstTrace0(TRACE_NORMAL, PARSECOMMANDLINE_PARSECOMMANDLINE_DUP02, "\nAvailable tests:  buf_read, buf_write, ep0, altset, interface, cancel, api, descriptor, bil_rw, bil_ep0, bil_alt\n");
  4434 				OstTrace0(TRACE_NORMAL, PARSECOMMANDLINE_PARSECOMMANDLINE_DUP02, "\nAvailable tests:  buf_read, buf_write, ep0, altset, interface, cancel, api, descriptor, bil_rw, bil_ep0, bil_alt, halt_endpoint\n");
  4400 				err=KErrCancel;
  4435 				err=KErrCancel;
  4401 				}
  4436 				}
  4402 			else
  4437 			else
  4403 				if (token==_L("-r"))
  4438 				if (token==_L("-r"))
  4404 					gRealHardware = ETrue;
  4439 					gRealHardware = ETrue;
  4433 						else if (subtoken==_L("descriptor"))
  4468 						else if (subtoken==_L("descriptor"))
  4434 								gSpecTest=EDescriptor;
  4469 								gSpecTest=EDescriptor;
  4435 						else if (subtoken==_L("interface"))
  4470 						else if (subtoken==_L("interface"))
  4436 								gSpecTest=EInterface;
  4471 								gSpecTest=EInterface;
  4437 						else if (subtoken==_L("cancel"))
  4472 						else if (subtoken==_L("cancel"))
       
  4473 								{
  4438 								gSpecTest=ECancel;
  4474 								gSpecTest=ECancel;
       
  4475 								gRealHardware = ETrue;
       
  4476 								}
  4439 						else if (subtoken==_L("api"))
  4477 						else if (subtoken==_L("api"))
  4440 								gSpecTest=EInvalidApi;
  4478 								gSpecTest=EInvalidApi;
  4441 						else if (subtoken==_L("bil_rw"))
  4479 						else if (subtoken==_L("bil_rw"))
  4442 								{
  4480 								{
  4443 								gSpecTest=EBilRw;
  4481 								gSpecTest=EBilRw;
  4456 						else if (subtoken==_L("altset"))
  4494 						else if (subtoken==_L("altset"))
  4457 								{
  4495 								{
  4458 								gRealHardware = ETrue;
  4496 								gRealHardware = ETrue;
  4459 								gSpecTest=EAltSet;
  4497 								gSpecTest=EAltSet;
  4460 								}
  4498 								}
       
  4499 						else if (subtoken==_L("halt_endpoint"))
       
  4500 								{
       
  4501 								gRealHardware = ETrue;
       
  4502 								gSpecTest=EHaltEndpoint;
       
  4503 								}
  4461 						else
  4504 						else
  4462 							{
  4505 							{
  4463 							err=KErrArgument;
  4506 							err=KErrArgument;
  4464 							}
  4507 							}
  4465 
  4508