1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmtestenv/mmtestfw/Source/SimulProc/SimulProcClient.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,144 @@
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 "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 +// Implementation of the RTestServ and RTestSession API's
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file TestClient.cpp
1.23 +*/
1.24 +//#include "..\..\SampleServer\src\SampleServer.h"
1.25 +#include <simulprocserver.h>
1.26 +#include <simulprocclient.h>
1.27 +
1.28 +
1.29 +TVersion RTestServ::Version() const
1.30 + {
1.31 + return(TVersion(1,0,1));
1.32 + }
1.33 +
1.34 +EXPORT_C TInt RTestServ::Connect(const TDesC& aServerName)
1.35 +/**
1.36 + * @param aServerName - Human readable name of the test server
1.37 + * @param aDebugMode - Set to true for just in time debugging
1.38 + * @return int - Standard error codes
1.39 + * Secure version of the API call. Expects the server binary to be
1.40 + * ServerXXX.exe
1.41 + */
1.42 + {
1.43 + if(aServerName.Length() > iServerName.MaxLength())
1.44 + return KErrTooBig;
1.45 + iServerName = aServerName;
1.46 + // Assume the server is already running and attempt to create a session
1.47 + // 4 message slots
1.48 + TInt err = CreateSession(aServerName,Version(),4);
1.49 + if(err == KErrNotFound)
1.50 + {
1.51 + // Server not running
1.52 + // Construct the server binary name
1.53 + TBuf<KMaxServerNameLength> serverFile;
1.54 + RProcess server;
1.55 + _LIT(KEmpty,"");
1.56 + _LIT(KExe,".exe");
1.57 +
1.58 + serverFile.Copy(aServerName);
1.59 + serverFile.Append(KExe);
1.60 + err = server.Create(serverFile,KEmpty);
1.61 + if(err != KErrNone)
1.62 + return err;
1.63 + // Synchronise with the server
1.64 + TRequestStatus reqStatus;
1.65 + server.Rendezvous(reqStatus);
1.66 +
1.67 + if (reqStatus!=KRequestPending)
1.68 + {
1.69 + server.Kill(0);
1.70 + }
1.71 + else
1.72 + {
1.73 + // Start the test harness
1.74 + server.Resume();
1.75 + // Server will call the reciprocal static synchronise call
1.76 + }
1.77 + User::WaitForRequest(reqStatus); // wait for start or death
1.78 + server.Close();
1.79 + if(reqStatus.Int() != KErrNone)
1.80 + return reqStatus.Int();
1.81 +
1.82 + // Create the root server session
1.83 + err = CreateSession(aServerName,Version(),4);
1.84 + }
1.85 + return err;
1.86 + }
1.87 +
1.88 +EXPORT_C const TDesC& RTestServ::ServerName() const
1.89 +/**
1.90 + * @return - The human readable server name
1.91 + */
1.92 + {
1.93 + return iServerName;
1.94 + }
1.95 +
1.96 +//
1.97 +EXPORT_C TInt RTestSession::Open(RTestServ& aServ, const TDesC& aStepName, TBool aSharedData)
1.98 +/**
1.99 + * @param aServ - Reference to the root server session
1.100 + * @param aStepName - Reference to the name of the test step owned by the server
1.101 + * @return Standard error codes
1.102 + * Secure and Non-secure variants
1.103 + * Synchronously open a server test step session
1.104 + */
1.105 + {
1.106 + if(aStepName.Length() > KMaxServerNameLength)
1.107 + return KErrTooBig;
1.108 + TIpcArgs args;
1.109 + args.Set(0,&aStepName);
1.110 + args.Set(1,aSharedData);
1.111 + return CreateSubSession(aServ,EMMTSOpenTestStep,args);
1.112 + }
1.113 +
1.114 +EXPORT_C void RTestSession::StartProcessing(TRequestStatus& aStatus)
1.115 +/**
1.116 + *
1.117 + * @param aCommandString - The arguments to the RUN_TEST_STEP command
1.118 + * @return aPanicString - If the test step panics, this member is set up with the panic string
1.119 + * @param aStatus - For completion to the caller
1.120 + * Secure and Non-secure variants
1.121 + * Send the RUN_TEST_STEP arguments to the test server
1.122 + */
1.123 + {
1.124 + SendReceive(EMMTSStartProcessing,aStatus);
1.125 + }
1.126 +
1.127 +EXPORT_C TVerdict RTestSession::EndProcessingAndReturnResult(TDes8& aMessage)
1.128 +/**
1.129 + *
1.130 + * @return - Standard Epoc error codes
1.131 + * Secure and Non-secure variants
1.132 + * Synchronous abort of the the test step
1.133 + */
1.134 + {
1.135 +
1.136 + TPckgBuf<TVerdict> v;
1.137 + TIpcArgs args;
1.138 + args.Set(0,&v);
1.139 + args.Set(1,&aMessage);
1.140 + SendReceive(EMMTSStopProcessing, args);
1.141 + return v();
1.142 + }
1.143 +
1.144 +EXPORT_C void RTestSession::Close()
1.145 + {
1.146 + CloseSubSession(EMMTSClose);
1.147 + }