LOCAL_C void doTestsL() { theRemovedEntries = new(ELeave)CMsvEntrySelection; CleanupStack::PushL(theRemovedEntries); CMsgsTestUtils::Start(_L("Large selection operations - will be slow")); TestMultipleNotifsL(); CMsgsTestUtils::Complete(); test.Printf(_L("** Waiting 10s for delayed updating **\n")); TestWaitL(); CMsgsTestUtils::Next(_L("Hidden entry stream")); TestHiddenEntryStreamsL(); CMsgsTestUtils::Complete(); CMsgsTestUtils::Next(_L("Removing all entries")); test.Printf(_L("...and checking for orphan files\n")); TestRemovingAllFilesL(); CMsgsTestUtils::Complete(); CMsgsTestUtils::Next(_L("Testing Session With Shared RFs ")); TestSessionWithSharedFsL(); CMsgsTestUtils::Complete(); CMsgsTestUtils::Next(_L("Testing Session With Priority Change ")); TestSessionWithPriorityL(); CMsgsTestUtils::Complete(); CleanupStack::PopAndDestroy(); // theRemovedEntries }
/** @SYMTestCaseID PDS-SQL-UT-4196 @SYMTestCaseDesc RFileBuf64::Open() file I/O error simulation test. The test calls RFileBuf64:Open() in a file I/O error simulation loop. @SYMTestActions RFileBuf64::Open() file I/O error simulation test. @SYMTestExpectedResults Test must not fail @SYMTestPriority High @SYMDEF DEF145198 */ void OpenFileIoErrTest() { RFileBuf64 fbuf(1024);//buffer capacity = 1024 bytes TInt err = fbuf.Create(TheFs, KTestFile3, EFileRead | EFileWrite); fbuf.Close(); TEST2(err, KErrNone); err = KErrGeneral; TInt cnt = 0; for(;err<KErrNone;++cnt) { TheTest.Printf(_L("===Iteration %d. Simulated error:\r\n"), cnt); for (TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError) { TheTest.Printf(_L("%d "), fsError); __UHEAP_MARK; (void)TheFs.SetErrorCondition(fsError, cnt); err = fbuf.Open(TheFs, KTestFile3, EFileRead | EFileWrite); (void)TheFs.SetErrorCondition(KErrNone); fbuf.Close(); __UHEAP_MARKEND; } TheTest.Printf(_L("\r\n")); } TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt); (void)TheFs.Delete(KTestFile3); }
//Delete "aFullName" file. static void DeleteFile(const TDesC& aFullName) { RFs fsSession; TInt err = fsSession.Connect(); if(err == KErrNone) { TEntry entry; if(fsSession.Entry(aFullName, entry) == KErrNone) { err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly); if(err != KErrNone) { TheTest.Printf(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName); } err = fsSession.Delete(aFullName); if(err != KErrNone) { TheTest.Printf(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName); } } fsSession.Close(); } else { TheTest.Printf(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName); } }
void TTestMsBlock::tFileAccess() { test.Start(_L("tFileAccess\n")); test.Next(_L("DriveInfo")); PrintDrvInfo(fsSession, msDrive->DriveNumber()); TVolumeInfo volInfo; TInt err = fsSession.Volume(volInfo); test(err == KErrNone); test.Printf(_L("Memory 'in use' = %lx\n"), (volInfo.iSize - volInfo.iFree)); test.Printf(_L("volInfo.iSize = %lx\n"), volInfo.iSize); test.Printf(_L("volInfo.iFree = %lx\n"), volInfo.iFree); //-- 1. create a file _LIT(KFile, "\\test_file.file"); const TUint KFileSz = 54321; test.Next(_L("Write file\n")); err = CreateCheckableStuffedFile(fsSession, KFile, KFileSz); test_KErrNone(err); //-- 2. verify the file, just in case. test.Next(_L("Verify file\n")); err = VerifyCheckableFile(fsSession, KFile); test_KErrNone(err); //-- 3. delete the file test.Next(_L("Delete file\n")); fsSession.Delete(KFile); test.End(); }
void TestDistribution(TRandom& aRandom, TInt aSamples) { TUint32* data = new TUint32[aSamples]; test_NotNull(data); TInt i; TReal mean = 0.0; for (i = 0 ; i < aSamples ; ++i) { data[i] = aRandom.Next(); mean += (TReal)data[i] / aSamples; } TReal sum2 = 0.0; for (i = 0 ; i < aSamples ; ++i) { TReal d = (TReal)data[i] - mean; sum2 += d * d; } TReal variance = sum2 / (aSamples - 1); test.Printf(_L(" mean == %f\n"), mean); test.Printf(_L(" variance == %f\n"), variance); delete [] data; }
/** @SYMTestCaseID PDS-STORE-UT-4056 @SYMTestCaseDesc Test for DEF141471 - STORE, new stream performance tests. PREQ2505 Insturmentation of PDS. RBufWriteStream & RBufReadStream performance tests. @SYMTestPriority High @SYMTestActions Test for DEF141471 - STORE, new stream performance tests. @SYMTestExpectedResults Test must not fail @SYMDEF DEF141471 */ void BufStreamTestL() { CBufFlat* bufFlat = CBufFlat::NewL(KTestDataLen); CleanupStack::PushL(bufFlat); //RBufWriteStream::Open() RBufWriteStream strm1; CleanupClosePushL(strm1); TUint32 fc = User::FastCounter(); strm1.Open(*bufFlat); TUint32 openFc = CalcTickDiff(fc, User::FastCounter()); PrintFcDiffAsUs(_L("### RBufWriteStream::Open(), Time=%d us\r\n"), openFc); DoStreamWriteTestL(strm1); CleanupStack::PopAndDestroy(&strm1); TheTest.Printf(_L(" Buffer size=%d\r\n"), bufFlat->Size()); //RBufWriteStream::Append() RBufWriteStream strm2; CleanupClosePushL(strm2); fc = User::FastCounter(); strm2.Append(*bufFlat); TUint32 appendFc = CalcTickDiff(fc, User::FastCounter()); PrintFcDiffAsUs(_L("### RBufWriteStream::Append(), Time=%d us\r\n"), appendFc); DoStreamWriteTestL(strm2); CleanupStack::PopAndDestroy(&strm2); TheTest.Printf(_L(" Buffer size=%d\r\n"), bufFlat->Size()); //RBufWriteStream::Insert() RBufWriteStream strm3; CleanupClosePushL(strm3); fc = User::FastCounter(); strm3.Insert(*bufFlat, KBufSize); TUint32 insertFc = CalcTickDiff(fc, User::FastCounter()); PrintFcDiffAsUs(_L("### RBufWriteStream::Insert(), Time=%d us\r\n"), insertFc); DoStreamWriteTestL(strm3); CleanupStack::PopAndDestroy(&strm3); TheTest.Printf(_L(" Buffer size=%d\r\n"), bufFlat->Size()); //RBufWriteStream::Truncate() RBufWriteStream strm4; CleanupClosePushL(strm4); fc = User::FastCounter(); strm4.Truncate(*bufFlat); TUint32 truncateFc = CalcTickDiff(fc, User::FastCounter()); PrintFcDiffAsUs(_L("### RBufWriteStream::Truncate(), Time=%d us\r\n"), truncateFc); DoStreamWriteTestL(strm4); CleanupStack::PopAndDestroy(&strm4); TheTest.Printf(_L(" Buffer size=%d\r\n"), bufFlat->Size()); RBufReadStream strm5; CleanupClosePushL(strm5); fc = User::FastCounter(); strm5.Open(*bufFlat); openFc = CalcTickDiff(fc, User::FastCounter()); PrintFcDiffAsUs(_L("### RBufReadStream::Open(), Time=%d us\r\n"), openFc); DoStreamReadTestL(strm5); CleanupStack::PopAndDestroy(&strm5); CleanupStack::PopAndDestroy(bufFlat); }
/** @SYMTestCaseID SYSLIB-BAFL-CT-0439 @SYMTestCaseDesc Timing Tests @SYMTestPriority High @SYMTestActions Check for the time loads needed to repeatedly load a resource @SYMTestExpectedResults Tests must not fail @SYMREQ REQ0000 */ void TRsReadTester::TimingTestsL() { test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0439 Timing tests ")); test.Next(_L("BUTTON and FLPTED")); TUint time = User::TickCount(); for (TInt ii=0; ii<100; ii++) { TResourceReader reader; CreateResourceReaderLC(reader,SYS_BUTTON_ONE); CleanupStack::PopAndDestroy(); CreateResourceReaderLC(reader,SYS_FLPTED_ONE); CleanupStack::PopAndDestroy(); } time = User::TickCount() - time; test.Printf(_L("Time to load 100 times: %d\n"),time); test.Next(_L("BUTTON and ARRAY")); time = User::TickCount(); for (TInt jj=0; jj<100; jj++) { TResourceReader reader; CreateResourceReaderLC(reader,SYS_BUTTON_ONE); CleanupStack::PopAndDestroy(); CreateResourceReaderLC(reader,SYS_ARRAY_ONE); CleanupStack::PopAndDestroy(); } time = User::TickCount() - time; test.Printf(_L("Time to load 100 times: %d\n"),time); }
/** @SYMTestCaseID PDS-SQL-UT-4197 @SYMTestCaseDesc RFileBuf64::Temp() file I/O error simulation test. The test calls RFileBuf64:Temp() in a file I/O error simulation loop. @SYMTestActions RFileBuf64::temp() file I/O error simulation test. @SYMTestExpectedResults Test must not fail @SYMTestPriority High @SYMDEF DEF145198 */ void TempFileIoErrTest() { TInt err = KErrGeneral; TInt cnt = 0; for(;err<KErrNone;++cnt) { TheTest.Printf(_L("===Iteration %d. Simulated error:\r\n"), cnt); for (TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError) { TheTest.Printf(_L("%d "), fsError); __UHEAP_MARK; (void)TheFs.SetErrorCondition(fsError, cnt); RFileBuf64 fbuf(1024);//buffer capacity = 1024 bytes TFileName tmpFileName; err = fbuf.Temp(TheFs, KTestDir, tmpFileName, EFileWrite | EFileRead); (void)TheFs.SetErrorCondition(KErrNone); fbuf.Close(); __UHEAP_MARKEND; TInt err2 = TheFs.Delete(tmpFileName); TInt expectedErr = err == KErrNone ? KErrNone : KErrNotFound; TEST2(err2, expectedErr); } TheTest.Printf(_L("\r\n")); } TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt); }
TInt CCpuMeter::Construct() { iNumCpus = NumberOfCpus(); iNullThreads = (RThread*)User::AllocZ(iNumCpus*sizeof(RThread)); iDelta = (TInt*)User::AllocZ(iNumCpus*sizeof(TInt)); iMeas[0] = (TTimeIntervalMicroSeconds*)User::AllocZ(iNumCpus*sizeof(TTimeIntervalMicroSeconds)); iMeas[1] = (TTimeIntervalMicroSeconds*)User::AllocZ(iNumCpus*sizeof(TTimeIntervalMicroSeconds)); if (!iNullThreads || !iDelta || !iMeas[0] || !iMeas[1]) return KErrNoMemory; TFullName kname; _LIT(KLitKernelName, "ekern.exe*"); _LIT(KLitNull, "::Null"); TFindProcess fp(KLitKernelName); test_KErrNone(fp.Next(kname)); test.Printf(_L("Found kernel process: %S\n"), &kname); kname.Append(KLitNull); TInt i; for (i=0; i<iNumCpus; ++i) { TFullName tname(kname); TFullName tname2; if (i>0) tname.AppendNum(i); TFindThread ft(tname); test_KErrNone(ft.Next(tname2)); TInt r = iNullThreads[i].Open(ft); test_KErrNone(r); iNullThreads[i].FullName(tname2); test.Printf(_L("Found and opened %S\n"), &tname2); } for (i=0; i<iNumCpus; ++i) iNullThreads[i].GetCpuTime(iMeas[0][i]); iNextMeas = 1; return KErrNone; }
/** @SYMTestCaseID PDS-SQL-UT-4161 @SYMTestCaseDesc SQL server startup file I/O error simulation test @SYMTestPriority High @SYMTestActions Runs the SQL server startup code in a file I/O error simulation loop. @SYMTestExpectedResults Test must not fail @SYMDEF DEF144096 */ void SqlServerStartupFileIoErrorTest() { RFs fs; TInt err = fs.Connect(); TEST2(err, KErrNone); for(TInt fsError=KErrNotFound;fsError>=KErrBadName;--fsError) { TheTest.Printf(_L("===Simulated error: %d\r\nIteration: "), fsError); err = KErrNotFound; TInt cnt=0; while(err<KErrNone) { TheTest.Printf(_L("%d "), cnt); (void)fs.SetErrorCondition(fsError, cnt); TRAP(err, CreateAndDestroySqlServerL()); (void)fs.SetErrorCondition(KErrNone); if(err != KErrNone) { ++cnt; } } TEST2(err, KErrNone); TheTest.Printf(_L("\r\n===File I/O error simulation test succeeded on iteration %d===\r\n"), cnt); } fs.Close(); }
/** @SYMTestCaseID PDS-SQL-UT-4233 @SYMTestCaseDesc CSqlBurEventMonitor object creation - OOM test The test runs CSqlBurEventMonitor::NewL() in an OOM loop. @SYMTestActions CSqlBurEventMonitor object creation - OOM test @SYMTestExpectedResults Test must not fail @SYMTestPriority High */ void SqlBurEventMonitorOomTest() { TInt err = KErrNoMemory; TInt failingAllocationNo = 0; TheTest.Printf(_L("Iteration:\r\n")); while(err == KErrNoMemory) { TheTest.Printf(_L(" %d"), ++failingAllocationNo); TInt startProcessHandleCount; TInt startThreadHandleCount; RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); __UHEAP_MARK; __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, failingAllocationNo, KBurstRate); CSqlBurEventMonitor* monitor = NULL; TRAP(err, monitor = CSqlBurEventMonitor::NewL(*TheSqlSrvTestBurInterface)); delete monitor; __UHEAP_RESET; __UHEAP_MARKEND; TInt endProcessHandleCount; TInt endThreadHandleCount; RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); TEST2(startProcessHandleCount, endProcessHandleCount); TEST2(startThreadHandleCount, endThreadHandleCount); } TEST2(err, KErrNone); TheTest.Printf(_L("\r\n=== OOM Test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo); }
/** Test opening channel on multiple units @pre TestLoadDriver() called */ void TestExDriver::TestChannelOnMultipleUnits() { TInt r; iTest.Printf(_L("Open Channel on Unit-1\n")); // Open thelogical channel, driver for unit 1. This is a user-side wrapper // function for RBusLogicalChannel::DoCreate() API. Hence DoCreate() is // called in Open() for unit 1. // r=iLdd.Open(KUnit1); iTest(r==KErrNone); // Close the channel opened iLdd.Close(); iTest.Printf(_L("Open Channel on Unit-2\n")); // Valid unit, hence return success r=iLdd.Open(KUnit2); iTest(r==KErrNone); // Close the channel opened iLdd.Close(); iTest.Printf(_L("Open Channel on Unit-3\n")); // Invalid unit, hence return error r=iLdd.Open(KUnit3); iTest(r==KErrNotSupported); iTest.Printf(_L("Open Channel on Unit-3: Failed as Expected\n")); // Channel opened fail, hence no need to close }
/** @SYMTestCaseID SYSLIB-DBMS-CT-0015 @SYMTestCaseDesc OPen table test. This test app has "PowerMgmt" (TABLE A: READ) capability, which allows it to read data from table A. B and C tables can be read too, because they do not have read security policy. The attempts to open A, B and C tables in insert/update mode must fail. @SYMTestPriority High @SYMTestActions Open table test. @SYMTestExpectedResults The test must not fail. @SYMREQ REQ2429 DBMS shall provide an API to apply security policies to database tables. */ static void TblOpenL() { TheTest.Printf(_L("An attempt to open table A\n")); //The test must fail, because the test app cannot satisfy table A, policy W. TInt err = TheTbl.Open(TheDb, KTblNameA); TEST2(err, KErrPermissionDenied); //The test must pass, because the test app can satisfy table A, policy R. err = TheTbl.Open(TheDb, KTblNameA, RDbRowSet::EReadOnly); TEST2(err, KErrNone); TheTbl.Close(); TheTest.Printf(_L("An attempt to open table B\n")); //The test must fail, because the test app cannot satisfy table B, policy W. err = TheTbl.Open(TheDb, KTblNameB); TEST2(err, KErrPermissionDenied); //The test must pass, because table B has no R policy. err = TheTbl.Open(TheDb, KTblNameB, RDbRowSet::EReadOnly); TEST2(err, KErrNone); TheTbl.Close(); TheTest.Printf(_L("An attempt to open table C\n")); //The test must fail, because the test app cannot satisfy table C, policy W. err = TheTbl.Open(TheDb, KTblNameC); TEST2(err, KErrPermissionDenied); //The test must pass, because table C has no R policy. err = TheTbl.Open(TheDb, KTblNameC, RDbRowSet::EReadOnly); TEST2(err, KErrNone); TheTbl.Close(); }
LOCAL_C void doOpenSerialL(RBusDevComm& aSerial, TInt aPort) { TInt error; #if defined (__WINS__) error=User::LoadPhysicalDevice(_L("ECDRV")); #else error=User::LoadPhysicalDevice(_L("EUART1")); if (error==KErrNone||error==KErrAlreadyExists) error=User::LoadPhysicalDevice(_L("EUART2")); if (error==KErrNone||error==KErrAlreadyExists) error=User::LoadPhysicalDevice(_L("EUART3")); if (error==KErrNone||error==KErrAlreadyExists) error=User::LoadPhysicalDevice(_L("EUART4")); #endif if (error==KErrNone||error==KErrAlreadyExists||error==KErrNotFound) error=User::LoadLogicalDevice(_L("ECOMM")); if (error==KErrAlreadyExists) error=KErrNone; User::LeaveIfError(error); test.Printf(_L("Loaded serial device drivers.\n")); // Open serial port. User::LeaveIfError(aSerial.Open(aPort)); User::LeaveIfError(SetSerialConfiguration(aSerial)); test.Printf(_L("Opened serial port.\n")); }
//DEF074278: Java VM requires more command line testArguments. void Defect_DEF074278_Part2() { TBuf<180> testArguments(_L("one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one twenty-two twenty-three twenty-four ")); TBuf<210> inputArguments; TUint testArgNo = 25; int argc=0; char** argv=0; char** envp=0; TheTest.Printf(_L("Retrieving the arguments passed in from T_UCRT0P1\n")); __crt0(argc,argv,envp); // get args & environment from somewhere //Get all the arguments into a descriptor, beginning at pos 1, as pos 0 contains //the T_UCRT0P2 exe path and name. for (TInt i=1; i < argc; i++) { char *str=argv[i]; while(*str) inputArguments.Append((TChar)*str++); inputArguments.Append(' '); } //tests all the arguments were passed to the new process correctly. TheTest.Printf(_L("Checking all arguements were passed to the new process correctly... ")); TEST(testArguments == inputArguments ); TEST2(testArgNo, argc); exit(0); }
TInt CSuspendTest::ZeroFillBlock( TInt aBlockNumber ) // // Zero-fills and entire block // The requires that writing works // { test.Printf( _L("Zero-filling block %d\n"), aBlockNumber ); // // Create a buffer full of zeros // const TInt KZeroBufSize = 512; TBuf8<KZeroBufSize> buf; buf.FillZ( buf.MaxLength() ); // // Write the data out to the Flash // TInt writeCount = iBlockSize / KZeroBufSize; TInt r = KErrNone; TUint blockBaseOffset = aBlockNumber * iBlockSize; TInt pos = blockBaseOffset; for( ; (writeCount > 0) && (KErrNone == r); writeCount-- ) { r = iDrive.Write( pos, buf ); if( r != KErrNone ) { test.Printf( _L("... FAIL: write failed (%d) at offset 0x%x\n"), pos ); } pos += KZeroBufSize; } return r; }
TInt64 runTest(TThreadFunction aFunction,const TDesC& aTitle) { RThread thread; TInt r=thread.Create(aTitle,aFunction,KDefaultStackSize,KHeapSize,KHeapSize,NULL); if(r!=KErrNone) { test.Printf(_L("Failed to create thread with error %d\n"),r); return(r); } thread.Resume(); User::After(1000000); count=0; User::After(KAverageOverInSeconds*1000000); TInt64 result=count; barrier = a; if (!barrier) barrier = c; barrier = b; if (!barrier) barrier = a; barrier = c; if (!barrier) barrier = b; thread.Kill(0); thread.Close(); result*=KNumberOfCalculationsPerLoop; result/=KAverageOverInSeconds; r=I64INT(result); test.Printf(_L("%S executed %d in 1 second\n"),&aTitle,r); return(result); }
GLDEF_C TInt E32Main() { test.Title(); test.Start(_L("Waiting...")); RUndertaker u; TInt r=u.Create(); test(r==KErrNone); //to avoid RVCT4 warning of unreachable statement. volatile TInt forever = 0; while(forever) { TInt h; TRequestStatus s; r=u.Logon(s,h); test(r==KErrNone); User::WaitForRequest(s); RThread t; t.SetHandle(h); TBuf8<128> b; t.Context(b); TInt *pR=(TInt*)b.Ptr(); TFullName tFullName = t.FullName(); TExitCategoryName tExitCategory = t.ExitCategory(); test.Printf(_L("Thread %S Exit %d %S %d\n"),&tFullName,t.ExitType(),&tExitCategory,t.ExitReason()); test.Printf(_L("r0 =%08x r1 =%08x r2 =%08x r3 =%08x\n"),pR[0],pR[1],pR[2],pR[3]); test.Printf(_L("r4 =%08x r5 =%08x r6 =%08x r7 =%08x\n"),pR[4],pR[5],pR[6],pR[7]); test.Printf(_L("r8 =%08x r9 =%08x r10=%08x r11=%08x\n"),pR[8],pR[9],pR[10],pR[11]); test.Printf(_L("r12=%08x r13=%08x r14=%08x r15=%08x\n"),pR[12],pR[13],pR[14],pR[15]); test.Printf(_L("cps=%08x dac=%08x\n"),pR[16],pR[17]); t.Close(); } return 0; }
/** Load the driver, LDD and PDD and verify if successful */ void TestExDriver::TestLoadDriver() { TInt r; // [RTest::Next() starts new set of tests] iTest.Next(_L("Test driver Loading")); // Load the PDD iTest.Printf(_L("Load Physical Device\n")); // Load the PDD. User API will load the PDD dll by name and // also enable the loader to search for the PDD object by name. // r = User::LoadPhysicalDevice(KExDriverPdd); // PDD loading is considered successful, if either it is loaded now // or it is already loaded and is existing // iTest((r==KErrNone)||(r==KErrAlreadyExists)); // Load the LDD iTest.Printf(_L("Load Logical Device\n")); // Load the LDD. User API will load the LDD dll by name and // also enable the loader to search for the LDD object by name. // r = User::LoadLogicalDevice(KExDriverLdd); // LDD loading is considered successful, if either it is loaded now // or it is already loaded and is existing iTest((r==KErrNone)||(r==KErrAlreadyExists)); }
/** Unload the driver, LDD and PDD and verify if successful @pre TestLoadDriver() called */ void TestExDriver::TestUnloadDriver() { TInt r; iTest.Next(_L("Test driver Un-Loading")); // Free the logical device / ldd iTest.Printf(_L("Free Logical Device\n")); r=User::FreeLogicalDevice(KDriverName); iTest(r==KErrNone); // Free the physical device / pdd iTest.Printf(_L("Free Physical Device\n")); // Instead of directly using the pdd name, get the PDD factory object name // and append with extension name, to unload the PDD. // TName pddName(KDriverName); _LIT(KVariantExtension,".pdd"); pddName.Append(KVariantExtension); // Free the PDD, resulting in freeing pdd factory object. Name passed here // should match with the one used by driver to register itself in DoCreate(). // r=User::FreePhysicalDevice(pddName); iTest(r==KErrNone); }
void Test1M(const SRatio& aRatio) { SRatio ratio = aRatio; const TInt N = sizeof(MultTestIntegers)/sizeof(MultTestIntegers[0]); test.Printf(_L("Testing %d integers\n"), N); TInt i; for (i=0; i<N; ++i) { TUint32 I = MultTestIntegers[i]; TUint32 I0 = I; TUint32 I1 = I; TInt r0 = RatioMult(aRatio, I0); TInt r1 = Driver.RatioMult(ratio, I1); if (r0!=KErrNone || r1!=KErrNone) { if (r0!=r1) { test.Printf(_L("Return code mismatch r0=%d r1=%d (I=%08x I0=%08x I1=%08x)\n"), r0, r1, I, I0, I1); test(0); } } else if (I0!=I1) { test.Printf(_L("Result mismatch I=%08x I0=%08x I1=%08x\n"), I, I0, I1); } } }
void CTestXonXoff::WriteComplete(TInt aStatus) { if (iTrace) { Test.Printf(_L("CTestXonXoff::WriteComplete(%d) len = %d/%d (%d)\r\n"), aStatus, iWriter->iDes.Length(), iWriter->iDes.MaxLength(), iWriter->iTotal); } if (aStatus!=KErrNone) { Fail(ETestFailWrite, aStatus); return; } switch (iState) { case EWaitReady: iRetries = 0; iTimer->Cancel(); iState = EWaitIO; Test.Printf(_L("Port Ready\r\n")); LineFailOn(); iStartTime.UniversalTime();; Write(); Read(); break; case EWaitIO: iRetries = 0; Write(); break; default: break; } }
// send a request and resend any continuations - use SDP_DEBUG to dump TUint testSdpContL(RTest& test, TUint8* aReqData, TUint aReqLen, TUint8 aReqId, /*TUint8* aRespData,*/ TUint aMtu) { TUint8 pduId = aReqId; HBufC8* requestHBuf = HBufC8::New(aReqLen + 10 /*KSdpContinuationStateLength*/); HBufC8* responseHBuf; TPtr8 request = requestHBuf->Des(); TPtr8 buf(0,0); TInt continuationLen = 0; TInt partial = 0; TInt continutations = 0; request.SetLength(0); request.Append(aReqData, aReqLen); do { pduId = aReqId; responseHBuf = InjectLC(pduId, request, aMtu); buf.Set(responseHBuf->Des()); switch(pduId) { case 0x03: test.Printf(_L("Got SDP_ServiceSearchResponse\n")); partial = BigEndian::Get16(&buf[2]); partial *= 4; partial += 4; continuationLen = buf[partial]; break; case 0x05: test.Printf(_L("Got SDP_ServiceAttributeResponse\n")); partial = BigEndian::Get16(&buf[0]); partial += 2; continuationLen = buf[partial]; break; case 0x07: test.Printf(_L("Got SDP_ServiceSearchAttributeResponse\n")); partial = BigEndian::Get16(&buf[0]); partial += 2; continuationLen = buf[partial]; break; default: test.Printf(_L("Got UnknownResponse (0x%x)\n"), buf[0]); continuationLen = 0; // create a dummy non-continuation break; } continutations++; request.Zero(); request.Append(aReqData, aReqLen-1); request.Append(&buf[partial], continuationLen+1); //1 for continuation len CleanupStack::PopAndDestroy(/*responseHBuf*/); } while (continuationLen != 0); delete requestHBuf; return continutations; }
LOCAL_C void InitL() { TBuf<80> logFile(KLogFileName); #if defined(__WINS__) && defined(__WINSCW__) logFile.Append(_L(".WINSCW")); #elif(__WINS__) logFile.Append(_L(".WINS")); #else logFile.Append(_L(".MARM")); #endif #if defined(_DEBUG) logFile.Append(_L(".DEB")); #else logFile.Append(_L(".REL")); #endif logFile.Append(_L(".LOG")); gTest.Printf(_L("\nLog File ")); gTest.Printf(logFile); gTest.Printf(_L("\n")); log = CImLog::NewL(logFile, EAppend); CleanupStack::PushL(log); log->AppendComment(_L8("Test Results")); log->AppendComment(_L8("T_GMXMLFAILURE memory leak test in XMLParser")); log->AppendComment(_L8("Test 1 Starting")); }
GLDEF_C TInt E32Main() { test.Title(); test.Start(_L("Create chunk")); RChunk c; TInt r=c.CreateDisconnectedLocal(0,0x1000,0x100000); test(r==KErrNone); r=c.Commit(0x10000,0x1000); test(r==KErrNone); TUint8* pBuf1=c.Base(); TUint8* pBuf2=pBuf1+0x10000; TInt s; TInt d; TInt l; for (l=1; l<300; l+=3) { for (s=0; s<=4096-l; s+=227) { test.Printf(_L("\ns=%4d l=%4d: "),s,l); for (d=0; d<=4096-l; d+=229) { DoTest(pBuf1,pBuf2,4096,s,d,l,0); DoTest(pBuf1,pBuf2,4096,s,d,l,1); } } } for (l=1; l<300; l+=3) { for (s=4096-l; s>=0; s-=227) { test.Printf(_L("\ns=%4d l=%4d: "),s,l); for (d=4096-l; d>=0; d-=229) { DoTest(pBuf1,pBuf2,4096,s,d,l,0); DoTest(pBuf1,pBuf2,4096,s,d,l,1); } } } for (l=1; l<400; l+=((l<=64)?1:3) ) { test.Printf(_L("\nOverlap test: l=%4d: "),l); for (s=32; s<=4096-32-l; s+=101) // want s to take all values 0...31 modulo 32 { for (d=s-32; d<=s+32; ++d) { DoOverlapTest(pBuf1,pBuf2,4096,s,d,l); } } } c.Close(); test.End(); return 0; }
/** Change the debugport to port KDebugPort(3) This function is optional and specific to variant. Incase of H4 variant, default debugport is 1. However since this tutorial driver tests both unit1(port1) and unit2(port2), default port is being changed to port3 to avoid conflict @post Debugport changed to COM port3 */ TInt TestExDriver::ChangeDebugPort(TInt aNewPort) { TInt muid; TInt val=-1; TInt newval; // HAL API provides interface to read and set some system attributes // specified by HALData. Here, HAL::EMachineUid gives the machine uid // on which this test is being executed. // const TInt r = HAL::Get(HAL::EMachineUid, muid); if (r==KErrNone) { // If the board is H4, we would like to change the debugport to 3 // to enable testing unit1. If unit1 is not being tested, then // no need to change the debugport // if (muid == HAL::EMachineUid_OmapH4) { // Get the deugport that is set currently using HAL API HAL::Get(HALData::EDebugPort,val); if (val!=aNewPort) { // Set the debugport to KDebugPort HAL::Set(HALData::EDebugPort,aNewPort); // Read again and verify HAL::Get(HALData::EDebugPort,newval); // Here, test() macro is not used to check as we dont want // to panic or exit if the check fails. test() macro check // panics and exits on the condition cheked being false // if(newval!=aNewPort) { // Failed changing debugport, we'll not be able to view // log messages on the debug port, but can see on display // iTest.Printf(_L("\nChanging DebugPort Failed\n")); } // Debugport changed to KDebugPort iTest.Printf(_L("\nDebugPort Changed to (%d))\n"),newval); // Let the user know the current debug port iTest.Printf(_L("\nPlease use COM port%d to view the debug messages on PC's hyperterminal\n"), newval); // User::After() suspends the current thread until a specified time // interval has expired. Time is given in microseconds. // This is added here to give the user view the above messages before // continuing // User::After(2000000); // 2 secs, in units of microseconds } } } // return the initial debug port return val; }
/** @SYMTestCaseID PDS-SQL-UT-4235 @SYMTestCaseDesc CSqlBurEventMonitor::RunL() - OOM test The test sets the backup & restore property status and then checks how the backup & restore property monitor (CSqlBurEventMonitor) reacts to the event. The test is performed in an OOM loop. @SYMTestActions CSqlBurEventMonitor::RunL() - OOM test @SYMTestExpectedResults Test must not fail @SYMTestPriority High */ void SqlBurEventMonitorRunOomTest() { CSqlBurEventMonitor* monitor = NULL; TRAPD(err, monitor = CSqlBurEventMonitor::NewL(*TheSqlSrvTestBurInterface)); err = KErrNoMemory; TInt failingAllocationNo = 0; TheTest.Printf(_L("Iteration:\r\n")); while(err == KErrNoMemory) { TheTest.Printf(_L(" %d"), ++failingAllocationNo); TInt startProcessHandleCount; TInt startThreadHandleCount; RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); __UHEAP_MARK; __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, failingAllocationNo, KBurstRate); TEST(!monitor->ActiveBackupClient()); TEST(!monitor->SqlBurCallback()); //Set the property, start the scheduler. CSqlBurEventMonitor::RunL() gets called and CSqlBurCallback //interface gets created. err = RProperty::Set(KSqlBurPropertyCategoryUid, KSqlBurBackupRestoreKey, conn::EBURBackupFull); if(err == KErrNone) { TestModeSqlBurError = KErrNone; CActiveScheduler::Start(); err = TestModeSqlBurError; if(err == KErrNone) { TEST(monitor->ActiveBackupClient() != NULL); TEST(monitor->SqlBurCallback() != NULL); //Destroy the SQL backup & restore callback err = RProperty::Set(KSqlBurPropertyCategoryUid, KSqlBurBackupRestoreKey, conn::EBURNormal); TestModeSqlBurError = KErrNone; CActiveScheduler::Start(); err = TestModeSqlBurError; if(err == KErrNone) { TEST(!monitor->ActiveBackupClient()); TEST(!monitor->SqlBurCallback()); } } } __UHEAP_RESET; __UHEAP_MARKEND; TInt endProcessHandleCount; TInt endThreadHandleCount; RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); TEST2(startProcessHandleCount, endProcessHandleCount); TEST2(startThreadHandleCount, endThreadHandleCount); } TEST2(err, KErrNone); TheTest.Printf(_L("\r\n=== OOM Test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo); delete monitor; }
GLDEF_C void CallTestsL(void) // // Call all tests // { test.Title(); test.Start(_L("Start Benchmarking ...")); test.Next(gSessionPath); ParseCommandLine(); AllocateBuffers(); RProcess().SetPriority(EPriorityBackground); TInt r = HAL::Get(HAL::EFastCounterFrequency, gFastCounterFreq); test_KErrNone(r); test.Printf(_L("HAL::EFastCounterFrequency %d\n"), gFastCounterFreq); test.Printf(_L("gReadCachingOn %d gWriteCachingOn %d gFlushAfterWrite %d gFileSequentialModeOn %d\n"), gReadCachingOn, gWriteCachingOn, gFlushAfterWrite, gFileSequentialModeOn); TestFileSeek(); // read once TestFileRead(KMaxFileSize, gMisalignedReadWrites, EFalse); // re-read TestFileRead(KMaxFileSize, gMisalignedReadWrites, ETrue); TestFileReadCPU(gMisalignedReadWrites); // append to file TestFileWrite(KMaxFileSize, gMisalignedReadWrites, EFalse); // update (overwrite) file TestFileWrite(KMaxFileSize, gMisalignedReadWrites, ETrue); TestFileWriteCPU(gMisalignedReadWrites); TestFileDelete(); // TestDirRead(); // PrintDirResults(); #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API TestLargeFileDelete(); #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API TestMkDir(); RecursiveRmDir(gSessionPath); DeAllocateBuffers(); test.End(); test.Close(); }
GLDEF_C TInt E32Main() { test.Title(); if (UserSvr::HalFunction(EHalGroupKernel, EKernelHalSmpSupported, 0, 0) == KErrNone) { test.Printf(_L("*********************************\n")); test.Printf(_L("* NOT SUPPORTED ON SMP SYSTEMS *\n")); test.Printf(_L("*********************************\n")); User::After(2000000); return(0); } test.Start(_L("Load LDD")); TInt r=User::LoadLogicalDevice(_L("D_IMPLICIT")); test(r==KErrNone || r==KErrAlreadyExists); test.Next(_L("Open channel")); RImpSysTest impSys; r=impSys.Open(); test(r==KErrNone); SStats s; test.Next(_L("Test with changing priorities")); r=impSys.Start(RImpSysTest::ETestPriority); test(r==KErrNone); Wait(30); r=impSys.Stop(s); test(r==KErrNone); TInt f1=Display(s); test.Next(_L("Test with round-robin")); r=impSys.Start(RImpSysTest::ETestRoundRobin); test(r==KErrNone); Wait(30); r=impSys.Stop(s); test(r==KErrNone); TInt f2=Display(s); test.Next(_L("Dry run")); r=impSys.Start(RImpSysTest::ETestDummy); test(r==KErrNone); Wait(30); r=impSys.Stop(s); test(r==KErrNone); TInt f3=Display(s); test.Next(_L("Close channel")); impSys.Close(); test(f1==0); test(f2==0); test(f3==0); test.End(); return KErrNone; }
/** @SYMTestCaseID PDS-SQL-UT-4207 @SYMTestCaseDesc RFileBuf64::Write() OOM test. The test calls RFileBuf64:Write() in an OOM simulation loop and verifies that no memory is leaked. The test also check that RFileBuf::DoSetCapacity() correctly operates in "out of memory" situation. @SYMTestActions RFileBuf64::Write() OOM test. @SYMTestExpectedResults Test must not fail @SYMTestPriority High @SYMDEF 380056 */ void WriteOomTest() { HBufC8* databuf = HBufC8::New(KPageSize); TEST(databuf != NULL); TPtr8 dataptr = databuf->Des(); dataptr.SetLength(KPageSize); dataptr.Fill(TChar(KChar)); TInt err = KErrNoMemory; TInt failingAllocationNo = 0; TheTest.Printf(_L("Iteration:\r\n")); while(err == KErrNoMemory) { TheTest.Printf(_L(" %d"), ++failingAllocationNo); (void)TheFs.Delete(KTestFile); MarkHandles(); MarkAllocatedCells(); __UHEAP_MARK; __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, failingAllocationNo, KBurstRate); const TInt KDefaultBufCapacity = 1024; RFileBuf64 fbuf(KDefaultBufCapacity); err = fbuf.Create(TheFs, KTestFile, EFileWrite | EFileRead); if(err == KErrNone) { err = fbuf.Write(0LL, dataptr); } fbuf.Close(); __UHEAP_RESET; __UHEAP_MARKEND; CheckAllocatedCells(); CheckHandles(); } TEST2(err, KErrNone); RFile64 file; err = file.Open(TheFs, KTestFile, EFileRead); TEST2(err, KErrNone); dataptr.Zero(); err = file.Read(dataptr); TEST2(err, KErrNone); file.Close(); TEST2(dataptr.Length(), KPageSize); for(TInt i=0;i<KPageSize;++i) { TEST(dataptr[i] == KChar); } TheTest.Printf(_L("\r\n=== OOM Test succeeded at heap failure rate of %d ===\r\n"), failingAllocationNo); //The file is left undeleted - to be used in ReadOomTest(). delete databuf; }