sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32test\server\t_open.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "t_server.h" sl@0: sl@0: GLDEF_D RTest test(_L("T_OPEN")); sl@0: sl@0: LOCAL_D TFileName gBatchFile; sl@0: LOCAL_D TBool gRunByBatch=EFalse; sl@0: sl@0: TFileName filename1=_L("Z:\\TEST\\T_FSRV.CPP"); sl@0: TFileName filename2=_L("Z:\\TEST\\T_FILE.CPP"); sl@0: TFileName dirname1=_L("Z:\\TEST\\*.XDE"); sl@0: sl@0: sl@0: LOCAL_C void Test0() sl@0: // sl@0: // Scan for open files - no sessions sl@0: // sl@0: { sl@0: sl@0: test.Next(_L("Scan for open files with no sessions open")); sl@0: CFileList* list; sl@0: TOpenFileScan fileScan(TheFs); sl@0: fileScan.NextL(list); sl@0: if (list==NULL) sl@0: return; sl@0: TInt count=list->Count(); sl@0: if (count==1) sl@0: { sl@0: gRunByBatch=ETrue; sl@0: gBatchFile=(*list)[0].iName; sl@0: delete list; sl@0: fileScan.NextL(list); sl@0: if (list==NULL) sl@0: return; sl@0: count=list->Count(); sl@0: } sl@0: while (count--) sl@0: { sl@0: TEntry entry=(*list)[count]; sl@0: test.Printf(_L("%d) EntryName = %S\n"),count,&entry.iName); sl@0: } sl@0: test.Printf(_L("Test will fail unless files are closed.\n")); sl@0: test(0); sl@0: //test.Printf(_L("Press any key ...\n")); sl@0: //test.Getch(); sl@0: } sl@0: sl@0: LOCAL_C void Test1() sl@0: // sl@0: // Test OpenFileScan sl@0: // sl@0: { sl@0: sl@0: test.Next(_L("Scan for open files - one session only")); sl@0: sl@0: RFile file1,file2,file3; sl@0: sl@0: TInt r=file1.Open(TheFs,filename1,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: sl@0: r=file2.Open(TheFs,filename2,EFileRead); sl@0: test(r==KErrNone); sl@0: sl@0: r=file3.Open(TheFs,filename1,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: sl@0: CFileList* list=NULL; sl@0: TOpenFileScan fileScan(TheFs); sl@0: TRAP(r,fileScan.NextL(list)); sl@0: test(r==KErrNone); sl@0: sl@0: if (gRunByBatch) sl@0: { sl@0: test(list!=NULL); sl@0: test(list->Count()==1); sl@0: TEntry entry=(*list)[0]; sl@0: test(entry.iName.FindF(_L(".BAT"))>=0); sl@0: delete list; sl@0: fileScan.NextL(list); sl@0: } sl@0: sl@0: sl@0: test(list!=NULL); sl@0: TInt count=list->Count(); sl@0: test(count==3); sl@0: TEntry entry=(*list)[0]; sl@0: sl@0: test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); sl@0: entry=(*list)[1]; sl@0: test(entry.iName.FindF(_L("T_FILE.CPP"))>=0); sl@0: entry=(*list)[2]; sl@0: test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); sl@0: TThreadId threadId=fileScan.ThreadId(); sl@0: RThread current; sl@0: TThreadId currentId=current.Id(); sl@0: test(threadId==currentId); sl@0: delete list; sl@0: sl@0: fileScan.NextL(list); sl@0: test(list==NULL); sl@0: sl@0: file1.Close(); sl@0: file2.Close(); sl@0: file3.Close(); sl@0: } sl@0: sl@0: LOCAL_C void Test2() sl@0: // sl@0: // Test openfilescan - empty, full, empty. sl@0: // sl@0: { sl@0: sl@0: sl@0: test.Next(_L("Scan for open files - empty sessions")); sl@0: sl@0: RFs fs1,fs2,fs3,fs4; sl@0: TInt r=fs1.Connect(); sl@0: test(r==KErrNone); sl@0: r=fs2.Connect(); sl@0: test(r==KErrNone); sl@0: r=fs3.Connect(); sl@0: test(r==KErrNone); sl@0: r=fs4.Connect(); sl@0: test(r==KErrNone); sl@0: sl@0: RFile file1,file2,file3; sl@0: sl@0: r=file1.Open(fs2,filename1,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: sl@0: r=file2.Open(fs2,filename2,EFileRead); sl@0: test(r==KErrNone); sl@0: sl@0: r=file3.Open(fs2,filename1,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: sl@0: CFileList* list; sl@0: TOpenFileScan fileScan(TheFs); sl@0: fileScan.NextL(list); sl@0: sl@0: if (gRunByBatch) sl@0: { sl@0: test(list!=NULL); sl@0: test(list->Count()==1); sl@0: TEntry entry=(*list)[0]; sl@0: test(entry.iName.FindF(_L(".BAT"))>=0); sl@0: delete list; sl@0: fileScan.NextL(list); sl@0: } sl@0: sl@0: test(list!=NULL); sl@0: TInt count=list->Count(); sl@0: test(count==3); sl@0: TEntry entry=(*list)[0]; sl@0: test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); sl@0: entry=(*list)[1]; sl@0: test(entry.iName.FindF(_L("T_FILE.CPP"))>=0); sl@0: entry=(*list)[2]; sl@0: test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); sl@0: TThreadId threadId=fileScan.ThreadId(); sl@0: RThread current; sl@0: TThreadId currentId=current.Id(); sl@0: test(threadId==currentId); sl@0: delete list; sl@0: sl@0: fileScan.NextL(list); sl@0: test(list==NULL); sl@0: sl@0: file1.Close(); sl@0: file2.Close(); sl@0: file3.Close(); sl@0: fs1.Close(); sl@0: fs2.Close(); sl@0: fs3.Close(); sl@0: fs4.Close(); sl@0: } sl@0: sl@0: LOCAL_C void Test3() sl@0: // sl@0: // Test openfilescan - empty, full, empty full sl@0: // sl@0: { sl@0: sl@0: test.Next(_L("Scan for open files - multiple sessions")); sl@0: sl@0: RFs fs1,fs2,fs3,fs4; sl@0: TInt r=fs1.Connect(); sl@0: test(r==KErrNone); sl@0: r=fs2.Connect(); sl@0: test(r==KErrNone); sl@0: r=fs3.Connect(); sl@0: test(r==KErrNone); sl@0: r=fs4.Connect(); sl@0: test(r==KErrNone); sl@0: sl@0: RFile file1,file2,file3; sl@0: sl@0: r=file1.Open(fs2,filename1,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: sl@0: r=file2.Open(fs2,filename2,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: sl@0: r=file3.Open(fs2,filename1,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: sl@0: r=file1.Open(fs4,filename1,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: sl@0: r=file2.Open(fs4,filename2,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: sl@0: r=file3.Open(fs4,filename1,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: sl@0: CFileList* list; sl@0: TOpenFileScan fileScan(TheFs); sl@0: fileScan.NextL(list); sl@0: sl@0: if (gRunByBatch) sl@0: { sl@0: test(list!=NULL); sl@0: test(list->Count()==1); sl@0: TEntry entry=(*list)[0]; sl@0: test(entry.iName.FindF(_L(".BAT"))>=0); sl@0: delete list; sl@0: fileScan.NextL(list); sl@0: } sl@0: sl@0: test(list!=NULL); sl@0: TInt count=list->Count(); sl@0: test(count==3); sl@0: TEntry entry=(*list)[0]; sl@0: test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); sl@0: entry=(*list)[1]; sl@0: test(entry.iName.FindF(_L("T_FILE.CPP"))>=0); sl@0: entry=(*list)[2]; sl@0: test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); sl@0: TThreadId threadId=fileScan.ThreadId(); sl@0: RThread current; sl@0: TThreadId currentId=current.Id(); sl@0: test(threadId==currentId); sl@0: delete list; sl@0: sl@0: fileScan.NextL(list); sl@0: test(list!=NULL); sl@0: count=list->Count(); sl@0: test(count==3); sl@0: entry=(*list)[0]; sl@0: test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); sl@0: entry=(*list)[1]; sl@0: test(entry.iName.FindF(_L("T_FILE.CPP"))>=0); sl@0: entry=(*list)[2]; sl@0: test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); sl@0: threadId=fileScan.ThreadId(); sl@0: currentId=current.Id(); sl@0: test(threadId==currentId); sl@0: delete list; sl@0: sl@0: fileScan.NextL(list); sl@0: test(list==NULL); sl@0: sl@0: file1.Close(); sl@0: file2.Close(); sl@0: file3.Close(); sl@0: fs1.Close(); sl@0: fs2.Close(); sl@0: fs3.Close(); sl@0: fs4.Close(); sl@0: } sl@0: sl@0: LOCAL_C void Test4() sl@0: // sl@0: // Test openfilescan - rdirs, empty, full, empty rdirs. sl@0: // sl@0: { sl@0: test.Next(_L("Scan for open files - check RDir sessions are ignored")); sl@0: sl@0: RFs fs1,fs2,fs3,fs4; sl@0: TInt r=fs1.Connect(); sl@0: test(r==KErrNone); sl@0: r=fs2.Connect(); sl@0: test(r==KErrNone); sl@0: r=fs3.Connect(); sl@0: test(r==KErrNone); sl@0: r=fs4.Connect(); sl@0: test(r==KErrNone); sl@0: sl@0: RDir dir1,dir2,dir3,dir4; sl@0: r=dir1.Open(TheFs,dirname1,KEntryAttMaskSupported); sl@0: test(r==KErrNone); sl@0: r=dir2.Open(TheFs,dirname1,KEntryAttMaskSupported); sl@0: test(r==KErrNone); sl@0: r=dir3.Open(TheFs,dirname1,KEntryAttMaskSupported); sl@0: test(r==KErrNone); sl@0: r=dir4.Open(TheFs,dirname1,KEntryAttMaskSupported); sl@0: test(r==KErrNone); sl@0: sl@0: RFile file1,file2,file3; sl@0: r=file1.Open(fs2,filename1,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: r=file2.Open(fs2,filename2,EFileRead); sl@0: test(r==KErrNone); sl@0: r=file3.Open(fs2,filename1,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: sl@0: RDir dir5,dir6,dir7,dir8; sl@0: r=dir5.Open(fs4,dirname1,KEntryAttMaskSupported); sl@0: test(r==KErrNone); sl@0: r=dir6.Open(fs4,dirname1,KEntryAttMaskSupported); sl@0: test(r==KErrNone); sl@0: r=dir7.Open(fs4,dirname1,KEntryAttMaskSupported); sl@0: test(r==KErrNone); sl@0: r=dir8.Open(fs4,dirname1,KEntryAttMaskSupported); sl@0: test(r==KErrNone); sl@0: sl@0: CFileList* list; sl@0: TOpenFileScan fileScan(TheFs); sl@0: fileScan.NextL(list); sl@0: sl@0: if (gRunByBatch) sl@0: { sl@0: test(list!=NULL); sl@0: test(list->Count()==1); sl@0: TEntry entry=(*list)[0]; sl@0: test(entry.iName.FindF(_L(".BAT"))>=0); sl@0: delete list; sl@0: fileScan.NextL(list); sl@0: } sl@0: sl@0: test(list!=NULL); sl@0: TInt count=list->Count(); sl@0: test(count==3); sl@0: TEntry entry=(*list)[0]; sl@0: test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); sl@0: entry=(*list)[1]; sl@0: test(entry.iName.FindF(_L("T_FILE.CPP"))>=0); sl@0: entry=(*list)[2]; sl@0: test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); sl@0: TThreadId threadId=fileScan.ThreadId(); sl@0: RThread current; sl@0: TThreadId currentId=current.Id(); sl@0: test(threadId==currentId); sl@0: delete list; sl@0: sl@0: fileScan.NextL(list); sl@0: test(list==NULL); sl@0: sl@0: file1.Close(); sl@0: file2.Close(); sl@0: file3.Close(); sl@0: dir1.Close(); dir2.Close(); sl@0: dir3.Close(); dir4.Close(); sl@0: dir5.Close(); dir6.Close(); sl@0: dir7.Close(); dir8.Close(); sl@0: fs1.Close(); fs2.Close(); sl@0: fs3.Close(); fs4.Close(); sl@0: } sl@0: sl@0: LOCAL_C void Test5() sl@0: // sl@0: // Test OpenFileScan sl@0: // sl@0: { sl@0: sl@0: test.Next(_L("Scan for open files - mixed RDirs and RFiles")); sl@0: sl@0: RFile file1,file2,file3; sl@0: TInt r=file1.Open(TheFs,filename1,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: r=file2.Open(TheFs,filename2,EFileRead); sl@0: test(r==KErrNone); sl@0: r=file3.Open(TheFs,filename1,EFileRead|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: sl@0: RDir dir1,dir2,dir3,dir4; sl@0: r=dir1.Open(TheFs,dirname1,KEntryAttMaskSupported); sl@0: test(r==KErrNone); sl@0: r=dir2.Open(TheFs,dirname1,KEntryAttMaskSupported); sl@0: test(r==KErrNone); sl@0: r=dir3.Open(TheFs,dirname1,KEntryAttMaskSupported); sl@0: test(r==KErrNone); sl@0: r=dir4.Open(TheFs,dirname1,KEntryAttMaskSupported); sl@0: test(r==KErrNone); sl@0: sl@0: CFileList* list; sl@0: TOpenFileScan fileScan(TheFs); sl@0: fileScan.NextL(list); sl@0: sl@0: if (gRunByBatch) sl@0: { sl@0: test(list!=NULL); sl@0: test(list->Count()==1); sl@0: TEntry entry=(*list)[0]; sl@0: test(entry.iName.FindF(_L(".BAT"))>=0); sl@0: delete list; sl@0: fileScan.NextL(list); sl@0: } sl@0: sl@0: test(list!=NULL); sl@0: TInt count=list->Count(); sl@0: test(count==3); sl@0: TEntry entry=(*list)[0]; sl@0: test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); sl@0: entry=(*list)[1]; sl@0: test(entry.iName.FindF(_L("T_FILE.CPP"))>=0); sl@0: entry=(*list)[2]; sl@0: test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0); sl@0: TThreadId threadId=fileScan.ThreadId(); sl@0: RThread current; sl@0: TThreadId currentId=current.Id(); sl@0: test(threadId==currentId); sl@0: delete list; sl@0: sl@0: fileScan.NextL(list); sl@0: test(list==NULL); sl@0: sl@0: file1.Close(); sl@0: file2.Close(); sl@0: file3.Close(); sl@0: dir1.Close(); sl@0: dir2.Close(); sl@0: dir3.Close(); sl@0: dir4.Close(); sl@0: } sl@0: sl@0: sl@0: NONSHARABLE_STRUCT(TThreadData) sl@0: // sl@0: // Encapsulates the data required by the worker thread. sl@0: // sl@0: { sl@0: // Thread identifier for debug output sl@0: TInt iNumber; sl@0: sl@0: // ID of the thread that started the worker thread, and the sl@0: // worker thread itself sl@0: TThreadId iMain; sl@0: TThreadId iWorker; sl@0: sl@0: // Request status object of the parent thread, used for signalling sl@0: TRequestStatus* iStatus; sl@0: sl@0: // Name of the file the parent thread requires this thread to open sl@0: TFileName iFilename; sl@0: sl@0: // Number of files opened by the thread; sl@0: TInt iNumFiles; sl@0: }; sl@0: sl@0: sl@0: LOCAL_C TInt WorkerThread(TAny* aParameter) sl@0: // sl@0: // This function is designed to run as a separate thread in order to verify the sl@0: // fix for DEF062875. sl@0: // sl@0: // When the thread is started it opens the file specified in the startup sl@0: // parameter, signals the main thread and then suspends. Once the main thread sl@0: // has completed its checking the worker thread is resumed and allowed to run sl@0: // to completion. sl@0: // sl@0: // @param aParameter Thread specific data supplied by the main thread when the sl@0: // worker thread is started. The data may be accessed by sl@0: // casting this pointer to a TThreadData* sl@0: // sl@0: { sl@0: // Can't use our global "test" object here sl@0: RTest myTest(_L("Worker thread")); sl@0: sl@0: sl@0: // Extract the parameters that this thread will need to use sl@0: TThreadData* threadData = (TThreadData*)aParameter; sl@0: sl@0: sl@0: RThread current; sl@0: TThreadId currentId = current.Id(); sl@0: sl@0: sl@0: myTest.Printf(_L("WORK%d: Worker thread %d started\n"), threadData->iNumber, threadData->iNumber); sl@0: myTest.Printf(_L("WORK%d: File: %S\n"), threadData->iNumber, &threadData->iFilename); sl@0: myTest.Printf(_L("WORK%d: Thread: %d\n"), threadData->iNumber, (TUint)currentId); sl@0: myTest.Printf(_L("WORK%d: Parent: %d\n"), threadData->iNumber, (TUint)threadData->iMain); sl@0: sl@0: sl@0: // Open the file specified by the parameter passed to us from the main sl@0: // thread sl@0: RFs myFs; sl@0: myFs.Connect(); sl@0: RFile file; sl@0: User::LeaveIfError(file.Open(myFs, threadData->iFilename, EFileRead | EFileShareReadersOnly)); sl@0: sl@0: // Signal the parent thread to continue then wait sl@0: myTest.Printf(_L("WORK%d: Signalling parent thread\n"), threadData->iNumber); sl@0: RThread parent; sl@0: User::LeaveIfError(parent.Open(threadData->iMain)); sl@0: parent.RequestComplete(threadData->iStatus, KErrNone); sl@0: sl@0: sl@0: myTest.Printf(_L("WORK%d: Waiting for parent thread to restart us\n"), threadData->iNumber); sl@0: current.Suspend(); sl@0: sl@0: sl@0: // Tidy up sl@0: myTest.Printf(_L("WORK%d: Closing file\n"), threadData->iNumber); sl@0: file.Close(); sl@0: sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: LOCAL_C void TestDEF062875() sl@0: // sl@0: // Verify that TOpenFileScan::ThreadId() returns the ID of the thread that sl@0: // opened the file. sl@0: // sl@0: // The object of the exercise here is to create several worker threads, each sl@0: // one will open a file, signal the main thread and then suspend. Once all sl@0: // the worker threads have suspended the main thread then uses sl@0: // TOpenFileScan::NextL() to verify that the thread IDs correspond to the sl@0: // worker threads that opened each file and not that of the main thread. sl@0: // sl@0: // The worker threads are then restarted and allowed to terminate naturally by sl@0: // running to completion sl@0: // sl@0: { sl@0: test.Start(_L("Test TOpenFileScan::ThreadId()")); sl@0: sl@0: const TInt KHeapSize = 32768; sl@0: sl@0: RThread thread1; sl@0: RThread thread2; sl@0: sl@0: TRequestStatus status1; sl@0: TRequestStatus status2; sl@0: sl@0: TThreadId id = RThread().Id(); sl@0: sl@0: TThreadData threadData[3]; sl@0: sl@0: threadData[0].iNumber = 0; sl@0: threadData[0].iMain = id; sl@0: threadData[0].iWorker = id; sl@0: threadData[0].iStatus = 0; sl@0: threadData[0].iFilename = filename1; sl@0: threadData[0].iNumFiles = 2; sl@0: sl@0: threadData[1].iNumber = 1; sl@0: threadData[1].iMain = id; sl@0: threadData[1].iStatus = &status1; sl@0: threadData[1].iFilename = filename1; sl@0: threadData[1].iNumFiles = 1; sl@0: sl@0: threadData[2].iNumber = 2; sl@0: threadData[2].iMain = id; sl@0: threadData[2].iStatus = &status2; sl@0: threadData[2].iFilename = filename2; sl@0: threadData[2].iNumFiles = 1; sl@0: sl@0: TInt numThreads = sizeof(threadData)/sizeof(threadData[0]); sl@0: sl@0: sl@0: // Open the files in the MAIN thread. sl@0: RFile file1; sl@0: User::LeaveIfError(file1.Open(TheFs, filename1, EFileRead | EFileShareReadersOnly)); sl@0: sl@0: RFile file2; sl@0: User::LeaveIfError(file2.Open(TheFs, filename2, EFileRead | EFileShareReadersOnly)); sl@0: sl@0: sl@0: // Create the first worker thread sl@0: test.Printf(_L("MAIN: Creating worker threads\n")); sl@0: thread1.Create(_L("WorkerThread1"), WorkerThread, KDefaultStackSize, KHeapSize, KHeapSize, &threadData[1]); sl@0: threadData[1].iWorker = thread1.Id(); sl@0: sl@0: // Start it and wait for it to suspend sl@0: thread1.Logon(status1); sl@0: thread1.Resume(); sl@0: test.Printf(_L("MAIN: Waiting for worker thread 1\n")); sl@0: User::WaitForRequest(status1); sl@0: sl@0: sl@0: // Create the second worker thread sl@0: thread2.Create(_L("WorkerThread2"), WorkerThread, KDefaultStackSize, KHeapSize, KHeapSize, &threadData[2]); sl@0: threadData[2].iWorker = thread2.Id(); sl@0: sl@0: sl@0: // Start it and wait for it to suspend sl@0: thread2.Logon(status2); sl@0: thread2.Resume(); sl@0: test.Printf(_L("MAIN: Waiting for worker thread 2\n")); sl@0: User::WaitForRequest(status2); sl@0: sl@0: sl@0: // Obtain a list of open files. At this point we should have a single open sl@0: // file, as opened by our worker thread. The thread ID reported by sl@0: // TOpenFileScan should be that of our worker thread rather than the main sl@0: // thread. sl@0: test.Printf(_L("MAIN: Verifying thread ID of open file(s)\n")); sl@0: CFileList* list; sl@0: TOpenFileScan fileScan(TheFs); sl@0: sl@0: sl@0: TInt count = 0; sl@0: FOREVER sl@0: { sl@0: fileScan.NextL(list); sl@0: sl@0: sl@0: // The NULL list indicates we've run out of sessions. sl@0: if(!list) sl@0: { sl@0: break; sl@0: } sl@0: sl@0: sl@0: TThreadId threadId=fileScan.ThreadId(); sl@0: TThreadData* data = 0; sl@0: for (count = 0; count < numThreads; count++) sl@0: { sl@0: if (threadId == threadData[count].iWorker) sl@0: { sl@0: data = &threadData[count]; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: sl@0: if (data) sl@0: { sl@0: test.Next(_L("Check number of open files...")); sl@0: test.Printf(_L("MAIN: Number of open files: %d (expecting %d)\n"), list->Count(), data->iNumFiles); sl@0: test(list->Count() == threadData[count].iNumFiles); sl@0: sl@0: sl@0: test.Next(_L("Check TThreadIds...")); sl@0: test.Printf(_L("MAIN: Main thread ID : %d\n"), (TUint)data->iMain); sl@0: test.Printf(_L("MAIN: Worker thread ID: %d\n"), (TUint)data->iWorker); sl@0: test.Printf(_L("MAIN: File thread ID : %d\n"), (TUint)threadId); sl@0: sl@0: sl@0: TInt loop = 0; sl@0: for (loop = 0; loop < list->Count(); loop++) sl@0: { sl@0: const TEntry& theEntry = (*list)[loop]; sl@0: test.Printf(_L(" ")); sl@0: test.Printf(theEntry.iName); sl@0: test.Printf(_L("\n")); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: test.Printf(_L("Ignored thread %d\n"), (TUint)threadId); sl@0: } sl@0: sl@0: sl@0: delete list; sl@0: list = 0; sl@0: sl@0: sl@0: test.Printf(_L("\n")); sl@0: } sl@0: sl@0: sl@0: // Signal the two worker threads to tidy up and run to normal termination sl@0: test.Printf(_L("MAIN: Signalling worker thread 1\n")); sl@0: thread1.Logon(status1); sl@0: thread1.Resume(); sl@0: User::WaitForRequest(status1); sl@0: sl@0: test.Printf(_L("MAIN: Signalling worker thread 2\n")); sl@0: thread2.Logon(status2); sl@0: thread2.Resume(); sl@0: User::WaitForRequest(status2); sl@0: sl@0: sl@0: // Tidy up and finish sl@0: test.Printf(_L("MAIN: Closing worker thread 1\n")); sl@0: thread1.Close(); sl@0: sl@0: test.Printf(_L("MAIN: Closing worker thread 2\n")); sl@0: thread2.Close(); sl@0: sl@0: file1.Close(); sl@0: file2.Close(); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: sl@0: GLDEF_C void CallTestsL() sl@0: // sl@0: // Call tests that may leave sl@0: // sl@0: { sl@0: filename1[0] = gExeFileName[0]; sl@0: filename2[0] = gExeFileName[0]; sl@0: dirname1[0] = gExeFileName[0]; sl@0: Test0(); sl@0: Test1(); sl@0: Test2(); sl@0: Test3(); sl@0: Test4(); sl@0: Test5(); sl@0: sl@0: TestDEF062875(); sl@0: }