source: trunk/MFCtooling/replay/replay.cpp @ 104

Last change on this file since 104 was 104, checked in by sherbold, 13 years ago
  • improved output in case of wrong startup parameters
  • parameter for application under test now mandatory
  • automatically closes application under test at the end of a session in case it is still open

+ support for multiple sessions in one replay file

File size: 1.5 KB
Line 
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
10int _tmain(int argc, _TCHAR* argv[])
11{
12        if (argc<3)
13        {
14                std::wcout << "Usage: " << argv[0] << "<replayfile> <applicationundertest>" << std::endl;
15                return 0;
16        }
17
18        // execute application to be replayed
19        /*if (argc>2) {
20                std::wcout << "executing " << argv[2] << std::endl;
21                PROCESS_INFORMATION pi;
22                STARTUPINFO si;
23                ZeroMemory(&pi, sizeof(pi));
24                ZeroMemory(&si, sizeof(si));
25                CreateProcess(NULL, argv[2], NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
26                Sleep(10000);
27        }*/
28
29
30        // initialize COM library for the current thread
31        CoInitialize(NULL);
32        MSXML2::ISAXXMLReader* pXMLReader = NULL;
33
34        // create an instance of the XML reader
35        HRESULT hr = CoCreateInstance(
36                __uuidof(MSXML2::SAXXMLReader),
37                NULL,
38                CLSCTX_ALL,
39                __uuidof(MSXML2::ISAXXMLReader),
40                (void **)&pXMLReader);
41
42        if( !FAILED(hr) ) {
43                std::wcout << L"replaying sessions in " << argv[1] << std::endl;
44                LogParser * parser = new LogParser(argv[2], 5000, true);
45                pXMLReader->putContentHandler(parser);
46                hr = pXMLReader->parseURL(argv[1]);
47                pXMLReader->Release();
48                std::wcout << L"================================================" << std::endl;
49                std::wcout << L"replay completed" << std::endl;
50        }
51
52        CoUninitialize();
53
54        std::wcout << L"press enter to exit ...";
55        getchar();
56
57        return 0;
58}
59
Note: See TracBrowser for help on using the repository browser.