mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 02:22:57 +01:00
add tests for Process::isRunning
This commit is contained in:
parent
af44951e77
commit
04116d6593
@ -92,6 +92,35 @@ void ProcessTest::testLaunchRedirectIn()
|
||||
#endif // !defined(_WIN32_WCE)
|
||||
}
|
||||
|
||||
void ProcessTest::testIsRunning()
|
||||
{
|
||||
std::string name("TestApp");
|
||||
std::string cmd;
|
||||
#if defined(_DEBUG)
|
||||
name += "d";
|
||||
#endif
|
||||
|
||||
#if defined(POCO_OS_FAMILY_UNIX)
|
||||
cmd = "./";
|
||||
cmd += name;
|
||||
#else
|
||||
cmd = name;
|
||||
#endif
|
||||
|
||||
std::vector<std::string> args;
|
||||
args.push_back("-count");
|
||||
Pipe inPipe;
|
||||
ProcessHandle ph = Process::launch(cmd, args, &inPipe, 0, 0);
|
||||
Process::PID id = ph.id();
|
||||
assert (Process::isRunning(ph));
|
||||
assert (Process::isRunning(id));
|
||||
PipeOutputStream ostr(inPipe);
|
||||
ostr << std::string(100, 'x');
|
||||
ostr.close();
|
||||
int rc = ph.wait();
|
||||
assert (!Process::isRunning(ph));
|
||||
assert (!Process::isRunning(id));
|
||||
}
|
||||
|
||||
void ProcessTest::testLaunchRedirectOut()
|
||||
{
|
||||
@ -175,6 +204,7 @@ CppUnit::Test* ProcessTest::suite()
|
||||
CppUnit_addTest(pSuite, ProcessTest, testLaunchRedirectIn);
|
||||
CppUnit_addTest(pSuite, ProcessTest, testLaunchRedirectOut);
|
||||
CppUnit_addTest(pSuite, ProcessTest, testLaunchEnv);
|
||||
CppUnit_addTest(pSuite, ProcessTest, testIsRunning);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
void testLaunchRedirectIn();
|
||||
void testLaunchRedirectOut();
|
||||
void testLaunchEnv();
|
||||
void testIsRunning();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
Loading…
Reference in New Issue
Block a user