sl@0: // Copyright (c) 2002-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: // e32test\pipe\t_pipe4.cpp sl@0: // This is very similar to User::WaitForRequest() but allows the User sl@0: // to specify multiple TRequestStatus objects to wait on. The function sl@0: // will return when the first TRequestStatus object completes. sl@0: // / Header Files//////// sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @STMTestCaseID KBASE-T_PIPE4-0218 sl@0: @SYMPREQ PREQ1460 sl@0: @SYMREQ REQ6142 sl@0: @SYMCR CR0923 sl@0: @SYMTestCaseDesc User::WaitForNRequests functional test sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests the operation of the API User::WaitForNRequests(). sl@0: @SYMTestExpectedResults Test should pass sl@0: */ sl@0: sl@0: #define __E32TEST_EXTENSION__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "rpipe.h" sl@0: sl@0: //// Test Objects for All threads//// sl@0: sl@0: LOCAL_D RTest test(_L("t_pipe4")); sl@0: LOCAL_D RTest test2(_L("t_pipe_t2")); sl@0: LOCAL_D RTest test3(_L("t_pipe_t3")); sl@0: LOCAL_D RTest test4(_L("t_pipe_t4")); sl@0: LOCAL_D RTest test5(_L("t_pipe_t5")); sl@0: sl@0: //// Thread Name Constants ////// sl@0: _LIT(KThread2Name, "WaitThread"); sl@0: _LIT(KThread3Name, "NotifyDataThread"); sl@0: _LIT(KThread4Name, "NotifySpaceThread"); sl@0: _LIT(KThread5Name, "CancelNotifyThread"); sl@0: sl@0: _LIT(KPipe1Name,"TestPipeP"); sl@0: _LIT(KPipe2Name,"TestPipeQ"); sl@0: _LIT(KPipe3Name,"TestPipeR"); sl@0: _LIT(KPipe4Name,"TestPipeS"); sl@0: _LIT(KPipe5Name,"TestPipeT"); sl@0: sl@0: sl@0: _LIT8(KTestDataNum,"1234567890"); sl@0: sl@0: sl@0: sl@0: const TInt KHeapSize=0x2000; sl@0: sl@0: sl@0: // Following class is used to pass thread handle information to different threads. sl@0: class TData sl@0: { sl@0: public: sl@0: TData(RPipe* aPipe, RPipe *bPipe, TInt aSize); sl@0: RPipe* rPipe; // Pipe Read handle sl@0: RPipe* wPipe; // Pipe Write handle sl@0: TInt iSize; sl@0: sl@0: sl@0: }; sl@0: sl@0: TData::TData(RPipe * aPipe , RPipe *bPipe, TInt aSize) { sl@0: rPipe = aPipe; sl@0: wPipe = bPipe; sl@0: iSize = aSize; sl@0: sl@0: } sl@0: sl@0: //////////////////////////////////////////////////// sl@0: //// WaitThread : Function opens the Read handle sl@0: //// for the pipe passed to it. sl@0: //// sl@0: //// CPipeName --> Pipe Name sl@0: //// aData --> Read Write Handle sl@0: //// sl@0: //////////////////////////////////////////////////// sl@0: TBufC<100> cPipeName; sl@0: sl@0: TInt WaitThread(TAny* aData) { sl@0: sl@0: test2.Start(_L("PIPE TEST:WaitThread Entry")); sl@0: TInt ret; sl@0: sl@0: TData& data = *(TData *)aData; // aData will have pipe handles and size. sl@0: sl@0: ret = data.rPipe->Open(cPipeName,RPipe::EOpenToRead); sl@0: test2 (ret == KErrNone); sl@0: sl@0: test2.Printf(_L("PIPE TEST:WaitThread Exit\n")); sl@0: test2.End(); sl@0: test2.Close(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: //////////////////////////////////////////////////// sl@0: //// NotifyDataThread : sl@0: //// Function writes data into the pipe. sl@0: //// sl@0: //// aData --> Read Write Handle sl@0: //// sl@0: //////////////////////////////////////////////////// sl@0: sl@0: TInt NotifyDataThread(TAny* aData) { sl@0: sl@0: TBufC8<50> cTestData(KTestDataNum); // Test Data sl@0: TInt ret; sl@0: sl@0: test3.Start(_L("PIPE TEST:NotifyDataThread Entry")); sl@0: sl@0: TData& data = *(TData *)aData; // aData will have pipe handles and size. sl@0: sl@0: User::After(10000); sl@0: sl@0: ret = data.wPipe->Write(cTestData,cTestData.Length()); sl@0: test3(ret == cTestData.Length()); sl@0: sl@0: test3.Printf(_L("PIPE TEST:NotifyDataThread Exit\n")); sl@0: test3.End(); sl@0: test3.Close(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: //////////////////////////////////////////////////// sl@0: //// NotifySpaceThread : sl@0: //// Function flush the pipe and makes sl@0: //// it free. sl@0: //// sl@0: //// aData --> Read Write Handle sl@0: //// sl@0: //////////////////////////////////////////////////// sl@0: sl@0: TInt NotifySpaceThread(TAny* aData) { sl@0: sl@0: sl@0: test4.Start(_L("PIPE TEST:NotifySpaceThread Entry")); sl@0: sl@0: TData& data = *(TData *)aData; // aData will have pipe handles and size. sl@0: sl@0: // User::After(10000000); sl@0: sl@0: data.rPipe->Flush(); sl@0: sl@0: test4.Printf(_L("PIPE TEST:NotifySpaceThread Exit\n")); sl@0: test4.End(); sl@0: test4.Close(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: //////////////////////////////////////////////////// sl@0: //// CancelNotifyThread : sl@0: //// Function cancels Space available request sl@0: //// or Cancels Data available request. sl@0: //// sl@0: //// CancelFlag --> 1 CancelSpaceAvailable sl@0: //// 0 for CancelDataAvailable sl@0: //// sl@0: //// aData --> Read Write Handle sl@0: //// sl@0: //////////////////////////////////////////////////// sl@0: sl@0: TInt CancelFlag; // 1 CancelSpaceAvailable ; 0 for CancelDataAvailable sl@0: TInt CancelNotifyThread(TAny* aData) { sl@0: sl@0: test5.Start(_L("PIPE TEST:CancelNotifyThread Entry")); sl@0: sl@0: TData& data = *(TData *)aData; // aData will have pipe handles and size. sl@0: sl@0: if ( CancelFlag == 1) sl@0: data.wPipe->CancelSpaceAvailable(); sl@0: else if ( CancelFlag == 0) sl@0: data.rPipe->CancelDataAvailable(); sl@0: else sl@0: test5.Printf(_L("PIPE TEST: *** Illegal Cancel\n")); sl@0: sl@0: test5.Printf(_L("PIPE TEST:CancelNotifyThread Exit\n")); sl@0: test5.End(); sl@0: test5.Close(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: //////////////////////////////////////////////////// sl@0: //// Main Thread sl@0: //// sl@0: //// sl@0: //////////////////////////////////////////////////// sl@0: /* sl@0: sl@0: sl@0: 1. Create 5 (UN)Pipes. sl@0: 2. Register NotifyData AVailable on 5 pipes. sl@0: 3. Create Thread 1 sl@0: 4. Wait for n request. sl@0: 5. In thread 1 write data into any one pipe. Exit sl@0: 6. Main should show 1 stat variable updated. sl@0: sl@0: 7. Again call Wait for n request. sl@0: 8. It shall come out as one stat is Available. sl@0: sl@0: 9. Close all the pipes. Repeat same for NotifySpace available. sl@0: sl@0: 10. Define 5 N-Pipes sl@0: 11. Open write end and call wait till read end open. sl@0: 12. Create thread 2 sl@0: 12. Wait for n request sl@0: 13. In thread 2 , open read end of one of the pipe. sl@0: 14. Main should show 1 stat variable updated. sl@0: sl@0: 15. Again call Wait for n request. sl@0: 16. It shall come out as one stat is Available. sl@0: sl@0: 17. Close all the pipes. Destroy pipes. sl@0: sl@0: 18. Create 3 N pipe and 2 UN pipes. sl@0: 19. Register 2 NDA , 2 NSA , 2 Read end wait. sl@0: 20. Create thread 3 make any request successful. sl@0: sl@0: sl@0: */ sl@0: sl@0: LOCAL_C void test_MainThread() sl@0: { sl@0: sl@0: RPipe aReader1,aWriter1; // Used to pass to thread. sl@0: RPipe aReader2,aWriter2; // Used to pass to thread. sl@0: RPipe aReader3,aWriter3; // Used to pass to thread. sl@0: RPipe aReader4,aWriter4; // Used to pass to thread. sl@0: RPipe aReader5,aWriter5; // Used to pass to thread. sl@0: sl@0: TInt ret,aSize; sl@0: RThread thread2; sl@0: RThread thread3; sl@0: RThread thread4; sl@0: RThread thread5; sl@0: sl@0: TRequestStatus stat1; sl@0: TRequestStatus stat2; sl@0: TRequestStatus stat3; sl@0: TRequestStatus stat4; sl@0: TRequestStatus stat5; sl@0: sl@0: TRequestStatus s; sl@0: sl@0: TRequestStatus *ReqArray[] = sl@0: { sl@0: &stat1,&stat2,&stat3,&stat4,&stat5 sl@0: }; sl@0: const TBufC<100> cPipeName1(KPipe1Name); sl@0: TBufC8<50> cTestData(KTestDataNum); // Test Data sl@0: sl@0: sl@0: sl@0: test.Printf(_L("PIPE TEST:Main Thread Entry\n")); sl@0: sl@0: //Test 1: sl@0: sl@0: aSize = 10; sl@0: // Create 5 Pipes. sl@0: ret = RPipe::Create( aSize, aReader1,aWriter1,EOwnerProcess, EOwnerProcess); sl@0: test_KErrNone(ret); sl@0: ret = RPipe::Create( aSize, aReader2,aWriter2,EOwnerProcess, EOwnerProcess); sl@0: test_KErrNone(ret); sl@0: ret = RPipe::Create( aSize, aReader3,aWriter3,EOwnerProcess, EOwnerProcess); sl@0: test_KErrNone(ret); sl@0: ret = RPipe::Create( aSize, aReader4,aWriter4,EOwnerProcess, EOwnerProcess); sl@0: test_KErrNone(ret); sl@0: ret = RPipe::Create( aSize, aReader5,aWriter5,EOwnerProcess, EOwnerProcess); sl@0: test_KErrNone(ret); sl@0: // Register Notification for Data Available for all 5 pipes. sl@0: aReader1.NotifyDataAvailable(stat1); sl@0: aReader2.NotifyDataAvailable(stat2); sl@0: aReader3.NotifyDataAvailable(stat3); sl@0: aReader4.NotifyDataAvailable(stat4); sl@0: aReader5.NotifyDataAvailable(stat5); sl@0: sl@0: sl@0: // Pass handles for Pipe# 3 sl@0: TData data1(&aReader3,&aWriter3,aSize); sl@0: sl@0: // Create thread for Writing data into pipe. sl@0: // This will make status variable of respective pipe as AVAILABLE sl@0: ret = thread3.Create( sl@0: KThread3Name, // Thread name sl@0: NotifyDataThread, // Function to be called sl@0: KDefaultStackSize, sl@0: KHeapSize, sl@0: KHeapSize, sl@0: (TAny *)&data1 // Data object containing Pipe information. sl@0: ); sl@0: test_KErrNone(ret); sl@0: thread3.Logon(s); sl@0: test_Equal(KRequestPending, s.Int()); sl@0: sl@0: // Start the Thread sl@0: thread3.Resume(); sl@0: sl@0: // Wait till any of the request status is Avaialble sl@0: User::WaitForNRequest(ReqArray,5); sl@0: sl@0: // As WaitForNRequest returned. This proves test pass. sl@0: test.Printf(_L("PIPE TEST:Test 1: Pass\n")); sl@0: sl@0: // Cancel all pending requests for other tests. sl@0: aReader1.CancelDataAvailable(); sl@0: aReader2.CancelDataAvailable(); sl@0: aReader3.CancelDataAvailable(); sl@0: aReader4.CancelDataAvailable(); sl@0: aReader5.CancelDataAvailable(); sl@0: sl@0: // Close thread. sl@0: User::WaitForRequest(s); sl@0: CLOSE_AND_WAIT(thread3); sl@0: sl@0: sl@0: //Test 2: sl@0: sl@0: // Pipes created in Test 1. sl@0: // Write data into all the pipes and Fill it. sl@0: aWriter1.Write(cTestData,cTestData.Length()); sl@0: aWriter2.Write(cTestData,cTestData.Length()); sl@0: aWriter3.Write(cTestData,cTestData.Length()); sl@0: aWriter4.Write(cTestData,cTestData.Length()); sl@0: aWriter5.Write(cTestData,cTestData.Length()); sl@0: sl@0: // Register notification for Space availability for all pipes. sl@0: sl@0: aWriter1.NotifySpaceAvailable(aSize,stat1); sl@0: aWriter2.NotifySpaceAvailable(aSize,stat2); sl@0: aWriter3.NotifySpaceAvailable(aSize,stat3); sl@0: aWriter4.NotifySpaceAvailable(aSize,stat4); sl@0: aWriter5.NotifySpaceAvailable(aSize,stat5); sl@0: sl@0: sl@0: // Create data object for Pipe# 5. sl@0: TData data2(&aReader5,&aWriter5,aSize); sl@0: sl@0: // Create thread which will make space available in Pipe. sl@0: // sl@0: ret = thread4.Create( sl@0: KThread4Name, // Thread name sl@0: NotifySpaceThread, // Function to be called sl@0: KDefaultStackSize, sl@0: KHeapSize, sl@0: KHeapSize, sl@0: (TAny *)&data2 // Data object containing Pipe information. sl@0: ); sl@0: test_KErrNone(ret); sl@0: thread4.Logon(s); sl@0: test_Equal(KRequestPending, s.Int()); sl@0: sl@0: // Start the thread. sl@0: thread4.Resume(); sl@0: sl@0: // Wait till any of the status variable status change to Avaialble sl@0: User::WaitForNRequest(ReqArray,5); sl@0: sl@0: test.Printf(_L("PIPE TEST:Test 2: Pass\n")); sl@0: sl@0: // Cancel all pending requests. sl@0: aWriter1.CancelSpaceAvailable(); sl@0: aWriter2.CancelSpaceAvailable(); sl@0: aWriter3.CancelSpaceAvailable(); sl@0: aWriter4.CancelSpaceAvailable(); sl@0: aWriter5.CancelSpaceAvailable(); sl@0: sl@0: // Close the thread. sl@0: User::WaitForRequest(s); sl@0: CLOSE_AND_WAIT(thread4); sl@0: sl@0: //Test 3: sl@0: // Flush all the Pipes. sl@0: // This is needed for NotifyDataAvailable request. sl@0: aReader1.Flush(); sl@0: aReader2.Flush(); sl@0: aReader3.Flush(); sl@0: aReader4.Flush(); sl@0: aReader5.Flush(); sl@0: sl@0: // Register NotifyDataAvailable request for all the pipes. sl@0: sl@0: CancelFlag = 0; // 0 = CanceldataAvailable() sl@0: aReader1.NotifyDataAvailable(stat1); sl@0: aReader2.NotifyDataAvailable(stat2); sl@0: aReader3.NotifyDataAvailable(stat3); sl@0: aReader4.NotifyDataAvailable(stat4); sl@0: aReader5.NotifyDataAvailable(stat5); sl@0: sl@0: TData data3(&aReader2,&aWriter2,aSize); sl@0: sl@0: ret = thread5.Create( sl@0: KThread5Name, // Thread name sl@0: CancelNotifyThread, // Function to be called sl@0: KDefaultStackSize, sl@0: KHeapSize, sl@0: KHeapSize, sl@0: (TAny *)&data3 // Data object containing Pipe information. sl@0: ); sl@0: test_KErrNone(ret); sl@0: thread5.Logon(s); sl@0: test_Equal(KRequestPending, s.Int()); sl@0: thread5.Resume(); sl@0: sl@0: User::WaitForNRequest(ReqArray,5); sl@0: sl@0: test.Printf(_L("PIPE TEST:Test 3: Pass\n")); sl@0: aReader1.CancelDataAvailable(); sl@0: aReader2.CancelDataAvailable(); sl@0: aReader3.CancelDataAvailable(); sl@0: aReader4.CancelDataAvailable(); sl@0: aReader5.CancelDataAvailable(); sl@0: User::WaitForRequest(s); sl@0: CLOSE_AND_WAIT(thread5); sl@0: sl@0: sl@0: //Test 4: sl@0: aReader1.Close(); sl@0: aWriter1.Close(); sl@0: aReader2.Close(); sl@0: aWriter2.Close(); sl@0: aReader3.Close(); sl@0: aWriter3.Close(); sl@0: aReader4.Close(); sl@0: aWriter4.Close(); sl@0: aReader5.Close(); sl@0: aWriter5.Close(); sl@0: sl@0: ret = RPipe::Define(KPipe1Name,aSize); sl@0: test_KErrNone(ret); sl@0: ret = RPipe::Define(KPipe2Name,aSize); sl@0: test_KErrNone(ret); sl@0: ret = RPipe::Define(KPipe3Name,aSize); sl@0: test_KErrNone(ret); sl@0: ret = RPipe::Define(KPipe4Name,aSize); sl@0: test_KErrNone(ret); sl@0: ret = RPipe::Define(KPipe5Name,aSize); sl@0: test_KErrNone(ret); sl@0: sl@0: aWriter1.Open(KPipe1Name,RPipe::EOpenToWrite); sl@0: aWriter2.Open(KPipe2Name,RPipe::EOpenToWrite); sl@0: aWriter3.Open(KPipe3Name,RPipe::EOpenToWrite); sl@0: aWriter4.Open(KPipe4Name,RPipe::EOpenToWrite); sl@0: aWriter5.Open(KPipe5Name,RPipe::EOpenToWrite); sl@0: sl@0: aWriter1.Wait(KPipe1Name,stat1); sl@0: aWriter2.Wait(KPipe2Name,stat2); sl@0: aWriter3.Wait(KPipe3Name,stat3); sl@0: aWriter4.Wait(KPipe4Name,stat4); sl@0: aWriter5.Wait(KPipe5Name,stat5); sl@0: sl@0: const TBufC<100> cPipeName2(KPipe2Name); sl@0: sl@0: TData data4(&aReader2,&aWriter2,aSize); sl@0: cPipeName = cPipeName2; sl@0: sl@0: ret = thread2.Create( sl@0: KThread2Name, // Thread name sl@0: WaitThread, // Function to be called sl@0: KDefaultStackSize, sl@0: KHeapSize, sl@0: KHeapSize, sl@0: (TAny *)&data4 // Data object containing Pipe information. sl@0: ); sl@0: test_KErrNone(ret); sl@0: thread2.Logon(s); sl@0: test_Equal(KRequestPending, s.Int()); sl@0: thread2.Resume(); sl@0: User::WaitForNRequest(ReqArray,5); sl@0: test.Printf(_L("PIPE TEST:Test 4: Pass\n")); sl@0: aWriter1.CancelWait(); sl@0: aWriter2.CancelWait(); sl@0: aWriter3.CancelWait(); sl@0: aWriter4.CancelWait(); sl@0: aWriter5.CancelWait(); sl@0: sl@0: aReader1.Close(); aWriter1.Close(); sl@0: aReader2.Close(); aWriter2.Close(); sl@0: aReader3.Close(); aWriter3.Close(); sl@0: aReader4.Close(); aWriter4.Close(); sl@0: aReader5.Close(); aWriter5.Close(); sl@0: sl@0: User::WaitForRequest(s); sl@0: CLOSE_AND_WAIT(thread2); sl@0: sl@0: //Test 5: sl@0: sl@0: ret =aWriter1.Open(KPipe1Name,RPipe::EOpenToWrite); sl@0: test_KErrNone(ret); sl@0: aReader1.Close(); sl@0: //ret =aWriter1.Wait(KPipe1Name,stat1); sl@0: aWriter1.Wait(KPipe1Name,stat1); sl@0: sl@0: ret =aWriter2.Open(KPipe2Name,RPipe::EOpenToWrite); sl@0: test_KErrNone(ret); sl@0: ret =aReader2.Open(KPipe2Name,RPipe::EOpenToRead); sl@0: test_KErrNone(ret); sl@0: ret =aWriter2.Write(cTestData,cTestData.Length()); sl@0: //ret =aWriter2.NotifySpaceAvailable(aSize,stat2); sl@0: aWriter2.NotifySpaceAvailable(aSize,stat2); sl@0: sl@0: ret = RPipe::Create( aSize, aReader3,aWriter3,EOwnerProcess, EOwnerProcess); sl@0: test_KErrNone(ret); sl@0: aReader3.Flush(); sl@0: //ret =aReader3.NotifyDataAvailable(stat3); sl@0: aReader3.NotifyDataAvailable(stat3); sl@0: sl@0: ret = RPipe::Create( aSize, aReader4,aWriter4,EOwnerProcess, EOwnerProcess); sl@0: test_KErrNone(ret); sl@0: ret =aWriter4.Write(cTestData,cTestData.Length()); sl@0: //ret =aWriter4.NotifySpaceAvailable(aSize,stat4); sl@0: aWriter4.NotifySpaceAvailable(aSize,stat4); sl@0: sl@0: ret = RPipe::Create( aSize, aReader5,aWriter5,EOwnerProcess, EOwnerProcess); sl@0: test_KErrNone(ret); sl@0: aReader5.Flush(); sl@0: //ret =aReader5.NotifyDataAvailable(stat5); sl@0: aReader5.NotifyDataAvailable(stat5); sl@0: sl@0: TData data5(&aReader3,&aWriter3,aSize); sl@0: cPipeName = cPipeName2; sl@0: sl@0: RThread thread6; sl@0: sl@0: ret = thread6.Create( sl@0: KThread3Name, // Thread name sl@0: NotifyDataThread, // Function to be called sl@0: KDefaultStackSize, sl@0: KHeapSize, sl@0: KHeapSize, sl@0: (TAny *)&data5 // Data object containing Pipe information. sl@0: ); sl@0: test_KErrNone(ret); sl@0: thread6.Logon(s); sl@0: test_Equal(KRequestPending, s.Int()); sl@0: thread6.Resume(); sl@0: User::WaitForNRequest(ReqArray,5); sl@0: test.Printf(_L("PIPE TEST:Test 5: Pass\n")); sl@0: sl@0: User::WaitForRequest(s); sl@0: CLOSE_AND_WAIT(thread6); sl@0: //Test 6: sl@0: sl@0: TData data6(&aReader2,&aWriter2,aSize); sl@0: cPipeName = cPipeName2; sl@0: sl@0: RThread thread7; sl@0: sl@0: ret = thread7.Create( sl@0: KThread3Name, // Thread name sl@0: NotifySpaceThread, // Function to be called sl@0: KDefaultStackSize, sl@0: KHeapSize, sl@0: KHeapSize, sl@0: (TAny *)&data6 // Data object containing Pipe information. sl@0: ); sl@0: test_KErrNone(ret); sl@0: thread7.Logon(s); sl@0: test_Equal(KRequestPending, s.Int()); sl@0: thread7.Resume(); sl@0: sl@0: User::WaitForNRequest(ReqArray,5); sl@0: test.Printf(_L("PIPE TEST:Test 6: Pass\n")); sl@0: sl@0: sl@0: User::WaitForRequest(s); sl@0: CLOSE_AND_WAIT(thread7); sl@0: sl@0: //Test 7: sl@0: TData data7(&aReader1,&aWriter1,aSize); sl@0: cPipeName = cPipeName1; sl@0: sl@0: RThread thread8; sl@0: sl@0: ret = thread8.Create( sl@0: KThread2Name, // Thread name sl@0: WaitThread, // Function to be called sl@0: KDefaultStackSize, sl@0: KHeapSize, sl@0: KHeapSize, sl@0: (TAny *)&data7 // Data object containing Pipe information. sl@0: ); sl@0: test_KErrNone(ret); sl@0: thread8.Logon(s); sl@0: test_Equal(KRequestPending, s.Int()); sl@0: thread8.Resume(); sl@0: sl@0: User::WaitForNRequest(ReqArray,5); sl@0: test.Printf(_L("PIPE TEST:Test 7: Pass\n")); sl@0: sl@0: sl@0: User::WaitForRequest(s); sl@0: // CLOSE_AND_WAIT(thread8); DOESN'T WORK SINCE PIPE DRIVER KEEPS THE THREAD OPEN sl@0: thread8.Close(); sl@0: sl@0: //Test 8: sl@0: TData data8(&aReader4,&aWriter4,aSize); sl@0: sl@0: RThread thread9; sl@0: sl@0: CancelFlag = 1; // 1 = CancelSpaceAvailable() sl@0: sl@0: ret = thread9.Create( sl@0: KThread4Name, // Thread name sl@0: CancelNotifyThread, // Function to be called sl@0: KDefaultStackSize, sl@0: KHeapSize, sl@0: KHeapSize, sl@0: (TAny *)&data8 // Data object containing Pipe information. sl@0: ); sl@0: test_KErrNone(ret); sl@0: thread9.Logon(s); sl@0: test_Equal(KRequestPending, s.Int()); sl@0: thread9.Resume(); sl@0: sl@0: User::WaitForNRequest(ReqArray,5); sl@0: test.Printf(_L("PIPE TEST:Test 8: Pass\n")); sl@0: sl@0: User::WaitForRequest(s); sl@0: CLOSE_AND_WAIT(thread9); sl@0: sl@0: //Test 9: sl@0: TData data9(&aReader5,&aWriter5,aSize); sl@0: sl@0: RThread thread10; sl@0: sl@0: CancelFlag = 0; // 0 = CancelDataAvailable() sl@0: sl@0: ret = thread10.Create( sl@0: KThread5Name, // Thread name sl@0: CancelNotifyThread, // Function to be called sl@0: KDefaultStackSize, sl@0: KHeapSize, sl@0: KHeapSize, sl@0: (TAny *)&data9 // Data object containing Pipe information. sl@0: ); sl@0: test_KErrNone(ret); sl@0: thread10.Logon(s); sl@0: test_Equal(KRequestPending, s.Int()); sl@0: thread10.Resume(); sl@0: sl@0: sl@0: User::WaitForNRequest(ReqArray,5); sl@0: test.Printf(_L("PIPE TEST:Test 9: Pass\n")); sl@0: sl@0: User::WaitForRequest(s); sl@0: CLOSE_AND_WAIT(thread10); sl@0: sl@0: sl@0: aReader1.Close(); aWriter1.Close(); sl@0: aReader2.Close(); aWriter2.Close(); sl@0: aReader3.Close(); aWriter3.Close(); sl@0: aReader4.Close(); aWriter4.Close(); sl@0: aReader5.Close(); aWriter5.Close(); sl@0: ret = RPipe::Destroy(KPipe1Name); sl@0: test_KErrNone(ret); sl@0: ret = RPipe::Destroy(KPipe2Name); sl@0: test_KErrNone(ret); sl@0: ret = RPipe::Destroy(KPipe3Name); sl@0: test_KErrNone(ret); sl@0: ret = RPipe::Destroy(KPipe4Name); sl@0: test_KErrNone(ret); sl@0: ret = RPipe::Destroy(KPipe5Name); sl@0: test_KErrNone(ret); sl@0: sl@0: sl@0: test.Printf(_L("PIPE TEST:Main Thread Exit\n")); sl@0: return; sl@0: sl@0: sl@0: sl@0: } sl@0: sl@0: //////////////////////////////////////////////////// sl@0: //// RunTests: sl@0: //// sl@0: //// sl@0: //////////////////////////////////////////////////// sl@0: LOCAL_C void RunTests(void) sl@0: { sl@0: sl@0: test.Start(_L("PIPE TEST: Testing WaitForNRequest")); sl@0: sl@0: test_MainThread(); sl@0: sl@0: test.Printf(_L("PIPE TEST: Ending test.\n")); sl@0: sl@0: test.End(); sl@0: test.Close(); sl@0: return; sl@0: } sl@0: sl@0: sl@0: //////////////////////////////////////////////////// sl@0: //// E32Main : Main entry point to test. sl@0: //// sl@0: //// sl@0: //////////////////////////////////////////////////// sl@0: sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: sl@0: { sl@0: TInt ret = 0; sl@0: sl@0: ret = RPipe::Init(); sl@0: sl@0: if (ret != KErrNone && ret != KErrAlreadyExists) sl@0: { sl@0: test.Printf(_L(" t_pipe4.exe PIPE TEST: Error loading driver %d\n"),ret); sl@0: test.Printf(_L(" Exiting t_pipe4.exe\n")); sl@0: sl@0: return KErrNone; sl@0: sl@0: } sl@0: RunTests(); sl@0: sl@0: TName pddName1(RPipe::Name()); sl@0: sl@0: ret= User::FreeLogicalDevice(pddName1); sl@0: sl@0: return KErrNone; sl@0: sl@0: }