os/kernelhwsrv/kerneltest/e32test/mqueue/t_mqueueecho.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/mqueue/t_mqueueecho.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,75 @@
     1.4 +/*
     1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +#include <e32test.h>
    1.22 +#include <e32svr.h>
    1.23 +#include <e32msgqueue.h>
    1.24 +
    1.25 +LOCAL_D RTest test(_L("t_mqueueecho"));
    1.26 +
    1.27 +
    1.28 +_LIT(KQueueA, "A");
    1.29 +_LIT(KQueueB, "B");
    1.30 +
    1.31 +LOCAL_C void RunTests(void)
    1.32 +	{
    1.33 +	test.Start(_L("Testing"));
    1.34 +
    1.35 +	RMsgQueueBase in;
    1.36 +	RMsgQueueBase out;
    1.37 +
    1.38 +	TInt ret = in.OpenGlobal(KQueueA);
    1.39 +	test (KErrNone == ret);
    1.40 +	ret = out.OpenGlobal(KQueueB);
    1.41 +	test (KErrNone == ret);
    1.42 +
    1.43 +	TInt size = in.MessageSize();
    1.44 +	test (size == out.MessageSize());
    1.45 + 
    1.46 +	TUint8* pBuffer = (TUint8*)User::Alloc(size);
    1.47 +	test (NULL != pBuffer);
    1.48 +
    1.49 +	TInt count = 0;
    1.50 +	do
    1.51 +		{
    1.52 +		in.ReceiveBlocking(pBuffer, size);
    1.53 +		out.SendBlocking(pBuffer, size);
    1.54 +		test.Printf(_L("Echo iteration %i received %i\r\n"), ++count, *(TInt*)pBuffer);
    1.55 +		}
    1.56 +	while (*(TInt*)pBuffer != 0);
    1.57 +
    1.58 +
    1.59 +	in.Close();
    1.60 +	out.Close();
    1.61 +	test.Next(_L("Ending test.\n"));
    1.62 +	test.End();
    1.63 +	
    1.64 +	test.Close();
    1.65 +	}
    1.66 +
    1.67 +GLDEF_C TInt E32Main()
    1.68 +//
    1.69 +//
    1.70 +    {
    1.71 +
    1.72 +	test.Title();
    1.73 +
    1.74 +	RunTests();
    1.75 +
    1.76 +	return KErrNone;
    1.77 +    }
    1.78 +