os/kernelhwsrv/kerneltest/e32test/pipe/t_pipe5.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/pipe/t_pipe5.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,186 @@
     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_pipe5.cpp
    1.18 +// This process has ReadDeviceData capability
    1.19 +// This is supporting program for testing pipes.
    1.20 +// This is used by main test file ( t_pipe.cpp) for testing
    1.21 +// pipes in multiprocess environment.
    1.22 +// 
    1.23 +//
    1.24 +
    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_pipe5"));
    1.31 +
    1.32 +_LIT(KPipeName2, "PipeWithNoCap");
    1.33 +_LIT(KPipeName4, "PipeWithRWCap");
    1.34 +_LIT(KPipeName5, "PipeWithComDDCap");
    1.35 +_LIT(KPipeName6, "PipeWithRWComDDCap");
    1.36 +_LIT(KPipeName7, "PipeWithRWComDDCapVID");
    1.37 +_LIT(KPipeName8, "PipeWithRWRUCap");
    1.38 +
    1.39 +
    1.40 +
    1.41 +
    1.42 +LOCAL_C void RunTests(void)
    1.43 +	{
    1.44 +	
    1.45 +	test.Start(_L("Testing In Pipe Process 5 : Process with ReadDeviceData Capabilities"));
    1.46 +	RPipe					aReader, aWriter;
    1.47 +		
    1.48 +	TInt		ret,aSize;
    1.49 +	
    1.50 +/////Part 1		
    1.51 +	test.Next(_L("PIPE TEST: PipeProcess 5-1\n"));
    1.52 +	ret = aReader.Open(KPipeName2,RPipe::EOpenToRead);
    1.53 +	test ( ret == KErrNone);
    1.54 +	
    1.55 +	test.Next(_L("PIPE TEST: PipeProcess 5-2\n"));				 
    1.56 +	ret = aWriter.Open(KPipeName2,RPipe::EOpenToWrite);
    1.57 +	test ( ret == KErrNone);
    1.58 +	
    1.59 +	aReader.Close();
    1.60 +	aWriter.Close();
    1.61 +	
    1.62 +	test.Next(_L("PIPE TEST: PipeProcess 5-3\n"));				 
    1.63 +	ret = aReader.Open(KPipeName2,RPipe::EOpenToRead);
    1.64 +	test ( ret == KErrNone);
    1.65 +	ret = aWriter.Open(KPipeName2,RPipe::EOpenToWriteNamedPipeButFailOnNoReaders);
    1.66 +	test ( ret == KErrNone);
    1.67 +	
    1.68 +	aReader.Close();
    1.69 +	aWriter.Close();
    1.70 +	
    1.71 +	test.Next(_L("PIPE TEST: PipeProcess 5-4\n"));				 
    1.72 +	ret = RPipe::Destroy (KPipeName2);
    1.73 +	test ( ret == KErrNone);
    1.74 +
    1.75 +
    1.76 +/////Part 2
    1.77 +	test.Next(_L("PIPE TEST: PipeProcess 5-5\n"));
    1.78 +	ret = aReader.Open(KPipeName4,RPipe::EOpenToRead);
    1.79 +	test ( ret == KErrNone);
    1.80 +	
    1.81 +	test.Next(_L("PIPE TEST: PipeProcess 5-6\n"));				 
    1.82 +	ret = aWriter.Open(KPipeName4,RPipe::EOpenToWrite);
    1.83 +	test ( ret == KErrNone);
    1.84 +	
    1.85 +	aReader.Close();
    1.86 +	aWriter.Close();
    1.87 +		
    1.88 +	test.Next(_L("PIPE TEST: PipeProcess 5-7\n"));				 
    1.89 +	ret = RPipe::Destroy (KPipeName4);
    1.90 +	test ( ret == KErrNone);
    1.91 +	
    1.92 +/////Part 3
    1.93 +
    1.94 +	test.Next(_L("PIPE TEST: PipeProcess 5-8\n"));
    1.95 +	ret = aReader.Open(KPipeName5,RPipe::EOpenToRead);
    1.96 +	test ( ret == KErrNone);
    1.97 +	
    1.98 +	test.Next(_L("PIPE TEST: PipeProcess 5-9\n"));				 
    1.99 +	ret = aWriter.Open(KPipeName5,RPipe::EOpenToWrite);
   1.100 +	test ( ret == KErrNone);
   1.101 +	
   1.102 +	aReader.Close();
   1.103 +	aWriter.Close();
   1.104 +		
   1.105 +	test.Next(_L("PIPE TEST: PipeProcess 5-10\n"));				 
   1.106 +	ret = RPipe::Destroy (KPipeName5);
   1.107 +	test ( ret == KErrNone);
   1.108 +	
   1.109 +/////Part 4
   1.110 +
   1.111 +	test.Next(_L("PIPE TEST: PipeProcess 5-11\n"));
   1.112 +	ret = aReader.Open(KPipeName6,RPipe::EOpenToRead);
   1.113 +	test ( ret == KErrNone);
   1.114 +	
   1.115 +	test.Next(_L("PIPE TEST: PipeProcess 5-12\n"));				 
   1.116 +	ret = aWriter.Open(KPipeName6,RPipe::EOpenToWrite);
   1.117 +	test ( ret == KErrNone);
   1.118 +	
   1.119 +	aReader.Close();
   1.120 +	aWriter.Close();
   1.121 +		
   1.122 +	test.Next(_L("PIPE TEST: PipeProcess 5-13\n"));				 
   1.123 +	ret = RPipe::Destroy (KPipeName6);
   1.124 +	test ( ret == KErrNone);
   1.125 +	
   1.126 +/////Part 5
   1.127 +
   1.128 +	test.Next(_L("PIPE TEST: PipeProcess 5-14\n"));
   1.129 +	ret = aReader.Open(KPipeName7,RPipe::EOpenToRead);
   1.130 +	test ( ret == KErrPermissionDenied);
   1.131 +	
   1.132 +	test.Next(_L("PIPE TEST: PipeProcess 5-15\n"));				 
   1.133 +	ret = aWriter.Open(KPipeName7,RPipe::EOpenToWrite);
   1.134 +	test ( ret == KErrPermissionDenied);
   1.135 +	
   1.136 +	aReader.Close();
   1.137 +	aWriter.Close();
   1.138 +		
   1.139 +	test.Next(_L("PIPE TEST: PipeProcess 5-16\n"));				 
   1.140 +	ret = RPipe::Destroy (KPipeName7);
   1.141 +	test ( ret == KErrPermissionDenied);
   1.142 +
   1.143 +/////Part 6
   1.144 +
   1.145 +	test.Next(_L("PIPE TEST: PipeProcess 5-17\n"));
   1.146 +	ret = aReader.Open(KPipeName8,RPipe::EOpenToRead);
   1.147 +	test ( ret == KErrPermissionDenied);
   1.148 +	
   1.149 +	test.Next(_L("PIPE TEST: PipeProcess 5-18\n"));				 
   1.150 +	ret = aWriter.Open(KPipeName8,RPipe::EOpenToWrite);
   1.151 +	test ( ret == KErrPermissionDenied);
   1.152 +	
   1.153 +	aReader.Close();
   1.154 +	aWriter.Close();
   1.155 +		
   1.156 +	test.Next(_L("PIPE TEST: PipeProcess 5-19\n"));				 
   1.157 +	ret = RPipe::Destroy (KPipeName8);
   1.158 +	test ( ret == KErrPermissionDenied);
   1.159 +	
   1.160 +/////Part 7	
   1.161 +	aSize = 10;
   1.162 +	ret = RPipe::Create(	aSize,
   1.163 +							aReader, 
   1.164 +							aWriter,
   1.165 +							EOwnerProcess,//TOwnerType aTypeW
   1.166 +							EOwnerProcess//TOwnerType aTypeW
   1.167 +						);
   1.168 +	
   1.169 +	test.Next(_L("PIPE TEST: PipeProcess 5-20\n"));				 
   1.170 +	test ( ret == KErrNone);
   1.171 +	aReader.Close();
   1.172 +	aWriter.Close();
   1.173 +	
   1.174 +	test.End();		
   1.175 +	test.Close();
   1.176 +	
   1.177 +	return;
   1.178 +}
   1.179 +
   1.180 +GLDEF_C TInt E32Main()
   1.181 +{
   1.182 +
   1.183 +	test.Title();
   1.184 +
   1.185 +	RunTests();
   1.186 +
   1.187 +	return KErrNone;
   1.188 +}
   1.189 +