//+------------------------------------------------------------------------ // // Microsoft Windows // Copyright (C) Microsoft Corporation, 1993. // // File: bm_rrpc.cxx // // Contents: Raw Rpc function call tests // // Classes: CRawRpc // // History: 1-Jul-93 t-martig Created // 2-Feb-94 rickhi Modified from above for Raw Rpc // //-------------------------------------------------------------------------- #include #pragma hdrstop #include HRESULT StartServer(BOOL _fDebug, LPTSTR _pszPath); extern "C" const GUID IID_IRawRpc; TCHAR *CRawRpc::Name () { return TEXT("RawRpc"); } SCODE CRawRpc::Setup (CTestInput *pInput) { CTestBase::Setup(pInput); // get flag indicating whether to keep all values or // only average values. TCHAR szAverage[5]; pInput->GetConfigString(Name(), TEXT("Average"), TEXT("Y"), szAverage, sizeof(szAverage)/sizeof(TCHAR)); if (szAverage[0] == 'n' || szAverage[0] == 'N') m_fAverage = FALSE; else m_fAverage = TRUE; // get iteration count if (m_fAverage) m_ulIterations = pInput->GetRealIterations(Name()); else m_ulIterations = pInput->GetIterations(Name()); m_pszStringBinding = NULL; m_hRpc = NULL; // initialize timing arrays INIT_RESULTS(m_ulVoidTime); INIT_RESULTS(m_ulVoidRCTime); INIT_RESULTS(m_ulDwordInTime); INIT_RESULTS(m_ulDwordOutTime); INIT_RESULTS(m_ulDwordInOutTime); INIT_RESULTS(m_ulStringInTime); INIT_RESULTS(m_ulStringOutTime); INIT_RESULTS(m_ulStringInOutTime); INIT_RESULTS(m_ulGuidInTime); INIT_RESULTS(m_ulGuidOutTime); // get the server exe name and debug flag out of the ini file, then // start the server and wait for it. TCHAR szServer[15]; pInput->GetConfigString(Name(), TEXT("Server"), TEXT("rawrpc.exe"), szServer, sizeof(szServer)/sizeof(TCHAR)); // get input TCHAR szValue[40]; pInput->GetConfigString(Name(), TEXT("Debug"), TEXT("N"), szValue, sizeof(szValue)/sizeof(TCHAR)); BOOL fDebug = !lstrcmpi(szValue, TEXT("Y")); DWORD dwTimeout = pInput->GetConfigInt(Name(), TEXT("Timeout"), 60000); HANDLE hEvent = CreateEvent(NULL, TRUE, FALSE, TEXT("OleBenchRawRpcServerStarted")); if (NULL == hEvent) { Log (TEXT("Setup - Event Creation failed."), GetLastError()); return E_FAIL; } // start the server application and wait for it. HRESULT sc = StartServer(fDebug, szServer); if (FAILED(sc)) { Log (TEXT("Setup - Start Server failed."), sc); CloseHandle(hEvent); return sc; } if (WAIT_OBJECT_0 != WaitForSingleObject(hEvent, dwTimeout)) { Log (TEXT("Setup - Server never signaled."), GetLastError()); CloseHandle(hEvent); return E_FAIL; } CloseHandle(hEvent); // bind to the server application TCHAR szProtseq[20]; TCHAR szNetworkAddr[20]; pInput->GetConfigString(Name(), TEXT("Protseq"), #ifdef USE_MSWMSG TEXT("mswmsg"), #else TEXT("ncalrpc"), #endif szProtseq, 20); pInput->GetConfigString(Name(), TEXT("NetworkAddr"), TEXT(""), szNetworkAddr, 20); LPTSTR pszEndPoint = TEXT("99999.99999"); RPC_STATUS rc; #ifdef UNICODE rc = RpcStringBindingCompose(NULL, szProtseq, szNetworkAddr, pszEndPoint, NULL, &m_pszStringBinding); #else // // Can't just use TCHAR here because RpcString*() take unsigned // chars // rc = RpcStringBindingCompose(NULL, (unsigned char *)szProtseq, (unsigned char *)szNetworkAddr, (unsigned char *)pszEndPoint, NULL, (unsigned char **)&m_pszStringBinding); #endif if (rc != S_OK) { Log(TEXT("Setup - RpcStringBindingCompose failed."), rc); return rc; } #ifdef UNICODE rc = RpcBindingFromStringBinding(m_pszStringBinding, &m_hRpc); #else rc = RpcBindingFromStringBinding((unsigned char *)m_pszStringBinding, &m_hRpc); #endif if (rc != S_OK) { Log(TEXT("Setup - RpcBindingFromStringBinding failed."), rc); return rc; } // all done. return S_OK; } SCODE CRawRpc::Cleanup () { if (m_hRpc) { RpcBindingFree(&m_hRpc); } if (m_pszStringBinding) { #ifdef UNICODE RpcStringFree(&m_pszStringBinding); #else RpcStringFree((unsigned char **)&m_pszStringBinding); #endif } return S_OK; } SCODE CRawRpc::Run () { CStopWatch sw; SCODE sc; ULONG iIter; // // void passing tests // ResetAverage( m_fAverage, sw ); for (iIter=0; iIter