Commit 717b1307 authored by legoc's avatar legoc

Renamed stop test

parent 03837f48
......@@ -38,6 +38,14 @@ target_link_libraries(veryfast PUBLIC cameo zmq)
add_executable(testveryfast src/tests/TestVeryFast.cpp)
target_link_libraries(testveryfast PUBLIC cameo zmq)
add_executable(stop src/tests/Stop.cpp)
target_link_libraries(stop PUBLIC cameo zmq)
add_executable(teststop src/tests/TestStop.cpp)
target_link_libraries(teststop PUBLIC cameo zmq)
......@@ -82,11 +90,6 @@ target_link_libraries(testresult PUBLIC cameo zmq)
add_executable(teststartwithresult src/tests/TestStartWithResultApplication.cpp)
target_link_libraries(teststartwithresult PUBLIC cameo zmq)
add_executable(teststop src/tests/TestStopApplication.cpp)
target_link_libraries(teststop PUBLIC cameo zmq)
add_executable(teststartwithstop src/tests/TestStartWithStopApplication.cpp)
target_link_libraries(teststartwithstop PUBLIC cameo zmq)
add_executable(testerror src/tests/TestErrorApplication.cpp)
......
......@@ -134,7 +134,7 @@ public class TestSelector {
if (appName.equals("all")) {
apps.add("testsimplejava");
apps.add("testveryfastjava");
apps.add("startstopjava");
apps.add("teststopjava");
apps.add("startresjava");
apps.add("starterrorjava");
apps.add("startstoragejava");
......@@ -160,7 +160,7 @@ public class TestSelector {
else if (appName.equals("java")) {
apps.add("testsimplejava");
apps.add("testveryfastjava");
apps.add("startstopjava");
apps.add("teststopjava");
apps.add("startresjava");
apps.add("starterrorjava");
apps.add("startstoragejava");
......@@ -173,7 +173,7 @@ public class TestSelector {
else if (appName.equals("cpp")) {
apps.add("testsimplecpp");
apps.add("testveryfastcpp");
apps.add("startstopcpp");
apps.add("teststopcpp");
apps.add("startrescpp");
apps.add("starterrorcpp");
apps.add("startstoragecpp");
......@@ -185,6 +185,7 @@ public class TestSelector {
else if (appName.equals("python")) {
apps.add("testsimplepy");
apps.add("testveryfastpy");
apps.add("teststoppy");
}
else {
apps.add(appName);
......
......@@ -21,7 +21,7 @@ import java.util.Date;
import fr.ill.ics.cameo.Application;
public class TestStopApplication {
public class Stop {
public static boolean stopping = false;
......
......@@ -20,7 +20,7 @@ import fr.ill.ics.cameo.Application;
import fr.ill.ics.cameo.Server;
public class TestStartWithStopApplication {
public class TestStop {
public static void main(String[] args) {
......
......@@ -49,6 +49,13 @@
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestVeryFast"/>
</application>
<application name="stopjava" starting_time="0" stopping_time="2" output_stream="yes" multiple="yes" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.Stop"/>
</application>
<application name="teststopjava" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestStop"/>
</application>
......@@ -104,13 +111,7 @@
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestStartWithResultApplication"/>
</application>
<application name="stopjava" starting_time="0" stopping_time="2" output_stream="yes" multiple="yes" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestStopApplication"/>
</application>
<application name="startstopjava" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestStartWithStopApplication"/>
</application>
<application name="starterrorjava" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="java" args="-classpath cameo-tests-jzmq/target/cameo-tests-jzmq-full.jar fr.ill.ics.cameo.test.TestStartWithErrorApplication"/>
......@@ -202,6 +203,15 @@
<start executable="testveryfast"/>
</application>
<application name="stopcpp" starting_time="0" stopping_time="2" output_stream="yes" multiple="yes" restart="no">
<start executable="stop"/>
</application>
<application name="teststopcpp" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="teststop"/>
</application>
......@@ -254,14 +264,6 @@
<start executable="teststartwithresult"/>
</application>
<application name="stopcpp" starting_time="0" stopping_time="2" output_stream="yes" multiple="yes" restart="no">
<start executable="teststop"/>
</application>
<application name="startstopcpp" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="teststartwithstop"/>
</application>
<application name="starterrorcpp" starting_time="0" stopping_time="1" output_stream="yes" multiple="no" restart="no">
<start executable="teststartwitherror"/>
</application>
......@@ -364,11 +366,11 @@
<start executable="testveryfast.py"/>
</application>
<application name="teststoppy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="teststop.py"/>
</application>
<application name="startstoppy" starting_time="0" stopping_time="1" output_stream="yes" log_directory="logs" multiple="no" restart="no">
<start executable="startstop.py"/>
</application>
<!-- Test apps -->
......
......@@ -11,9 +11,8 @@ this.init(sys.argv)
server = this.getServer()
for i in range(numberOfTimes):
app = server.start("veryfastpy", 0)
state = app.waitFor()
print("Finished the application", app.getNameId(),
"with state", state,
"and code", app.getExitCode()
)
app = server.start("veryfastpy", 0)
state = app.waitFor()
print("Finished the application", app.getNameId(),
"with state", state,
"and code", app.getExitCode())
......@@ -11,20 +11,22 @@ this = cameopy.This
this.init(sys.argv)
server = this.getServer()
for i in range(numberOfTimes):
app = server.start("stopcpp", 0);
print("waiting 100ms...")
time.sleep(0.100)
print("stopping application", app.getNameId())
app.stop()
result = app.getResult()
# The variable result can be None
if result:
print("result", result)
else:
print("no result")
for i in range(numberOfTimes):
print("finished the application")
# Start the cpp app because handlers not supported in Python.
app = server.start("stopcpp", 0);
print("Waiting 100ms...")
time.sleep(0.100)
print("Stopping application", app.getNameId())
app.stop()
result = app.getResult()
# The variable result can be None.
if result:
print("Result", result)
else:
print("No result")
print("Finished the application")
......@@ -11,9 +11,8 @@ this.init(sys.argv)
server = this.getServer()
for i in range(numberOfTimes):
app = server.start("simplepy", 0)
state = app.waitFor()
print("Finished the application", app.getNameId(),
"with state", state,
"and code", app.getExitCode()
)
app = server.start("simplepy", 0)
state = app.waitFor()
print("Finished the application", app.getNameId(),
"with state", state,
"and code", app.getExitCode())
......@@ -24,20 +24,20 @@
using namespace std;
using namespace cameo;
struct StopData {
struct StopState {
bool stopping;
StopData() : stopping(false) {}
StopState() : stopping(false) {}
};
struct Stop {
shared_ptr<StopData> data;
shared_ptr<StopState> data;
Stop(shared_ptr<StopData> sharedData) : data(sharedData) {}
Stop(shared_ptr<StopState> sharedData) : data(sharedData) {}
void operator()() {
cout << "stop handler executed" << endl;
cout << "Stop handler executed" << endl;
data->stopping = true;
}
};
......@@ -48,26 +48,22 @@ int main(int argc, char *argv[]) {
// New block to ensure cameo objects are terminated before the application.
{
if (application::This::isAvailable()) {
cout << "connected" << endl;
}
application::This::setRunning();
// Define an object StopData that is shared with the handler.
shared_ptr<StopData> data(new StopData());
application::This::handleStop(Stop(data));
// Define an object StopState that is shared with the handler.
shared_ptr<StopState> state(new StopState());
application::This::handleStop(Stop(state));
int i = 0;
while (!data->stopping) {
cout << "waiting " << i << "..." << endl;
while (!state->stopping) {
cout << "Waiting " << i << "..." << endl;
this_thread::sleep_for(chrono::milliseconds(100));
i++;
}
application::This::setResult("2189");
cout << "finished the application" << endl;
cout << "Finished the application" << endl;
}
return 0;
......
......@@ -26,7 +26,7 @@ using namespace cameo;
struct StateHandler {
void operator()(application::State state) {
cout << "received state " << application::toString(state) << endl;
cout << "Received state " << application::toString(state) << endl;
}
};
......@@ -44,32 +44,28 @@ int main(int argc, char *argv[]) {
{
Server& server = application::This::getServer();
if (application::This::isAvailable() && server.isAvailable()) {
cout << "connected" << endl;
}
// loop the number of times.
for (int i = 0; i < numberOfTimes; ++i) {
unique_ptr<application::Instance> stopApplication = server.start("stopcpp");
cout << "waiting 100ms..." << endl;
cout << "Waiting 100ms..." << endl;
this_thread::sleep_for(chrono::milliseconds(100));
cout << "stopping application " << stopApplication->getNameId() << endl;
cout << "Stopping application " << stopApplication->getNameId() << endl;
stopApplication->stop();
//stopApplication->waitFor(StateHandler());
optional<string> result = stopApplication->getResult();
if (result.has_value()) {
cout << "stop application returned " << result.value() << endl;
cout << "Stop application returned " << result.value() << endl;
} else {
cout << "stop application has no result" << endl;
cout << "Stop application has no result" << endl;
}
cout << "finished the application " << *stopApplication << endl;
cout << "Finished the application " << *stopApplication << endl;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment