1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/pipe/t_pipe2.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,105 @@
1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\pipe\t_pipe2.cpp
1.18 +// This is supporting program for testing pipes.
1.19 +// This is used by main test file ( t_pipe.cpp) for testing
1.20 +// pipes in multiprocess environment.
1.21 +//
1.22 +//
1.23 +
1.24 +#define __E32TEST_EXTENSION__
1.25 +#include <e32test.h>
1.26 +#include <e32svr.h>
1.27 +#include <rpipe.h>
1.28 +
1.29 +
1.30 +LOCAL_D RTest test(_L("t_pipe2"));
1.31 +_LIT(KPipeName5, "InterProcessPipe1");
1.32 +
1.33 +
1.34 +_LIT8(KTestDataIP, "ABCDEFGHIJ");
1.35 +_LIT8(KTestData,"Pipe Data To Be Passed");
1.36 +
1.37 +LOCAL_C void RunTests(void)
1.38 + {
1.39 + test.Start(_L("Testing In Pipe Process 2"));
1.40 +
1.41 + TInt ret; // Return value variable
1.42 +
1.43 + RPipe aReader;
1.44 + RPipe aReaderUN;
1.45 + const TBufC<50> cPipeName1(KPipeName5);
1.46 +
1.47 + TBuf8<150> cPipeReadData1;
1.48 + TInt aSize;
1.49 + TRequestStatus stat1;
1.50 +
1.51 + test.Next(_L("PIPE TEST: PipeProcess 2-1: Open Read Handle to unamed Pipe\n"));
1.52 + ret=aReaderUN.Open(3,EOwnerProcess);
1.53 + test_KErrNone(ret);
1.54 +
1.55 + test.Next(_L("PIPE TEST: PipeProcess 2-1.1: Get the UnNamed pipe read handle from another process \n"));
1.56 + ret = aReaderUN.Size();
1.57 + test (ret = 22);
1.58 +
1.59 + ret = aReaderUN.MaxSize();
1.60 + test (ret = 512);
1.61 +
1.62 + ret = aReaderUN.Read(cPipeReadData1,22);
1.63 + test (ret == 22);
1.64 +
1.65 + ret = cPipeReadData1.Compare(KTestData);
1.66 + test (ret == KErrNone);
1.67 +
1.68 + aReaderUN.Close();
1.69 +
1.70 +
1.71 + test.Next(_L("Open handle to named pipe\n"));
1.72 +
1.73 + aSize =10;
1.74 + ret = aReader.Open(cPipeName1, RPipe::EOpenToRead);
1.75 + test_KErrNone(ret);
1.76 +
1.77 + test.Next(_L("PIPE TEST: PipeProcess 2-2: Wait till NotifyDataAvailable.\n"));
1.78 +
1.79 + aReader.NotifyDataAvailable(stat1);
1.80 +
1.81 + User::WaitForRequest(stat1);
1.82 +
1.83 + test.Next(_L("PIPE TEST: PipeProcess 2-3: Call ReadBlocking and Read the data.\n"));
1.84 +
1.85 + aReader.Flush();
1.86 + ret = aReader.ReadBlocking(cPipeReadData1,aSize);
1.87 + test_Equal(aSize, ret);
1.88 + ret = cPipeReadData1.Compare(KTestDataIP);
1.89 + test( ret== KErrNone);
1.90 +
1.91 + test.Next(_L("PIPE TEST: PipeProcess 2-4: Exit Process t_pipe2.\n"));
1.92 + aReader.Close();
1.93 + test.End();
1.94 + test.Close();
1.95 +}
1.96 +
1.97 +GLDEF_C TInt E32Main()
1.98 +//
1.99 +//
1.100 + {
1.101 +
1.102 + test.Title();
1.103 +
1.104 + RunTests();
1.105 +
1.106 + return KErrNone;
1.107 + }
1.108 +