os/kernelhwsrv/kerneltest/e32test/pipe/t_pipe5.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32test\pipe\t_pipe5.cpp
sl@0
    15
// This process has ReadDeviceData capability
sl@0
    16
// This is supporting program for testing pipes.
sl@0
    17
// This is used by main test file ( t_pipe.cpp) for testing
sl@0
    18
// pipes in multiprocess environment.
sl@0
    19
// 
sl@0
    20
//
sl@0
    21
sl@0
    22
#include <e32test.h>
sl@0
    23
#include <e32svr.h>
sl@0
    24
#include "rpipe.h"
sl@0
    25
sl@0
    26
sl@0
    27
LOCAL_D RTest test(_L("t_pipe5"));
sl@0
    28
sl@0
    29
_LIT(KPipeName2, "PipeWithNoCap");
sl@0
    30
_LIT(KPipeName4, "PipeWithRWCap");
sl@0
    31
_LIT(KPipeName5, "PipeWithComDDCap");
sl@0
    32
_LIT(KPipeName6, "PipeWithRWComDDCap");
sl@0
    33
_LIT(KPipeName7, "PipeWithRWComDDCapVID");
sl@0
    34
_LIT(KPipeName8, "PipeWithRWRUCap");
sl@0
    35
sl@0
    36
sl@0
    37
sl@0
    38
sl@0
    39
LOCAL_C void RunTests(void)
sl@0
    40
	{
sl@0
    41
	
sl@0
    42
	test.Start(_L("Testing In Pipe Process 5 : Process with ReadDeviceData Capabilities"));
sl@0
    43
	RPipe					aReader, aWriter;
sl@0
    44
		
sl@0
    45
	TInt		ret,aSize;
sl@0
    46
	
sl@0
    47
/////Part 1		
sl@0
    48
	test.Next(_L("PIPE TEST: PipeProcess 5-1\n"));
sl@0
    49
	ret = aReader.Open(KPipeName2,RPipe::EOpenToRead);
sl@0
    50
	test ( ret == KErrNone);
sl@0
    51
	
sl@0
    52
	test.Next(_L("PIPE TEST: PipeProcess 5-2\n"));				 
sl@0
    53
	ret = aWriter.Open(KPipeName2,RPipe::EOpenToWrite);
sl@0
    54
	test ( ret == KErrNone);
sl@0
    55
	
sl@0
    56
	aReader.Close();
sl@0
    57
	aWriter.Close();
sl@0
    58
	
sl@0
    59
	test.Next(_L("PIPE TEST: PipeProcess 5-3\n"));				 
sl@0
    60
	ret = aReader.Open(KPipeName2,RPipe::EOpenToRead);
sl@0
    61
	test ( ret == KErrNone);
sl@0
    62
	ret = aWriter.Open(KPipeName2,RPipe::EOpenToWriteNamedPipeButFailOnNoReaders);
sl@0
    63
	test ( ret == KErrNone);
sl@0
    64
	
sl@0
    65
	aReader.Close();
sl@0
    66
	aWriter.Close();
sl@0
    67
	
sl@0
    68
	test.Next(_L("PIPE TEST: PipeProcess 5-4\n"));				 
sl@0
    69
	ret = RPipe::Destroy (KPipeName2);
sl@0
    70
	test ( ret == KErrNone);
sl@0
    71
sl@0
    72
sl@0
    73
/////Part 2
sl@0
    74
	test.Next(_L("PIPE TEST: PipeProcess 5-5\n"));
sl@0
    75
	ret = aReader.Open(KPipeName4,RPipe::EOpenToRead);
sl@0
    76
	test ( ret == KErrNone);
sl@0
    77
	
sl@0
    78
	test.Next(_L("PIPE TEST: PipeProcess 5-6\n"));				 
sl@0
    79
	ret = aWriter.Open(KPipeName4,RPipe::EOpenToWrite);
sl@0
    80
	test ( ret == KErrNone);
sl@0
    81
	
sl@0
    82
	aReader.Close();
sl@0
    83
	aWriter.Close();
sl@0
    84
		
sl@0
    85
	test.Next(_L("PIPE TEST: PipeProcess 5-7\n"));				 
sl@0
    86
	ret = RPipe::Destroy (KPipeName4);
sl@0
    87
	test ( ret == KErrNone);
sl@0
    88
	
sl@0
    89
/////Part 3
sl@0
    90
sl@0
    91
	test.Next(_L("PIPE TEST: PipeProcess 5-8\n"));
sl@0
    92
	ret = aReader.Open(KPipeName5,RPipe::EOpenToRead);
sl@0
    93
	test ( ret == KErrNone);
sl@0
    94
	
sl@0
    95
	test.Next(_L("PIPE TEST: PipeProcess 5-9\n"));				 
sl@0
    96
	ret = aWriter.Open(KPipeName5,RPipe::EOpenToWrite);
sl@0
    97
	test ( ret == KErrNone);
sl@0
    98
	
sl@0
    99
	aReader.Close();
sl@0
   100
	aWriter.Close();
sl@0
   101
		
sl@0
   102
	test.Next(_L("PIPE TEST: PipeProcess 5-10\n"));				 
sl@0
   103
	ret = RPipe::Destroy (KPipeName5);
sl@0
   104
	test ( ret == KErrNone);
sl@0
   105
	
sl@0
   106
/////Part 4
sl@0
   107
sl@0
   108
	test.Next(_L("PIPE TEST: PipeProcess 5-11\n"));
sl@0
   109
	ret = aReader.Open(KPipeName6,RPipe::EOpenToRead);
sl@0
   110
	test ( ret == KErrNone);
sl@0
   111
	
sl@0
   112
	test.Next(_L("PIPE TEST: PipeProcess 5-12\n"));				 
sl@0
   113
	ret = aWriter.Open(KPipeName6,RPipe::EOpenToWrite);
sl@0
   114
	test ( ret == KErrNone);
sl@0
   115
	
sl@0
   116
	aReader.Close();
sl@0
   117
	aWriter.Close();
sl@0
   118
		
sl@0
   119
	test.Next(_L("PIPE TEST: PipeProcess 5-13\n"));				 
sl@0
   120
	ret = RPipe::Destroy (KPipeName6);
sl@0
   121
	test ( ret == KErrNone);
sl@0
   122
	
sl@0
   123
/////Part 5
sl@0
   124
sl@0
   125
	test.Next(_L("PIPE TEST: PipeProcess 5-14\n"));
sl@0
   126
	ret = aReader.Open(KPipeName7,RPipe::EOpenToRead);
sl@0
   127
	test ( ret == KErrPermissionDenied);
sl@0
   128
	
sl@0
   129
	test.Next(_L("PIPE TEST: PipeProcess 5-15\n"));				 
sl@0
   130
	ret = aWriter.Open(KPipeName7,RPipe::EOpenToWrite);
sl@0
   131
	test ( ret == KErrPermissionDenied);
sl@0
   132
	
sl@0
   133
	aReader.Close();
sl@0
   134
	aWriter.Close();
sl@0
   135
		
sl@0
   136
	test.Next(_L("PIPE TEST: PipeProcess 5-16\n"));				 
sl@0
   137
	ret = RPipe::Destroy (KPipeName7);
sl@0
   138
	test ( ret == KErrPermissionDenied);
sl@0
   139
sl@0
   140
/////Part 6
sl@0
   141
sl@0
   142
	test.Next(_L("PIPE TEST: PipeProcess 5-17\n"));
sl@0
   143
	ret = aReader.Open(KPipeName8,RPipe::EOpenToRead);
sl@0
   144
	test ( ret == KErrPermissionDenied);
sl@0
   145
	
sl@0
   146
	test.Next(_L("PIPE TEST: PipeProcess 5-18\n"));				 
sl@0
   147
	ret = aWriter.Open(KPipeName8,RPipe::EOpenToWrite);
sl@0
   148
	test ( ret == KErrPermissionDenied);
sl@0
   149
	
sl@0
   150
	aReader.Close();
sl@0
   151
	aWriter.Close();
sl@0
   152
		
sl@0
   153
	test.Next(_L("PIPE TEST: PipeProcess 5-19\n"));				 
sl@0
   154
	ret = RPipe::Destroy (KPipeName8);
sl@0
   155
	test ( ret == KErrPermissionDenied);
sl@0
   156
	
sl@0
   157
/////Part 7	
sl@0
   158
	aSize = 10;
sl@0
   159
	ret = RPipe::Create(	aSize,
sl@0
   160
							aReader, 
sl@0
   161
							aWriter,
sl@0
   162
							EOwnerProcess,//TOwnerType aTypeW
sl@0
   163
							EOwnerProcess//TOwnerType aTypeW
sl@0
   164
						);
sl@0
   165
	
sl@0
   166
	test.Next(_L("PIPE TEST: PipeProcess 5-20\n"));				 
sl@0
   167
	test ( ret == KErrNone);
sl@0
   168
	aReader.Close();
sl@0
   169
	aWriter.Close();
sl@0
   170
	
sl@0
   171
	test.End();		
sl@0
   172
	test.Close();
sl@0
   173
	
sl@0
   174
	return;
sl@0
   175
}
sl@0
   176
sl@0
   177
GLDEF_C TInt E32Main()
sl@0
   178
{
sl@0
   179
sl@0
   180
	test.Title();
sl@0
   181
sl@0
   182
	RunTests();
sl@0
   183
sl@0
   184
	return KErrNone;
sl@0
   185
}
sl@0
   186