enum TVerdict TE_RConnectionTest500::doTestStepL(void) { TInt err; RSocketServ socketServer; RHostResolver hostResolver; err = OpenSocketServer(socketServer); TESTEL(KErrNone == err, err); CleanupClosePushL(socketServer); err = OpenHostResolver(hostResolver, socketServer); TESTEL(KErrNone == err, err); CleanupClosePushL(hostResolver); err = MakeSynchronousNameRequest(hostResolver, iTestName); // this will use GetByName() TESTEL(KErrIfAuthenticationFailure == err, err); DestroyHostResolver(hostResolver); CleanupStack::Pop(); CloseSocketServer(socketServer); CleanupStack::Pop(&socketServer); // just sanity check our pops return TestStepResult(); }
/** Creates a second process, runs the requested test and ensures that the specified panic occurs. @param aExecutableName The name of the new process @param aTestInfo The specification for this test @param aPanicCategory Descriptor containing the start of the expected panic string e.g. for "ALLOC:xxxxxxxx" this would be "ALLOC" @leave One of the system wide error codes */ void CTGraphicsResourceInternalBase::CreateSecondProcessAndCheckAllocPanicL(const TDesC &aExecutableName, TSgResIntTestInfo& aTestInfo, const TDesC &aPanicCategory) { // Create a second process RProcess process; TInt err = process.Create(aExecutableName, KNullDesC); TESTEL(KErrNone == err, err); CleanupClosePushL(process); // Specify the id passed to the second process TPckg<TSgResIntTestInfo> ptr(aTestInfo); err = process.SetParameter(KSecondProcessParametersSlot, ptr); TESTEL(KErrNone == err, err); // Kick off the second process and wait for it to complete // The actual testing is done in the second process TRequestStatus status; process.Logon(status); process.Resume(); User::WaitForRequest(status); if(EExitPanic != process.ExitType()) { ERR_PRINTF3(_L("Expected exit type: %d, Actual exit type: %d"), EExitPanic, process.ExitType()); TEST(EFalse); } TExitCategoryName secondProcessExitCategory = process.ExitCategory(); if(0 != secondProcessExitCategory.Match(aPanicCategory)) { ERR_PRINTF3(_L("Expected panic category: %S, Actual panic category: %S"), &aPanicCategory, &secondProcessExitCategory); TEST(EFalse); } CleanupStack::PopAndDestroy(); }
enum TVerdict CEsockTest9_3::easyTestStepL() { Logger().WriteFormat(_L("TE_ESock: test 9.3")); TESTL(EPass == TestStepResult()); // ipv6 // List Route(s) ListRoutes(); TPckgBuf<TSoInetRouteInfo> opt; opt().iType = ERtUser; opt().iState = ERtReady; opt().iIfAddr.SetFamily(KAFUnspec); opt().iMetric = 1; (TInetAddr::Cast(opt().iIfAddr)).Input(_L("::1")); (TInetAddr::Cast(opt().iGateway)).Input(_L("fe80::dead:beef")); (TInetAddr::Cast(opt().iDstAddr)).Input(_L("2001:618:400:61::dead:fee")); (TInetAddr::Cast(opt().iNetMask)).Input(_L("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")); // Add Route TInt ret = iEsockSuite->GetSocketHandle(1).SetOpt(KSoInetAddRoute, KSolInetRtCtrl, opt); TESTEL(KErrNone == ret, ret); // List Route(s) ListRoutes(); // Delete Route ret = iEsockSuite->GetSocketHandle(1).SetOpt(KSoInetDeleteRoute, KSolInetRtCtrl, opt); TESTEL(KErrNone == ret, ret); // List Route(s) ListRoutes(); return EPass; }
enum TVerdict CEsockTest2_5::easyTestStepL() { TESTL(EPass == TestStepResult()); // get port numbers TInt port1, port2; TESTL(GetIntFromConfig(SectionName(_L("Test_2.5")), _L("port1"), port1)); TESTL(GetIntFromConfig(SectionName(_L("Test_2.5")), _L("port2"), port2)); // set the local port number to port1 TInt nRet = iEsockSuite->GetSocketHandle(1).SetLocalPort(port1); TESTEL(nRet == KErrNone, nRet); // check port has been set correctly TUint port = iEsockSuite->GetSocketHandle(1).LocalPort(); TESTL(port == (TUint)port1); // set the local port number to port2 // check that this is not successful nRet = iEsockSuite->GetSocketHandle(1).SetLocalPort(port2); TESTEL(nRet == KErrAlreadyExists, nRet); // check port has not been changed port = iEsockSuite->GetSocketHandle(1).LocalPort(); TESTL(port == (TUint)port1); return EPass; }
/** @SYMTestCaseID GRAPHICS-RESOURCE-0201 @SYMTestCaseDesc Test Graphics Resource with low memory conditions. @SYMPREQ PREQ2637 @SYMFssID RSgImage RSgDrawable RSgDriver @SYMTestPriority High @SYMTestType UT @SYMTestPurpose To ensure the correct errors or KErrNoMemory are returned by graphics resource apis under low memory conditions. @SYMTestActions Force allocations to fail on the RSgDrivers heap, try running each of the conformance tests and stress tests to ensure no RSgDriver allocated memory or heap memory is leaked. It also creates an image in this process which is used in another process for OOM testing. @SYMTestExpectedResults Return codes of the functions tested should be either the expected value or KErrNoMemory This is handled by CTSgTestStepBase::CheckErrorL. No ALLOC or SGALLOC panics should occur. */ void CTGraphicsResourceInternal::TestOOML() { // drawable OOM test TSgResIntTestInfo testInfo = { ESgResIntDrawableOOM }; TInt result = CreateSecondProcessAndDoTestL(KInternalTestsSecondProcess, testInfo); TEST(result & EFirstTestPassed); // image OOM test testInfo.iTestCase = ESgResIntImageOOM; RSgDriver sgDriver; TInt err = sgDriver.Open(); TESTEL(err == KErrNone, err); CleanupClosePushL(sgDriver); RSgImage image1; TSgImageInfo info1(TSize(8, 8), EUidPixelFormatRGB_565, ESgUsageBitOpenVgImage); err = image1.Create(info1); TESTEL(err == KErrNone, err); CleanupClosePushL(image1); testInfo.iDrawableId = image1.Id(); result = CreateSecondProcessAndDoTestL(KInternalTestsSecondProcess, testInfo); TEST(result & EFirstTestPassed); CleanupStack::PopAndDestroy(2, &sgDriver); }
enum TVerdict CEsockTest11_1::easyTestStepL() { // get ip address to connect to TInetAddr addr; TESTL(GetIpAddressFromConfig(_L("Test_Common"), _L("ipAddress"), addr)); // get port number to connect to TInt port; TESTL(GetIntFromConfig(_L("Test_11.1"), _L("port"), port)); // set remote address port addr.SetPort(port); // open a TCP socket RSocket sock; CleanupClosePushL(sock); TInt nRet = sock.Open(iEsockSuite->iSocketServer, KAfInet, KSockStream, KProtocolInetTcp); TESTEL(KErrNone == nRet, nRet); // connect to the remote address TRequestStatus stat; sock.Connect(addr, stat); User::WaitForRequest(stat); TESTEL(stat==KErrNone, stat.Int()); // get the remote name of the connected socket TInetAddr addr1; sock.RemoteName(addr1); // check this matches the address we connected to TESTL(addr.CmpAddr(addr1)); CleanupStack::PopAndDestroy(1, &sock); return EPass; }
TVerdict CDhcpTestStep1_2::doTestStepL() /** * @return - TVerdict code only ever returns EPass, else leaves with error! * Override of base class pure virtual * Connect to DHCP Daemon - Daemon not found(test doc 4.1.2) * Daemon name in commDB specifies a non-existent daemon therefore * connection start will fail as the settings for it are incorrect... */ { SetTestStepResult(EFail); RSocketServ eSock; TInt err = eSock.Connect(); TESTEL(err == KErrNone, err); CleanupClosePushL(eSock); #ifdef _DEBUG User::LeaveIfError(RProperty::Set(KMyPropertyCat, KMyPropertyDestPortv4, 67)); #endif RConnection connNET1; err = connNET1.Open(eSock); TESTEL(err == KErrNone, err); CleanupClosePushL(connNET1); err = connNET1.Start(iConnPrefs); // see test script for IAP used TESTEL(err == KErrNotFound, err); CleanupStack::PopAndDestroy(&connNET1); CleanupStack::PopAndDestroy(&eSock); SetTestStepResult(EPass); return TestStepResult(); }
enum TVerdict CEsockTest9_4::easyTestStepL() { Logger().WriteFormat(_L("TE_ESock: test 9.4")); TESTL(EPass == TestStepResult()); // ipv4 // List Route(s) ListRoutes(); // Add Route TInt ret = SetRoute(KSoInetAddRoute, IPADDR(10,158,7,52),IPADDR(255,0,0,0),IPADDR(10,158,7,73), IPADDR(127,0,0,1), 0); TESTEL(KErrNone == ret, ret); // List Route(s) ListRoutes(); // Change Route ret = SetRoute(KSoInetChangeRoute, IPADDR(10,158,7,52),IPADDR(255,0,0,0),IPADDR(10,158,7,70), IPADDR(127,0,0,1), 0); TESTEL(KErrNotFound == ret, ret); // List Route(s) ListRoutes(); return EPass; }
enum TVerdict CEsockTest2_4::easyTestStepL() { TESTL(EPass == TestStepResult()); // double bind on different sockets // get IP address TInetAddr addr; TESTL(GetIpAddressFromConfig(SectionName(_L("Test_2.4")), _L("ipAddress"), addr)); // set port number to a valid value addr.SetPort(9); // socket already opened - retrieve // socket handle and bind TInt nRet = iEsockSuite->GetSocketHandle(1).Bind(addr); // bind should succeed TESTEL(nRet == KErrNone, nRet); // socket already opened - retrieve // socket handle and bind again to same address nRet = iEsockSuite->GetSocketHandle(2).Bind(addr); // second bind should fail TESTEL(nRet == KErrInUse, nRet); return EPass; }
/** * ReConnect is a utility function to connect and disconnect using an Agt. * * The preconditions for this function are assumed to be set so that * a connection attempt will be successful. Any error will be reported to * the test framework as a failed test case * */ void CTestStepCsdAgt::ReConnectL() { TInt err; TInt stage; CNifAgentRefN1 *agent; // Construct a new Dummy Nifman Instance Log(_L("Loading DUMMYNIF.DLL")); agent = CNifAgentRefN1::NewL(this); CleanupStack::PushL(agent); // Attempt connection Log(_L("Connecting...")); agent->Connect(); // Check for an error code agent->GetCompletionCode(err); TESTEL(err==KErrNone,err); // Check ConnectComplete was reported at the correct stage in the state machine agent->GetProgressStage(stage); TESTEL(stage==ECsdConnectionOpen,stage); Log(_L("Connect Succeeded")); DelayL(2000000); // Attempt connection Log(_L("Reconnecting...")); agent->ReConnect(); // Check for an error code agent->GetCompletionCode(err); TESTEL(err==KErrNone,err); // Check ConnectComplete was reported at the correct stage in the state machine agent->GetProgressStage(stage); TESTEL(stage==ECsdConnectionOpen,stage); Log(_L("Reconnect successful")); DelayL(2000000); // Disconnect Log(_L("Disconnecting...")); agent->Disconnect(); // Check for an error code agent->GetCompletionCode(err); TESTEL(err==KErrNone,err); Log(_L("Disconnect successful")); // Finished with Dummy Nifman so delete it CleanupStack::PopAndDestroy(agent); Log(_L("DUMMYNIF.DLL Unloaded")); }
TVerdict CDhcpTestStep1_3::doTestStepL() /** * @return - TVerdict code only ever returns EPass, else leaves with error! * Override of base class pure virtual * Get Active IP Address (test doc 4.1.3) * from a connection that does not use DHCP * configuration but the static settings in * commDB. Therefore any request for the address * from the DHCP daemon will fail. */ { SetTestStepResult(EFail); RSocketServ eSock; TInt err = eSock.Connect(); TESTEL(err == KErrNone, err); INFO_PRINTF2(_L("eSock.Connect() returned %d"),err); CleanupClosePushL(eSock); #ifdef _DEBUG User::LeaveIfError(RProperty::Set(KMyPropertyCat, KMyPropertyDestPortv4, 67)); #endif RConnection connNET1; err = connNET1.Open(eSock); INFO_PRINTF2(_L("connNET1.Open(eSock) returned %d"),err); TESTEL(err == KErrNone, err); CleanupClosePushL(connNET1); err = connNET1.Start(iConnPrefs); // see test script for IAP used INFO_PRINTF2(_L("connNET1.Start(prefs) returned %d"),err); TESTEL(err == KErrNone, err); TRequestStatus stat; TConnectionAddrBuf address; address().iAddressFamily = IpAddressFamilyL(); INFO_PRINTF1(_L("Just before connNET1.Ioctl(...)")); INFO_PRINTF2(_L("Size: %d "), address.Size()); INFO_PRINTF2(_L("MaxSize: %d "), address.MaxSize()); INFO_PRINTF2(_L("MaxLength: %d "), address.MaxLength()); connNET1.Ioctl(KCOLConfiguration, KConnGetCurrentAddr, stat, &address); User::WaitForRequest(stat); INFO_PRINTF2(_L("err = connNET1.Ioctl(...) returned %d"),stat.Int()); TESTEL(stat == KErrNotSupported, stat.Int()); err = connNET1.Stop(); INFO_PRINTF2(_L("connNET1.Stop() returned %d"),err); TESTEL(err == KErrNone, err); CleanupStack::PopAndDestroy(&connNET1); CleanupStack::PopAndDestroy(&eSock); SetTestStepResult(EPass); return TestStepResult(); }
// Test case 4.1, Context Config change, Service Option reduced, disconnect enum TVerdict CPsdAgtTest4_1::doPsdAgtTestStepL( void ) { TInt err; TInt stage; CNifAgentRefN1 *agent; TRealAgtNotify agtNotify; agtNotify.SetTestCase(401); Log(_L("Loading DUMMYNIF.DLL")); // Construct a new Dummy Nifman Instance agent = CNifAgentRefN1::NewL(this,EFalse); CleanupStack::PushL(agent); // Attempt connection Log(_L("Connecting...")); agent->Connect(); // Check result codes agent->GetCompletionCode(err); TESTEL(err==KErrNone,err); // Check ConnectComplete was reported at the correct stage in the state machine agent->GetProgressStage(stage); TESTEL(stage==KConnectionOpen,stage); Log(_L("Connect Successful")); DelayL(3000000); // Tell the ETEL layer to send a QOS change to PSDAGX Log(_L("Notify PSDAGX of QoS change")); agtNotify.NotifyAgt(EReduce); // Make sure no dialog is presented DelayL(3000000); // Disconnect Log(_L("Disconnecting...")); agent->Disconnect(); // Check result code agent->GetCompletionCode(err); TESTEL(err==KErrNone,err); Log(_L("Disconnect Successful")); // Finished with Dummy Nifman so delete it CleanupStack::PopAndDestroy(agent); Log(_L("DUMMYNIF.DLL Unloaded")); // Finished with database so undo any changes Log(_L("Reverting COMMDB changes")); return iTestStepResult; }
enum TVerdict CIpsecTest1_1::doTestStepL() /** * test - import policies */ { _LIT(KThisSection, "Section1.1"); Log(_L("Test - import policy")); /** * make sure the act_prof.lst file is deleted */ RFs fs; TInt ret = fs.Connect(); Log(_L("fs.Connect returned %d"), ret); TESTEL(ret == KErrNone, ret); CleanupClosePushL(fs); /** * read parameters */ TPtrC ptrResult; _LIT(KPolicyDir, "PolicyDir"); const TBool b = GetStringFromConfig(KThisSection, KPolicyDir, ptrResult); if(!b) { Log(_L("Could not read policy file from config")); TESTL(EFalse); } Log(_L("PolicyDir = %S"), &ptrResult); CIPSecAPI* api = 0; TRAP(ret, api = CIPSecAPI::NewL()); Log(_L("CIPSecAPI::NewL returned %d"), ret); TESTEL(ret == KErrNone, ret); CleanupStack::PushL(api); ret = api->ImportPolicy(ptrResult); Log(_L("ImportPolicy returned %d"), ret); TESTEL(ret == KErrNone, ret); /** * cleanup */ CleanupStack::PopAndDestroy(api); CleanupStack::PopAndDestroy(&fs); return iTestStepResult; }
// Implicitly create a single connection using GetByName() enum TVerdict TE_RConnectionTest307::doTestStepL(void) { TInt err; RSocketServ ss; RHostResolver hr; RConnection monitor; TRequestStatus status; TInterfaceNotificationBuf info; err = OpenSocketServer(ss); TESTEL(KErrNone == err, err); CleanupClosePushL(ss); err = OpenConnection(monitor, ss); TESTEL(KErrNone == err, err); CleanupClosePushL(monitor); err = OpenHostResolver(hr, ss); TESTEL(KErrNone == err, err); CleanupClosePushL(hr); // issue request AllInterfaceNotification(monitor, status, info); err = MakeNameRequest(hr, iTestName); // this will use GetByName() TESTEL(KErrNone == err, err); // check for interface up... CheckInterfaceNotificationL(status, info, EInterfaceUp); // issue request AllInterfaceNotification(monitor, status, info); DestroyHostResolver(hr); CleanupStack::Pop(); // check for interface down... CheckInterfaceNotificationL(status, info, EInterfaceDown); CloseConnection(monitor); CleanupStack::Pop(); CloseSocketServer(ss); CleanupStack::Pop(); return TestStepResult(); } // TE_RConnectionTest307
enum TVerdict CEsockTest11_2::easyTestStepL() { TInt nRet; TProtocolDesc protocolInfo; // Get protocol information // open a TCP socket, retrieve the protocol info // and check the protocol ID RSocket sock1; CleanupClosePushL(sock1); nRet = sock1.Open(iEsockSuite->iSocketServer, KAfInet, KSockStream, KProtocolInetTcp); TESTEL(KErrNone == nRet, nRet); TESTL(sock1.Info(protocolInfo)==KErrNone); TESTL(protocolInfo.iProtocol==KProtocolInetTcp); CleanupStack::PopAndDestroy(1, &sock1); // open a UDP socket, retrieve the protocol info // and check the protocol ID RSocket sock2; CleanupClosePushL(sock2); nRet = sock2.Open(iEsockSuite->iSocketServer, KAfInet, KSockDatagram, KProtocolInetUdp); TESTEL(KErrNone == nRet, nRet); TESTL(sock2.Info(protocolInfo)==KErrNone); TESTL(protocolInfo.iProtocol==KProtocolInetUdp); CleanupStack::PopAndDestroy(1, &sock2); // open an ICMP socket, retrieve the protocol info // and check the protocol ID RSocket sock3; CleanupClosePushL(sock3); nRet = sock3.Open(iEsockSuite->iSocketServer, KAfInet, KSockDatagram, KProtocolInetIcmp); TESTEL(KErrNone == nRet, nRet); TESTL(sock3.Info(protocolInfo)==KErrNone); TESTL(protocolInfo.iProtocol==KProtocolInetIcmp); CleanupStack::PopAndDestroy(1, &sock3); // open an IP socket, retrieve the protocol info // and check the protocol ID RSocket sock4; CleanupClosePushL(sock4); nRet = sock4.Open(iEsockSuite->iSocketServer, KAfInet, KSockDatagram, KProtocolInetIp); TESTEL(KErrNone == nRet, nRet); TESTL(sock4.Info(protocolInfo)==KErrNone); TESTL(protocolInfo.iProtocol==KProtocolInetIp); CleanupStack::PopAndDestroy(1, &sock4); return EPass; }
// creates a connection and destroys it again // Implicitly detect a single connection using SendTo() enum TVerdict TE_RConnectionTest305::doTestStepL(void) { TInt err; RConnection monitor; RSocketServ ss; RSocket sock; TRequestStatus status; TInterfaceNotificationBuf info; err = OpenSocketServer(ss); TESTEL(KErrNone == err, err); CleanupClosePushL(ss); err = OpenConnection(monitor, ss); TESTEL(KErrNone == err, err); CleanupClosePushL(monitor); err = OpenUdpSocketL(sock, ss); TESTEL(KErrNone == err, err); CleanupClosePushL(sock); // issue request AllInterfaceNotification(monitor, status, info); err = TestUdpDataPathL(sock, iDummyNifSendAddr); // this will use SendTo() TESTEL(KErrNone == err, err); // check for interface up... CheckInterfaceNotificationL(status, info, EInterfaceUp); AllInterfaceNotification(monitor, status, info); DestroyUdpSocket(sock); CleanupStack::Pop(); // check for interface down... CheckInterfaceNotificationL(status, info, EInterfaceDown); CloseConnection(monitor); CleanupStack::Pop(); CloseSocketServer(ss); CleanupStack::Pop(); return TestStepResult(); } // TE_RConnectionTest305
// creates a connection and destroys it again enum TVerdict TE_RConnectionTest304::doTestStepL(void) { TInt err; RSocketServ socketServer; RConnection connection; RConnection monitor; TRequestStatus status; TInterfaceNotificationBuf info; err = OpenSocketServer(socketServer); TESTEL(KErrNone == err, err); CleanupClosePushL(socketServer); err = OpenConnection(connection, socketServer); TESTEL(KErrNone == err, err); CleanupClosePushL(connection); err = OpenConnection(monitor, socketServer); TESTEL(KErrNone == err, err); CleanupClosePushL(monitor); // issue request AllInterfaceNotification(monitor, status, info); // start connection to complete request err = StartConnection(connection); TESTEL(KErrNone == err, err); CheckInterfaceNotificationL(status, info, EInterfaceUp, &connection); // issue request AllInterfaceNotification(monitor, status, info); CloseConnection(connection); CleanupStack::Pop(); CheckInterfaceNotificationL(status, info, EInterfaceDown); CloseConnection(monitor); CleanupStack::Pop(); CloseSocketServer(socketServer); CleanupStack::Pop(); return TestStepResult(); } // TE_RConnectionTest304
/** * Connect, and block execution, ie. wait for an asyncronous request * * The response function for the asyncronous callback should unblock * */ void CTestStepCsdAgt::ConnectAndWaitForAsyncronousRequestL() { TInt err; TInt stage; CNifAgentRefN1 *agent; // Construct a new Dummy Nifman Instance Log(_L("Loading DUMMYNIF.DLL")); agent = CNifAgentRefN1::NewL(this); CleanupStack::PushL(agent); // Attempt connection Log(_L("Connecting...")); agent->Connect(); // Check result codes agent->GetCompletionCode(err); TESTEL(err==KErrNone,err); // Check ConnectComplete was reported at the correct stage in the state machine agent->GetProgressStage(stage); TESTEL(stage==ECsdConnectionOpen,stage); Log(_L("Connect Successful")); Log(_L("Wait for EAgentToNifEventTypeGetDataTransfer event")); DelayL(2000000); iStage++; // increment stage so we know that we are connected // Block until request arrives CActiveScheduler::Start(); DelayL(2000000); // Disconnect Log(_L("Disconnecting...")); agent->Disconnect(); // Check result code agent->GetCompletionCode(err); TESTEL(err==KErrNone,err); Log(_L("Disconnect Successful")); // Finished with Dummy Nifman so delete it CleanupStack::PopAndDestroy(agent); Log(_L("DUMMYNIF.DLL Unloaded")); }
/** Creates a second process and do some tests in it. @param aExecutableName The name of the new process @param aTestInfo The information for the tests @leave Gets system wide error code */ TInt CTGraphicsResourceInternalBase::CreateSecondProcessAndDoTestL(const TDesC &aExecutableName, TSgResIntTestInfo& aTestInfo) { // Create a second process RProcess process; User::LeaveIfError(process.Create(aExecutableName, KNullDesC)); CleanupClosePushL(process); // Specify the id passed to the second process TPckg<TSgResIntTestInfo> ptr(aTestInfo); TInt err = process.SetParameter(KSecondProcessParametersSlot, ptr); TESTEL(KErrNone == err, err); // Kick off the second process and wait for it to complete // The actual testing is done in the second process TRequestStatus status; process.Logon(status); process.Resume(); User::WaitForRequest(status); //ExitReason() returns the test result TInt exitreason = process.ExitReason(); TEST(process.ExitType() == EExitKill); CleanupStack::PopAndDestroy(); return exitreason; }
enum TVerdict CEsockTest2_1::easyTestStepL() { TESTL(EPass == TestStepResult()); TInt nSockets = iEsockSuite->GetSocketListCount(); // bind to n sockets on port 0 // get ip address TInetAddr addr, addr1; TESTL(GetIpAddressFromConfig(SectionName(_L("Test_2.1")), _L("ipAddress"), addr)); // set the port number to 0 addr.SetPort(0); // for each open socket TInt nRet; TUint port; for (TInt n = 0; n < nSockets; n++) { // bind the socket nRet = iEsockSuite->GetSocketHandle(n + 1).Bind(addr); TESTEL(nRet == KErrNone, nRet); // get the socket name iEsockSuite->GetSocketHandle(n + 1).LocalName(addr1); // check address has been set correctly TESTL(addr.Match(addr1)); // get port number - check it is non-zero port = iEsockSuite->GetSocketHandle(n + 1).LocalPort(); TESTL(port > 0); } return EPass; }
/** * ConnectExpectError is a utility function to connect and disconnect using an Agt * * The preconditions for this function are assumed to be set so that * a connection attempt will fail with the error passed to the function and * at the stage passed to the function. * */ void CTestStepCsdAgt::ConnectExpectErrorL(TInt aError, TInt aStage) { TInt err; TInt stage; CNifAgentRefN1 *agent; // Construct a new Dummy Nifman Instance Log(_L("Loading DUMMYNIF.DLL")); agent = CNifAgentRefN1::NewL(this); CleanupStack::PushL(agent); // Attempt connection Log(_L("Connecting...")); agent->Connect(); // Check result codes agent->GetCompletionCode(err); // If the connection (wrongly) goes ahead without detecting an error, we have to leave, // but if we just return the unexpected KErrNone, the caller will think everything's // OK. Make sure that if we have got a KErrNone, we return something else, so that it // gets spotted as a test failure. if (err == KErrNone) TESTEL(err==aError,KErrGeneral); else TESTEL(err==aError,err); // Check ConnectComplete was reported at the correct stage in the state machine agent->GetProgressStage(stage); TESTEL(stage==aStage,stage); Log(_L("Connect failed as expected")); DelayL(2000000); // Disconnect Log(_L("Disconnecting...")); agent->Disconnect(); // Check result code agent->GetCompletionCode(err); TESTEL(err==KErrNone,err); Log(_L("Disconnect successful")); // Finished with Dummy Nifman so delete it CleanupStack::PopAndDestroy(agent); Log(_L("DUMMYNIF.DLL Unloaded")); }
TVerdict CDhcpTestStep1_1::doTestStepL() /** * @return - TVerdict code, only ever returns EPass, else leaves with error! * Override of base class pure virtual * Connect to DHCP Daemon (test doc 4.1.1) * Test cannot explicitly connect as we use the * RConnection API here which will test full * functionality through the system. This test * therefore starts an ethernet connection with * settings in commDB to specify using dhcp configuration * to provide the connection with an address. If the connection * starts successfully, then DHCP was used to configure an * address therefore connection to DHCP by NIFMAN was achieved... */ { SetTestStepResult(EFail); RSocketServ eSock; TInt err = eSock.Connect(); TESTEL(err == KErrNone, err); CleanupClosePushL(eSock); #ifdef _DEBUG User::LeaveIfError(RProperty::Set(KMyPropertyCat, KMyPropertyDestPortv4, 67)); User::LeaveIfError(RProperty::Set(KMyPropertyCat, KMyPropertyDestPortv6, 547)); #endif RConnection connNET1; err = connNET1.Open(eSock); TESTEL(err == KErrNone, err); CleanupClosePushL(connNET1); err = connNET1.Start(iConnPrefs); // see test script for IAP used TESTEL(err == KErrNone, err); err = connNET1.Stop(); TESTEL(err == KErrNone, err); CleanupStack::PopAndDestroy(&connNET1); CleanupStack::PopAndDestroy(&eSock); SetTestStepResult(EPass); return TestStepResult(); }
TVerdict CDhcpTestStep1_4::doTestStepL() /** * @return - TVerdict code only ever returns EPass, else leaves with error! * Override of base class pure virtual * Get DHCP Server Address (test case 4.1.4) * As no DHCP configuration is used for this * test, the connection cannot be queried for * the DHCP Server that assigned any address... */ { SetTestStepResult(EFail); RSocketServ eSock; TInt err = eSock.Connect(); TESTEL( err == KErrNone, err); CleanupClosePushL(eSock); #ifdef _DEBUG User::LeaveIfError(RProperty::Set(KMyPropertyCat, KMyPropertyDestPortv4, 67)); #endif RConnection connNET1; err = connNET1.Open(eSock); TESTEL( err == KErrNone, err); CleanupClosePushL(connNET1); err = connNET1.Start(iConnPrefs); // see test script for IAP used TESTEL(err == KErrNone, err); TRequestStatus stat; TConnectionAddrBuf address; address().iAddressFamily = IpAddressFamilyL(); connNET1.Ioctl(KCOLConfiguration, KConnGetServerAddr, stat, &address); User::WaitForRequest(stat); TESTEL( stat == KErrNotSupported, stat.Int()); err = connNET1.Stop(); TESTEL(err == KErrNone, err); CleanupStack::PopAndDestroy(&connNET1); CleanupStack::PopAndDestroy(&eSock); SetTestStepResult(EPass); return TestStepResult(); }
TVerdict CDhcpTestStep1_5::doTestStepL() /** * @return - TVerdict code only ever returns EPass, else leaves with error! * Override of base class pure virtual * Get Remaining Lease Time (test case 4.1.5) */ { SetTestStepResult(EFail); RSocketServ eSock; TInt err = eSock.Connect(); TESTEL(err == KErrNone, err); CleanupClosePushL(eSock); #ifdef _DEBUG User::LeaveIfError(RProperty::Set(KMyPropertyCat, KMyPropertyDestPortv4, 67)); #endif RConnection connNET1; err = connNET1.Open(eSock); TESTEL(err == KErrNone, err); CleanupClosePushL(connNET1); err = connNET1.Start(iConnPrefs); // see test script for IAP used TESTEL(err == KErrNone, err); TConnectionLeaseInfoBuf leaseTime1; leaseTime1().iAddressFamily = IpAddressFamilyL(); TRequestStatus stat; connNET1.Ioctl(KCOLConfiguration, KConnGetAddrLeaseTimeRemain, stat, &leaseTime1); User::WaitForRequest(stat); TESTEL(stat == KErrNotSupported, stat.Int()); err = connNET1.Stop(); TESTEL(err == KErrNone, err); CleanupStack::PopAndDestroy(&connNET1); CleanupStack::PopAndDestroy(&eSock); SetTestStepResult(EPass); return TestStepResult(); }
/** Copies the test file dummy.rsc from z: to c: using RSmlTestUtils rather than aFs due to platsec protection of involved directories. */ void CT_ApsScanStep::CopyRecognizerFileL() { RSmlTestUtils fs; CleanupClosePushL(fs); User::LeaveIfError(fs.Connect()); // Ensure c:\\resource\\plugins is created, otherwise leave and abort this teststep TInt err = fs.CreateDirectoryL(KRscTargetDir); TESTEL((err==KErrNone || err==KErrAlreadyExists), err); // Copy resource file from z: to c:, if unsuccessful - leave and abort this teststep #if defined (__WINSCW__) err = fs.CopyFileL(KRscSourcePathWinscw, KRscTargetPath); #else err = fs.CopyFileL(KRscSourcePathArmv5, KRscTargetPath); #endif TESTEL(err==KErrNone, err); CleanupStack::PopAndDestroy(&fs); }
TVerdict COpenCloseBogus::doTestStepL() { SetTestStepResult(EPass); INFO_PRINTF1(_L("============================================\n")); INFO_PRINTF1(_L("Test : test1\n")); INFO_PRINTF1(_L("============================================\n")); RTestNif one; INFO_PRINTF1(_L("Open/close with bogus name")); TInt Err = one.Open(_L("testagent")); TESTEL(Err == KErrNone, Err); one.Close(); RLibrary r; Err = r.Load(_L("bogus.agt")); TESTEL(Err == KErrNotFound, Err); return TestStepResult(); }
enum TVerdict CEsockTest10_2::easyTestStepL() { // Ioctl on an unconnected socket // open a TCP socket RSocket sock; CleanupClosePushL(sock); TInt nRet = sock.Open(iEsockSuite->iSocketServer, KAfInet, KSockStream, KProtocolInetTcp); TESTEL(KErrNone == nRet, nRet); // get select state of the socket sock.GetOpt (KSOSelectPoll, KSOLSocket, (nRet = 0)); // socket is blocked for writing, has no data for reading // and has no exception condition TESTEL(0 == nRet, nRet); // close the socket CleanupStack::PopAndDestroy(); return EPass; }
enum TVerdict CEsockTest10_3::easyTestStepL() { TESTL(EPass == TestStepResult()); // cancel an Ioctl operation TPckgBuf<TUint> flags; flags() = KSockSelectExcept; // get select state of the server socket // do not wait for operation to complete TRequestStatus stat; iEsockSuite->GetSocketHandle(iSockIndex3).Ioctl(KIOctlSelect, stat, &flags, KSOLSocket); TESTEL(KRequestPending == stat.Int(), stat.Int()); // cancel the Ioctl operation iEsockSuite->GetSocketHandle(iSockIndex3).CancelIoctl(); // wait for operation to complete User::WaitForRequest(stat); // completion status will be KErrNone or KErrCancel TESTEL(KErrCancel == stat.Int(), stat.Int()); // get select state of the server socket flags() = KSockSelectRead | KSockSelectWrite | KSockSelectExcept; iEsockSuite->GetSocketHandle(iSockIndex3).Ioctl(KIOctlSelect, stat, &flags, KSOLSocket); User::WaitForRequest(stat); TESTEL(KErrNone == stat.Int(), stat.Int()); // socket is not blocked for writing TESTL(flags()==KSockSelectWrite); return EPass; }
// To test multiple start enum TVerdict TE_RConnectionTest318::doTestStepL(void) { RSocketServ ss; RConnection conn1; TRequestStatus tStartConn; TInt nErr = OpenSocketServer( ss ); TESTEL(KErrNone == nErr, nErr); CleanupClosePushL(ss); nErr = conn1.Open( ss ); TESTEL( nErr == KErrNone, nErr ); CleanupClosePushL(conn1); conn1.Start( tStartConn ); nErr = conn1.Start(); //shouldn't be so quick KErrInUse expected TESTEL( nErr == KErrInUse, nErr ); // wait for completion User::WaitForRequest( tStartConn ); TESTEL( tStartConn.Int() == KErrNone, tStartConn.Int() ); //close conn1 conn1.Stop(); CleanupStack::PopAndDestroy(); //the other way around nErr = conn1.Open( ss ); TESTEL( nErr == KErrNone, nErr ); CleanupClosePushL(conn1); nErr = conn1.Start(); TESTEL( nErr == KErrNone, nErr ); conn1.Start( tStartConn ); User::WaitForRequest( tStartConn ); //should get KErrAlreadyExists TESTEL( tStartConn.Int() == KErrAlreadyExists, tStartConn.Int() ); //close conn1 conn1.Stop(); CleanupStack::PopAndDestroy(); //close ss CleanupStack::PopAndDestroy(); return TestStepResult(); } // TE_RConnectionTest318
// creates a connection and destroys it again enum TVerdict TE_RConnectionTest301::doTestStepL(void) { TInt err; RConnection activeConn; RConnection conn; RSocketServ ss; TRequestStatus status; TInterfaceNotificationBuf info; err = OpenSocketServer(ss); TESTEL(KErrNone == err, err); CleanupClosePushL(ss); err = OpenConnection(conn, ss); TESTEL(KErrNone == err, err); CleanupClosePushL(conn); err = OpenConnection(activeConn, ss); TESTEL(KErrNone == err, err); CleanupClosePushL(activeConn); err = StartConnectionWithOverrides(conn, 1); TESTEL(KErrNone == err, err); // issue request AllInterfaceNotification(conn, status, info); // start another different connection to complete request if it hasn't already done so err = StartConnectionWithOverrides(activeConn, 6); TESTEL(KErrNone == err, err); // wait for completion User::WaitForRequest(status); // check for correct value TESTEL(status.Int() == KErrInUse, status.Int()); CloseConnection(activeConn); CleanupStack::Pop(); CloseConnection(conn); CleanupStack::Pop(); CloseSocketServer(ss); CleanupStack::Pop(); return TestStepResult(); } // TE_RConnectionTest301