os/kernelhwsrv/kerneltest/e32test/pipe/t_pipe2.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // e32test\pipe\t_pipe2.cpp
    15 // This is supporting program for testing pipes.
    16 // This is used by main test file ( t_pipe.cpp) for testing
    17 // pipes in multiprocess environment.
    18 // 
    19 //
    20 
    21 #define __E32TEST_EXTENSION__
    22 #include <e32test.h>
    23 #include <e32svr.h>
    24 #include <rpipe.h>
    25 
    26 
    27 LOCAL_D RTest test(_L("t_pipe2"));
    28 _LIT(KPipeName5, "InterProcessPipe1");
    29 
    30 
    31 _LIT8(KTestDataIP, "ABCDEFGHIJ");
    32 _LIT8(KTestData,"Pipe Data To Be Passed");
    33 
    34 LOCAL_C void RunTests(void)
    35 	{
    36 	test.Start(_L("Testing In Pipe Process 2"));
    37 
    38 	TInt 				ret;									// Return value variable
    39 
    40 	RPipe 				aReader;
    41 	RPipe 				aReaderUN;
    42 	const	TBufC<50>	cPipeName1(KPipeName5);
    43 	
    44 	TBuf8<150>			cPipeReadData1;
    45 	TInt				aSize;
    46 	TRequestStatus		stat1;
    47 	
    48 	test.Next(_L("PIPE TEST: PipeProcess 2-1: Open Read Handle to unamed Pipe\n"));
    49 	ret=aReaderUN.Open(3,EOwnerProcess);
    50 	test_KErrNone(ret);
    51 
    52 	test.Next(_L("PIPE TEST: PipeProcess 2-1.1: Get the UnNamed pipe read handle from another process \n"));
    53 	ret = aReaderUN.Size();
    54 	test (ret = 22);
    55 	
    56 	ret = aReaderUN.MaxSize();
    57 	test (ret = 512);
    58 	
    59 	ret = aReaderUN.Read(cPipeReadData1,22);
    60 	test (ret == 22);
    61 	
    62 	ret = 	cPipeReadData1.Compare(KTestData);
    63 	test (ret == KErrNone);
    64 
    65 	aReaderUN.Close();
    66 	
    67 
    68 	test.Next(_L("Open handle to named pipe\n"));
    69 
    70 	aSize =10;
    71 	ret = aReader.Open(cPipeName1, RPipe::EOpenToRead);
    72 	test_KErrNone(ret);	
    73 
    74 	test.Next(_L("PIPE TEST: PipeProcess 2-2: Wait till NotifyDataAvailable.\n"));
    75 
    76 	aReader.NotifyDataAvailable(stat1);
    77 
    78 	User::WaitForRequest(stat1);
    79 
    80 	test.Next(_L("PIPE TEST: PipeProcess 2-3: Call ReadBlocking and Read the data.\n"));
    81 
    82 	aReader.Flush(); 
    83 	ret = aReader.ReadBlocking(cPipeReadData1,aSize);
    84 	test_Equal(aSize, ret);
    85 	ret = cPipeReadData1.Compare(KTestDataIP);
    86 	test( ret== KErrNone);
    87 		
    88 	test.Next(_L("PIPE TEST: PipeProcess 2-4: Exit Process t_pipe2.\n"));
    89 	aReader.Close();
    90 	test.End();
    91 	test.Close();
    92 }
    93 
    94 GLDEF_C TInt E32Main()
    95 //
    96 //
    97     {
    98 
    99 	test.Title();
   100 
   101 	RunTests();
   102 
   103 	return KErrNone;
   104     }
   105