os/kernelhwsrv/kerneltest/e32test/pipe/t_pipe3.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_pipe3.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 #include <e32test.h>
    22 #include <e32svr.h>
    23 #include "rpipe.h"
    24 
    25 
    26 LOCAL_D RTest test(_L("t_pipe3"));
    27 
    28 _LIT(KPipeName2, "PipeWithNoCap");
    29 _LIT(KPipeName3, "PipeWithNoCapVID");
    30 _LIT(KPipeName4, "PipeWithRWCap");
    31 
    32 
    33 
    34 
    35 LOCAL_C void RunTests(void)
    36 	{
    37 	
    38 	test.Start(_L("Testing In Pipe Process 3 : Process with No Capabilities"));
    39 	RPipe					aReader, aWriter;
    40 		
    41 	TInt		ret,aSize;
    42 	
    43 /////// Part 1		
    44 	test.Next(_L("PIPE TEST: PipeProcess 3-1: Open Read handle to Pipe with No capability.\n"));
    45 	ret = aReader.Open(KPipeName2,RPipe::EOpenToRead);
    46 	test ( ret == KErrNone);
    47 	
    48 	test.Next(_L("PIPE TEST: PipeProcess 3-2: Open Write handle to Pipe with No capability.\n"));				 
    49 	ret = aWriter.Open(KPipeName2,RPipe::EOpenToWrite);
    50 	test ( ret == KErrNone);
    51 	
    52 	aReader.Close();
    53 	aWriter.Close();
    54 	
    55 	test.Next(_L("PIPE TEST: PipeProcess 3-3: Open Write handle to Pipe with No capability.\n"));				 
    56 	ret = aReader.Open(KPipeName2,RPipe::EOpenToRead);
    57 	test ( ret == KErrNone);
    58 	ret = aWriter.Open(KPipeName2,RPipe::EOpenToWriteNamedPipeButFailOnNoReaders);
    59 	test ( ret == KErrNone);
    60 	
    61 	aReader.Close();
    62 	aWriter.Close();
    63 	
    64 	test.Next(_L("PIPE TEST: PipeProcess 3-4: Destroy Pipe with No capability.\n"));				 
    65 	ret = RPipe::Destroy (KPipeName2);
    66 	test ( ret == KErrNone);
    67 	
    68 /////// Part 2
    69 	test.Next(_L("PIPE TEST: PipeProcess 3-5: Open Read handle to Pipe with Read-Write capability.\n"));
    70 	ret = aReader.Open(KPipeName4,RPipe::EOpenToRead);
    71 	test ( ret == KErrPermissionDenied);
    72 	
    73 	test.Next(_L("PIPE TEST: PipeProcess 3-6: Open Write handle to Pipe with Read-Write capability.\n"));				 
    74 	ret = aWriter.Open(KPipeName4,RPipe::EOpenToWrite);
    75 	test ( ret == KErrPermissionDenied);
    76 	
    77 	aReader.Close();
    78 	aWriter.Close();
    79 	
    80 /////// Part 3
    81 	test.Next(_L("PIPE TEST: PipeProcess 3-7: Open Read handle to Pipe with No capability.\n"));
    82 	ret = aReader.Open(KPipeName3,RPipe::EOpenToRead);
    83 	test ( ret == KErrNone);
    84 	
    85 	test.Next(_L("PIPE TEST: PipeProcess 3-8: Open Write handle to Pipe with No capability.\n"));				 
    86 	ret = aWriter.Open(KPipeName3,RPipe::EOpenToWrite);
    87 	test ( ret == KErrNone);
    88 	
    89 	aReader.Close();
    90 	aWriter.Close();
    91 	
    92 	test.Next(_L("PIPE TEST: PipeProcess 3-9: Destroy Pipe with No capability.\n"));				 
    93 	ret = RPipe::Destroy (KPipeName3);
    94 	test ( ret == KErrNone);
    95 	
    96 /////// Part 4			
    97 	aSize = 10;
    98 	ret = RPipe::Create(	aSize,
    99 							aReader, 
   100 							aWriter,
   101 							EOwnerProcess,//TOwnerType aTypeW
   102 							EOwnerProcess//TOwnerType aTypeW
   103 						);
   104 	
   105 	test.Next(_L("PIPE TEST: PipeProcess 3-10: Create UnNamed Pipe. It shall be allow.\n"));				 
   106 	test ( ret == KErrNone);
   107 	aReader.Close();
   108 	aWriter.Close();
   109 
   110 	test.End();		
   111 	test.Close();
   112 
   113 /////// Test End
   114 	
   115 	return;
   116 }
   117 
   118 GLDEF_C TInt E32Main()
   119 {
   120 
   121 	test.Title();
   122 
   123 	RunTests();
   124 
   125 	return KErrNone;
   126 }
   127