dfhack/tools/supported/suspendtest.cpp

62 lines
1.4 KiB
C++

// Test suspend/resume
#include <iostream>
#include <climits>
#include <vector>
#include <ctime>
#include <string>
using namespace std;
2010-05-25 22:48:23 -06:00
#include <DFHack.h>
#include <dfhack/extra/termutil.h>
int main (void)
{
bool temporary_terminal = TemporaryTerminal();
string blah;
2010-05-23 15:06:10 -06:00
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
try
{
2010-05-23 15:06:10 -06:00
DF = DFMgr.getSingleContext();
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
if(temporary_terminal)
cin.ignore();
return 1;
}
cout << "Attached, DF should be suspended now" << endl;
getline(cin, blah);
2010-05-23 15:06:10 -06:00
DF->Resume();
cout << "Resumed, DF should be running" << endl;
getline(cin, blah);
2010-05-23 15:06:10 -06:00
DF->Suspend();
cout << "Suspended, DF should be suspended now" << endl;
getline(cin, blah);
2010-05-23 15:06:10 -06:00
DF->Resume();
cout << "Resumed, testing ForceResume. Suspend using SysInternals Process Explorer" << endl;
getline(cin, blah);
2009-11-18 18:48:18 -07:00
2010-05-23 15:06:10 -06:00
DF->ForceResume();
cout << "ForceResumed. DF should be running." << endl;
getline(cin, blah);
2009-11-18 18:48:18 -07:00
2010-05-23 15:06:10 -06:00
if(!DF->Detach())
{
cerr << "Can't detach from DF" << endl;
if(temporary_terminal)
cin.ignore();
return 1;
}
cout << "Detached, DF should be running again" << endl;
if(temporary_terminal)
getline(cin, blah);
return 0;
}