Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

190 lines
3.9 KiB

  1. //+------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993.
  5. //
  6. // File: bm_nest.cxx
  7. //
  8. // Contents: Nested Object Rpc Method Invocation tests
  9. //
  10. // Classes: CNestTest
  11. //
  12. // History: 1-July-93 t-martig Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #include <headers.cxx>
  16. #pragma hdrstop
  17. #include <bm_nest.hxx>
  18. #include <oletest.hxx>
  19. #include <tracelog.hxx>
  20. TCHAR *CNestTest::Name ()
  21. {
  22. return TEXT("Nested");
  23. }
  24. SCODE CNestTest::Setup (CTestInput *pInput)
  25. {
  26. CTestBase::Setup(pInput);
  27. // get iteration count
  28. m_ulIterations = pInput->GetIterations(Name());
  29. // get CLSID of server
  30. SCODE sc = pInput->GetGUID(&m_ClsID, Name(), TEXT("Clsid_Local"));
  31. if (FAILED(sc))
  32. {
  33. Log (TEXT("Setup - GetClassID failed."), sc);
  34. return sc;
  35. }
  36. // initialize timing arrays
  37. INIT_RESULTS(m_ulNest2Time);
  38. INIT_RESULTS(m_ulNest3Time);
  39. INIT_RESULTS(m_ulNest4Time);
  40. INIT_RESULTS(m_ulNest5Time);
  41. sc = InitCOM();
  42. if (FAILED(sc))
  43. {
  44. Log (TEXT("Setup - CoInitialize failed."), sc);
  45. return sc;
  46. }
  47. m_pILoop1=NULL;
  48. sc = CoCreateInstance(m_ClsID, NULL, CLSCTX_LOCAL_SERVER,
  49. IID_ILoop, (void **)&m_pILoop1);
  50. if (FAILED(sc))
  51. {
  52. Log (TEXT("Setup - CoCreateInstance of first Server failed."), sc);
  53. return sc;
  54. }
  55. m_pILoop2=NULL;
  56. sc = CoCreateInstance(m_ClsID, NULL, CLSCTX_LOCAL_SERVER,
  57. IID_ILoop, (void **)&m_pILoop2);
  58. if (FAILED(sc))
  59. {
  60. Log (TEXT("Setup - CoCreateInstance of second Server failed."), sc);
  61. return sc;
  62. }
  63. // pass the pointers to each other
  64. sc = m_pILoop1->Init(m_pILoop2);
  65. if (FAILED(sc))
  66. {
  67. Log (TEXT("Setup - Initialization of first Server failed."), sc);
  68. return sc;
  69. }
  70. sc = m_pILoop2->Init(m_pILoop1);
  71. if (FAILED(sc))
  72. {
  73. Log (TEXT("Setup - Initialization of second Server failed."), sc);
  74. return sc;
  75. }
  76. return S_OK;
  77. }
  78. SCODE CNestTest::Cleanup ()
  79. {
  80. if (m_pILoop1)
  81. {
  82. m_pILoop1->Uninit();
  83. m_pILoop1->Release();
  84. }
  85. if (m_pILoop2)
  86. {
  87. m_pILoop2->Uninit();
  88. m_pILoop2->Release();
  89. }
  90. UninitCOM();
  91. return S_OK;
  92. }
  93. SCODE CNestTest::Run ()
  94. {
  95. CStopWatch sw;
  96. SCODE sc;
  97. //
  98. // nesting 2 levels. Note we pass in 3 not 2, since the server
  99. // subtracts 1 from the passed in value and then stops the nesting
  100. // if the count is zero.
  101. //
  102. // a value of 3 represents a single nested call.
  103. //
  104. for (ULONG iIter=0; iIter<m_ulIterations; iIter++)
  105. {
  106. sw.Reset();
  107. sc = m_pILoop1->Loop(3);
  108. m_ulNest2Time[iIter] = sw.Read();
  109. Log (TEXT("Loop (2)"), sc);
  110. }
  111. //
  112. // nesting 3 levels
  113. //
  114. for (iIter=0; iIter<m_ulIterations; iIter++)
  115. {
  116. sw.Reset();
  117. sc= m_pILoop1->Loop(4);
  118. m_ulNest3Time[iIter] = sw.Read();
  119. Log (TEXT("Loop (3)"), sc);
  120. }
  121. //
  122. // nesting 4 levels
  123. //
  124. for (iIter=0; iIter<m_ulIterations; iIter++)
  125. {
  126. sw.Reset();
  127. sc = m_pILoop1->Loop(5);
  128. m_ulNest4Time[iIter] = sw.Read();
  129. Log (TEXT("Loop (4)"), sc);
  130. }
  131. //
  132. // nesting 5 levels
  133. //
  134. for (iIter=0; iIter<m_ulIterations; iIter++)
  135. {
  136. sw.Reset();
  137. sc = m_pILoop1->Loop(6);
  138. m_ulNest5Time[iIter] = sw.Read();
  139. Log (TEXT("Loop (5)"), sc);
  140. }
  141. return S_OK;
  142. }
  143. SCODE CNestTest::Report (CTestOutput &output)
  144. {
  145. output.WriteSectionHeader (Name(), TEXT("Nested ORpc Calls"), *m_pInput);
  146. output.WriteString (TEXT("\n"));
  147. output.WriteResults (TEXT("Nesting 2 "), m_ulIterations, m_ulNest2Time);
  148. output.WriteResults (TEXT("Nesting 3 "), m_ulIterations, m_ulNest3Time);
  149. output.WriteResults (TEXT("Nesting 4 "), m_ulIterations, m_ulNest4Time);
  150. output.WriteResults (TEXT("Nesting 5 "), m_ulIterations, m_ulNest5Time);
  151. return S_OK;
  152. }