Source code of Windows XP (NT5)
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.

512 lines
16 KiB

  1. //+------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993.
  5. //
  6. // File: bmdriver.cxx
  7. //
  8. // Contents: Main module of the benchmark test
  9. //
  10. // Classes: CBenchMarkDriver
  11. //
  12. // Functions: WinMain
  13. //
  14. // History: 30-June-93 t-martig Created
  15. // 07-June-94 t-vadims Added Storage tests
  16. //
  17. //--------------------------------------------------------------------------
  18. #include <benchmrk.hxx>
  19. #include <bmdriver.hxx>
  20. #include <bm_activ.hxx>
  21. #include <bm_alloc.hxx>
  22. #include <bm_api.hxx>
  23. #include <bm_cgps.hxx>
  24. #include <bm_iid.hxx>
  25. #include <bm_init.hxx>
  26. #include <bm_marsh.hxx>
  27. #include <bm_mrsh2.hxx>
  28. #include <bm_noise.hxx>
  29. #include <bm_nest.hxx>
  30. #include <bm_obind.hxx>
  31. #include <bm_props.hxx>
  32. #include <bm_qi.hxx>
  33. #include <bm_regis.hxx>
  34. #include <bm_rot.hxx>
  35. #include <bm_rpc.hxx>
  36. #include <bm_rpc2.hxx>
  37. #include <bm_rrpc.hxx>
  38. #include <bm_sbind.hxx>
  39. #include <bm_filio.hxx>
  40. #include <bm_stg.hxx>
  41. #include <bm_nstg.hxx>
  42. #include <bmp_stg.hxx>
  43. #include "..\cairole\ui\hlp_iocs.hxx"
  44. #include "..\cairole\ui\hlp_ias.hxx"
  45. #include "..\cairole\ui\hlp_site.hxx"
  46. #include "..\cairole\ui\hlp_doc.hxx"
  47. #include "..\cairole\ui\bm_crt.hxx"
  48. #include "..\cairole\ui\bm_crtl.hxx"
  49. //#include "..\cairole\ui\bm_clip.hxx"
  50. #include "..\cairole\ui\bm_load.hxx"
  51. #include "..\cairole\ui\bm_link.hxx"
  52. #include "..\cairole\ui\bm_cache.hxx"
  53. #define REGISTRY_ENTRY_LEN 256
  54. typedef struct
  55. {
  56. const char *key;
  57. const char *value;
  58. } RegistryKeyValue;
  59. const RegistryKeyValue REG_CONST_KEY[] =
  60. {
  61. ".bm1", "CLSID\\{99999999-0000-0008-C000-000000000052}",
  62. ".bm2", "CLSID\\{99999999-0000-0008-C000-000000000051}",
  63. "CLSID\\{20730701-0001-0008-C000-000000000046}", "OleTestClass",
  64. "CLSID\\{20730711-0001-0008-C000-000000000046}", "OleTestClass1",
  65. "CLSID\\{20730712-0001-0008-C000-000000000046}", "OleTestClass2",
  66. "CLSID\\{20730713-0001-0008-C000-000000000046}", "OleTestClass3",
  67. "CLSID\\{20730714-0001-0008-C000-000000000046}", "OleTestClass4",
  68. "CLSID\\{20730715-0001-0008-C000-000000000046}", "OleTestClass5",
  69. "CLSID\\{20730716-0001-0008-C000-000000000046}", "OleTestClass6",
  70. "CLSID\\{20730717-0001-0008-C000-000000000046}", "OleTestClass7",
  71. "CLSID\\{20730718-0001-0008-C000-000000000046}", "OleTestClass8",
  72. "CLSID\\{00000138-0001-0008-C000-000000000046}", "CPrxyBalls",
  73. "Interface\\{00000138-0001-0008-C000-000000000046}", "IBalls",
  74. "Interface\\{00000139-0001-0008-C000-000000000046}", "ICube",
  75. "Interface\\{00000136-0001-0008-C000-000000000046}", "ILoops",
  76. "Interface\\{00000137-0001-0008-C000-000000000046}", "IRpcTest",
  77. "Interface\\{00000138-0001-0008-C000-000000000046}\\ProxyStubClsid32", "{00000138-0001-0008-C000-000000000046}",
  78. "Interface\\{00000139-0001-0008-C000-000000000046}\\ProxyStubClsid32", "{00000138-0001-0008-C000-000000000046}",
  79. "Interface\\{00000136-0001-0008-C000-000000000046}\\ProxyStubClsid32", "{00000138-0001-0008-C000-000000000046}",
  80. "Interface\\{00000137-0001-0008-C000-000000000046}\\ProxyStubClsid32", "{00000138-0001-0008-C000-000000000046}",
  81. "CLSID\\{0000013a-0001-0008-C000-000000000046}\\ProgID", "ProgID60",
  82. "CLSID\\{0000013a-0001-0008-C000-000000000046}", "CBallsClassFactory",
  83. "CLSID\\{0000013b-0001-0008-C000-000000000046}", "CCubesClassFactory",
  84. "CLSID\\{0000013c-0001-0008-C000-000000000046}", "CLoopClassFactory",
  85. "CLSID\\{0000013d-0001-0008-C000-000000000046}", "CRpcTestClassFactory",
  86. "CLSID\\{00000140-0000-0008-C000-000000000046}", "CQueryInterface",
  87. "CLSID\\{00000142-0000-0008-C000-000000000046}", "Dummy",
  88. ".ut4", "ProgID50",
  89. ".ut5", "ProgID51",
  90. ".ut6", "ProgID52",
  91. ".ut7", "ProgID53",
  92. ".ut8", "ProgID54",
  93. ".ut9", "ProgID55",
  94. ".bls", "ProgID60",
  95. "CLSID\\{99999999-0000-0008-C000-000000000050}", "SDI",
  96. "CLSID\\{99999999-0000-0008-C000-000000000051}", "MDI",
  97. "CLSID\\{99999999-0000-0008-C000-000000000052}", "InprocNoRegister",
  98. "CLSID\\{99999999-0000-0008-C000-000000000053}", "InprocRegister",
  99. "CLSID\\{99999999-0000-0008-C000-000000000054}", "InprocRegister",
  100. "CLSID\\{99999999-0000-0008-C000-000000000054}\\TreatAs", "{99999999-0000-0008-C000-000000000050}",
  101. "CLSID\\{99999999-0000-0008-C000-000000000055}", "MDI",
  102. "CLSID\\{99999999-0000-0008-C000-000000000055}\\ActivateAtBits", "Y",
  103. "ProgID50", "objact sdi",
  104. "ProgID50\\CLSID", "{99999999-0000-0008-C000-000000000050}",
  105. "ProgID51", "objact mdi",
  106. "ProgID51\\CLSID", "{99999999-0000-0008-C000-000000000051}",
  107. "ProgID52", "objact dll",
  108. "ProgID52\\CLSID", "{99999999-0000-0008-C000-000000000052}",
  109. "ProgID53", "objact dll reg",
  110. "ProgID53\\CLSID", "{99999999-0000-0008-C000-000000000053}",
  111. "ProgID54", "objact dll reg",
  112. "ProgID54\\CLSID", "{99999999-0000-0008-C000-000000000054}",
  113. "ProgID55", "remote activation",
  114. "ProgID55\\CLSID", "{99999999-0000-0008-C000-000000000055}",
  115. "ProgID60", "CLSIDFromProgID test",
  116. "ProgID60\\CLSID", "{0000013a-0001-0008-C000-000000000046}",
  117. // Indicates end of list.
  118. "", ""
  119. };
  120. const RegistryKeyValue REG_EXE_KEY[] =
  121. {
  122. "CLSID\\{20730701-0001-0008-C000-000000000046}\\InprocServer32", "oletest.dll",
  123. "CLSID\\{20730711-0001-0008-C000-000000000046}\\InprocServer32", "oletest.dll",
  124. "CLSID\\{20730712-0001-0008-C000-000000000046}\\InprocServer32", "oletest.dll",
  125. "CLSID\\{20730713-0001-0008-C000-000000000046}\\InprocServer32", "oletest.dll",
  126. "CLSID\\{20730714-0001-0008-C000-000000000046}\\InprocServer32", "oletest.dll",
  127. "CLSID\\{20730715-0001-0008-C000-000000000046}\\InprocServer32", "oletest.dll",
  128. "CLSID\\{20730716-0001-0008-C000-000000000046}\\InprocServer32", "oletest.dll",
  129. "CLSID\\{20730717-0001-0008-C000-000000000046}\\InprocServer32", "oletest.dll",
  130. "CLSID\\{20730718-0001-0008-C000-000000000046}\\InprocServer32", "oletest.dll",
  131. "CLSID\\{20730712-0001-0008-C000-000000000046}\\LocalServer32", "bmtstsvr.exe",
  132. "CLSID\\{20730701-0001-0008-C000-000000000046}\\LocalServer32", "bmtstsvr.exe",
  133. "CLSID\\{0000013a-0001-0008-C000-000000000046}\\LocalServer32", "ballsrv.exe",
  134. "CLSID\\{00000138-0001-0008-C000-000000000046}\\InprocServer32", "iballs.dll",
  135. "CLSID\\{0000013b-0001-0008-C000-000000000046}\\LocalServer32", "cubesrv.exe",
  136. "CLSID\\{0000013c-0001-0008-C000-000000000046}\\LocalServer32", "loopsrv.exe",
  137. "CLSID\\{0000013d-0001-0008-C000-000000000046}\\LocalServer32", "rpctst.exe",
  138. "CLSID\\{00000140-0000-0008-C000-000000000046}\\LocalServer32", "qisrv.exe",
  139. "CLSID\\{00000140-0000-0008-C000-000000000046}\\InprocServer32", "qisrv.dll",
  140. "CLSID\\{00000142-0000-0008-C000-000000000046}\\InprocServer32", "ballsrv.dll",
  141. "CLSID\\{99999999-0000-0008-C000-000000000050}\\LocalServer32", "sdi.exe",
  142. "CLSID\\{99999999-0000-0008-C000-000000000051}\\LocalServer32", "mdi.exe",
  143. "CLSID\\{99999999-0000-0008-C000-000000000052}\\InprocServer32", "dlltest.dll",
  144. "CLSID\\{99999999-0000-0008-C000-000000000053}\\InprocServer32", "dlltest.dll",
  145. "CLSID\\{99999999-0000-0008-C000-000000000055}\\LocalServer32", "db.exe",
  146. // Indicates end of list.
  147. "", ""
  148. };
  149. DWORD g_fFullInfo = 0; // write full info or not
  150. DWORD g_dwPauseBetweenTests = 0; // time delay between running tests
  151. //+-------------------------------------------------------------------
  152. //
  153. // Member: CBenchMarkDriver::RunTest, public
  154. //
  155. // Synopsis: Sets up, runs, reports and cleans up test procedure
  156. // of specified class
  157. //
  158. // Parameters: [output] Output class for results
  159. // [pTest] Test object
  160. //
  161. // History: 30-June-93 t-martig Created
  162. //
  163. //--------------------------------------------------------------------
  164. SCODE CBenchMarkDriver::RunTest (CTestInput &input,
  165. CTestOutput &output, CTestBase *pTest)
  166. {
  167. TCHAR szConfigString[80];
  168. SCODE sc;
  169. input.GetConfigString (TEXT("Tests"), pTest->Name(),
  170. TEXT("OFF"), szConfigString, 80);
  171. if (lstrcmpi (szConfigString, TEXT("OFF")) != 0 &&
  172. lstrcmpi (szConfigString, TEXT("FALSE")) != 0)
  173. {
  174. LogSection (pTest->Name());
  175. sc=pTest->Setup(&input);
  176. if (FAILED(sc))
  177. return sc;
  178. // pause between test invocations
  179. Sleep(g_dwPauseBetweenTests);
  180. sc = pTest->Run();
  181. pTest->Report(output);
  182. pTest->Cleanup();
  183. if (FAILED(sc))
  184. {
  185. output.WriteString (TEXT("\nStatus:\tERROR, see log file\n"));
  186. }
  187. // pause between test invocations
  188. Sleep(g_dwPauseBetweenTests);
  189. }
  190. return sc;
  191. }
  192. //+-------------------------------------------------------------------
  193. //
  194. // Member: CBenchMarkDriver::WriteHeader, public
  195. //
  196. // Synopsis: Prints test form header into output file
  197. //
  198. // History: 5-August-93 t-martig Created
  199. //
  200. //--------------------------------------------------------------------
  201. void CBenchMarkDriver::WriteHeader (CTestInput &input, CTestOutput &output)
  202. {
  203. _SYSTEMTIME stTimeDate;
  204. output.WriteString (TEXT("CairOLE Benchmarks\n"));
  205. output.WriteConfigEntry (input, TEXT("Driver"), TEXT("Tester"), TEXT(""));
  206. GetLocalTime (&stTimeDate);
  207. output.WriteDate (&stTimeDate);
  208. output.WriteString (TEXT("\t"));
  209. output.WriteTime (&stTimeDate);
  210. output.WriteString (TEXT("\n\n"));
  211. }
  212. //+-------------------------------------------------------------------
  213. //
  214. // Member: CBenchMarkDriver::Run, public
  215. //
  216. // Synopsis: Runs all tests specified in .ini file
  217. //
  218. // History: 30-June-93 t-martig Created
  219. //
  220. //--------------------------------------------------------------------
  221. #define RUN_TEST(CMyTestClass) \
  222. { \
  223. CTestBase *pTest; \
  224. pTest = new CMyTestClass; \
  225. RunTest (input, output, pTest); \
  226. delete pTest; \
  227. output.Flush(); \
  228. }
  229. SCODE CBenchMarkDriver::Run (LPSTR lpCmdLine)
  230. {
  231. TCHAR szBenchMarkIniFile[MAX_PATH];
  232. TCHAR szOutputFileName[MAX_PATH];
  233. TCHAR szLogFileName[MAX_PATH];
  234. TCHAR szTemp[MAX_PATH];
  235. // Get file name of .ini file. if not specified in the command
  236. // line, use the default BM.INI in the local directory
  237. GetCurrentDirectory (MAX_PATH, szTemp);
  238. lstrcpy(szBenchMarkIniFile, szTemp);
  239. lstrcat (szBenchMarkIniFile, TEXT("\\BM.INI"));
  240. // create the names for the temporary files. uses pid.xxx. Its the
  241. // current directory appended with the pid and a file extension.
  242. OLECHAR szPid[9];
  243. DWORD pid = GetCurrentProcessId();
  244. CHAR aszPid[9];
  245. _itoa(pid, aszPid, 16);
  246. mbstowcs(szPid, aszPid, strlen(aszPid)+1);
  247. #ifdef UNICODE
  248. wcscpy(aszPerstName[0], szTemp);
  249. #else
  250. mbstowcs(aszPerstName[0], szTemp, strlen(szTemp)+1);
  251. #endif
  252. wcscat(aszPerstName[0], L"\\");
  253. wcscat(aszPerstName[0], szPid);
  254. wcscpy(aszPerstName[1], aszPerstName[0]);
  255. wcscpy(aszPerstNameNew[0], aszPerstName[0]);
  256. wcscpy(aszPerstNameNew[1], aszPerstName[0]);
  257. wcscat(aszPerstName[0], L".BM1");
  258. wcscat(aszPerstNameNew[0], L"NEW.BM1");
  259. wcscat(aszPerstName[1], L".BM2");
  260. wcscat(aszPerstNameNew[1], L"NEW.BM2");
  261. // Define input, output and log file
  262. CTestInput input (szBenchMarkIniFile);
  263. CTestOutput output (input.GetConfigString (TEXT("Driver"), TEXT("Report"),
  264. TEXT("BM.RES"), szOutputFileName, MAX_PATH));
  265. CTestOutput log (input.GetConfigString (TEXT("Driver"), TEXT("Log"),
  266. TEXT("BM.LOG"), szLogFileName, MAX_PATH));
  267. LogTo (&log);
  268. // Get the pause time between test invocations
  269. g_dwPauseBetweenTests = input.GetConfigInt (TEXT("Driver"),
  270. TEXT("PauseBetweenTests"),
  271. 2000);
  272. // Get global info level flag
  273. g_fFullInfo = input.GetInfoLevelFlag();
  274. // Write the correct OleInitialize flag to win.ini for the various
  275. // OLE servers to use, based on the init flag in bm.ini.
  276. LPTSTR pszOleInit;
  277. #ifdef THREADING_SUPPORT
  278. if (input.GetOleInitFlag() == COINIT_MULTITHREADED)
  279. {
  280. // pszOleInit = TEXT("MultiThreaded");
  281. }
  282. else
  283. #endif
  284. {
  285. // pszOleInit = TEXT("ApartmentThreaded");
  286. }
  287. // WriteProfileString(TEXT("TestSrv"), TEXT("ThreadMode"), pszOleInit);
  288. // WriteProfileString(TEXT("OleSrv"), TEXT("ThreadMode"), pszOleInit);
  289. // Write header and configuration info
  290. WriteHeader (input, output);
  291. ReportBMConfig (input, output);
  292. // Run all the tests
  293. // To add tests, use macro RUN_TEST, the parameter is the name of
  294. // the test class. Be sure to include a sction called [<TestClass>] in
  295. // the BM.INI file, as well as a switch under the [Tests] section
  296. // (<TestClass> = ON, e.g.)
  297. Sleep(1000);
  298. RUN_TEST (COleMarshalTest2);
  299. RUN_TEST (CNoiseTest);
  300. RUN_TEST (CRawRpc); // NOTE: must come before any OLE tests
  301. RUN_TEST (COleInitializeTest);
  302. RUN_TEST (COleRegistrationTest);
  303. RUN_TEST (COleActivationTest);
  304. RUN_TEST (CFileMonikerStorageBindTest);
  305. RUN_TEST (CFileMonikerObjBindTest);
  306. RUN_TEST (CROTTest);
  307. RUN_TEST (COlePropertyTest);
  308. RUN_TEST (COleMarshalTest);
  309. RUN_TEST (CRpcTest);
  310. RUN_TEST (CRpcTest2);
  311. RUN_TEST (CNestTest);
  312. RUN_TEST (CQueryInterfaceTest);
  313. RUN_TEST (CApiTest);
  314. RUN_TEST (CCGPSTest);
  315. RUN_TEST (COleAllocTest);
  316. RUN_TEST (CGuidCompareTest);
  317. RUN_TEST (CFileIOTest);
  318. RUN_TEST (CStorageTest);
  319. RUN_TEST (CNestedStorageTest);
  320. RUN_TEST (CStorageParserTest);
  321. //Upper layer tests
  322. RUN_TEST (CCreateTest);
  323. RUN_TEST (CCreateLinkTest);
  324. // RUN_TEST (CClipbrdTest);
  325. RUN_TEST (COleLoadTest);
  326. RUN_TEST (CIOLTest);
  327. RUN_TEST (COleCacheTest);
  328. return S_OK;
  329. }
  330. //+-------------------------------------------------------------------
  331. //
  332. // Function: RegistrySetup
  333. //
  334. // Synopsis: If the registry entries for this program are not set,
  335. // write them
  336. //
  337. // Note: This function uses all Ascii characters and character
  338. // arithmatic because it has to run on NT and Chicago.
  339. //
  340. // History: 16 Dec 94 AlexMit Created
  341. //
  342. //--------------------------------------------------------------------
  343. BOOL RegistrySetup()
  344. {
  345. char value[REGISTRY_ENTRY_LEN];
  346. LONG value_size;
  347. LONG result;
  348. char directory[MAX_PATH];
  349. char *appname;
  350. BOOL success = FALSE;
  351. // Write constant entries.
  352. for (int i = 0; REG_CONST_KEY[i].key[0] != '\0'; i++)
  353. {
  354. result = RegSetValueA(
  355. HKEY_CLASSES_ROOT,
  356. REG_CONST_KEY[i].key,
  357. REG_SZ,
  358. REG_CONST_KEY[i].value,
  359. strlen(REG_CONST_KEY[i].value) );
  360. if (result != ERROR_SUCCESS)
  361. goto cleanup;
  362. }
  363. // Compute the path to the application.
  364. result = GetFullPathNameA("benchmrk", sizeof(directory), directory, &appname);
  365. if (result == 0)
  366. goto cleanup;
  367. // Add the path to all the dll and exe entries.
  368. for (i = 0; REG_EXE_KEY[i].key[0] != '\0'; i++)
  369. {
  370. // Verify that the path will fit in the buffer and compute the path
  371. // to the next executable.
  372. if (strlen(REG_EXE_KEY[i].value) >=
  373. (ULONG)(MAX_PATH - (appname - directory)))
  374. goto cleanup;
  375. strcpy(appname, REG_EXE_KEY[i].value);
  376. // Write the next entry.
  377. result = RegSetValueA(
  378. HKEY_CLASSES_ROOT,
  379. REG_EXE_KEY[i].key,
  380. REG_SZ,
  381. directory,
  382. strlen(directory));
  383. if (result != ERROR_SUCCESS)
  384. goto cleanup;
  385. }
  386. success = TRUE;
  387. cleanup:
  388. return success;
  389. }
  390. //+-------------------------------------------------------------------
  391. //
  392. // Function: WinMain
  393. //
  394. // Synopsis: Program entry point, starts benchmark driver
  395. //
  396. // History: 30-June-93 t-martig Created
  397. //
  398. //--------------------------------------------------------------------
  399. int APIENTRY WinMain(
  400. HINSTANCE hInstance,
  401. HINSTANCE hPrevInstance,
  402. LPSTR lpCmdLine,
  403. int nCmdShow)
  404. {
  405. CBenchMarkDriver driver;
  406. if (!_stricmp(lpCmdLine, "/r") || !_stricmp(lpCmdLine, "-r"))
  407. {
  408. if (!RegistrySetup())
  409. {
  410. printf("Registry Updated\n");
  411. return 0;
  412. }
  413. else
  414. {
  415. printf("Registry Update Failed\n");
  416. return 1;
  417. }
  418. }
  419. driver.Run (lpCmdLine);
  420. return 0;
  421. }
  422.