os/kernelhwsrv/kerneltest/e32test/mqueue/t_mqueueecho.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 
    18 #include <e32test.h>
    19 #include <e32svr.h>
    20 #include <e32msgqueue.h>
    21 
    22 LOCAL_D RTest test(_L("t_mqueueecho"));
    23 
    24 
    25 _LIT(KQueueA, "A");
    26 _LIT(KQueueB, "B");
    27 
    28 LOCAL_C void RunTests(void)
    29 	{
    30 	test.Start(_L("Testing"));
    31 
    32 	RMsgQueueBase in;
    33 	RMsgQueueBase out;
    34 
    35 	TInt ret = in.OpenGlobal(KQueueA);
    36 	test (KErrNone == ret);
    37 	ret = out.OpenGlobal(KQueueB);
    38 	test (KErrNone == ret);
    39 
    40 	TInt size = in.MessageSize();
    41 	test (size == out.MessageSize());
    42  
    43 	TUint8* pBuffer = (TUint8*)User::Alloc(size);
    44 	test (NULL != pBuffer);
    45 
    46 	TInt count = 0;
    47 	do
    48 		{
    49 		in.ReceiveBlocking(pBuffer, size);
    50 		out.SendBlocking(pBuffer, size);
    51 		test.Printf(_L("Echo iteration %i received %i\r\n"), ++count, *(TInt*)pBuffer);
    52 		}
    53 	while (*(TInt*)pBuffer != 0);
    54 
    55 
    56 	in.Close();
    57 	out.Close();
    58 	test.Next(_L("Ending test.\n"));
    59 	test.End();
    60 	
    61 	test.Close();
    62 	}
    63 
    64 GLDEF_C TInt E32Main()
    65 //
    66 //
    67     {
    68 
    69 	test.Title();
    70 
    71 	RunTests();
    72 
    73 	return KErrNone;
    74     }
    75