1 | // replay.cpp : Defines the entry point for the console application.
|
---|
2 | //
|
---|
3 |
|
---|
4 | #include "stdafx.h"
|
---|
5 |
|
---|
6 | #include "LogParser.h"
|
---|
7 | #include "SAXContentHandlerImpl.h"
|
---|
8 | #include <iostream>
|
---|
9 |
|
---|
10 | int _tmain(int argc, _TCHAR* argv[])
|
---|
11 | {
|
---|
12 | if (argc<4)
|
---|
13 | {
|
---|
14 | std::wcout << "Usage: " << argv[0] << "<replayfile> <applicationundertest> [<resultfile>] [<useDefaultDelay>] [<waitAfterFinish>]" << std::endl;
|
---|
15 | return 0;
|
---|
16 | }
|
---|
17 | TCHAR * replayfile = argv[1];
|
---|
18 | TCHAR * appUnderTest = argv[2];
|
---|
19 | TCHAR * resultfile = NULL;
|
---|
20 | bool useDefaultDelay = true;
|
---|
21 | int wait = 1;
|
---|
22 | if( argc>=4 ) {
|
---|
23 | TCHAR * resultfile = argv[3];
|
---|
24 | }
|
---|
25 | if( argc>=5 ) {
|
---|
26 | useDefaultDelay = (bool) _tstoi(argv[4]);
|
---|
27 | }
|
---|
28 | if( argc>=6 ) {
|
---|
29 | wait = _tstoi(argv[5]);
|
---|
30 | }
|
---|
31 |
|
---|
32 | // initialize COM library for the current thread
|
---|
33 | CoInitialize(NULL);
|
---|
34 | MSXML2::ISAXXMLReader* pXMLReader = NULL;
|
---|
35 |
|
---|
36 | // create an instance of the XML reader
|
---|
37 | HRESULT hr = CoCreateInstance(
|
---|
38 | __uuidof(MSXML2::SAXXMLReader),
|
---|
39 | NULL,
|
---|
40 | CLSCTX_ALL,
|
---|
41 | __uuidof(MSXML2::ISAXXMLReader),
|
---|
42 | (void **)&pXMLReader);
|
---|
43 |
|
---|
44 | if( !FAILED(hr) ) {
|
---|
45 | TestResults results(replayfile);
|
---|
46 | std::wcout << L"replaying sessions in " << argv[1] << std::endl;
|
---|
47 | LogParser * parser = new LogParser(appUnderTest, 5000, &results, useDefaultDelay);
|
---|
48 | pXMLReader->putContentHandler(parser);
|
---|
49 | hr = pXMLReader->parseURL(replayfile);
|
---|
50 | pXMLReader->Release();
|
---|
51 | std::wcout << L"================================================" << std::endl;
|
---|
52 | std::wcout << L"replay completed" << std::endl;
|
---|
53 | if( resultfile!=NULL ) {
|
---|
54 | results.write(resultfile);
|
---|
55 | std::wcout << L"results written to " << resultfile << std::endl;
|
---|
56 | }
|
---|
57 | }
|
---|
58 |
|
---|
59 | CoUninitialize();
|
---|
60 |
|
---|
61 | if( wait!=0 ) {
|
---|
62 | std::wcout << L"press enter to exit ...";
|
---|
63 | getchar();
|
---|
64 | }
|
---|
65 |
|
---|
66 | return 0;
|
---|
67 | }
|
---|
68 |
|
---|