From: Martin Quinson Date: Wed, 3 Feb 2016 07:34:29 +0000 (+0100) Subject: Cleanup in this test case X-Git-Tag: v3_13~995 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3af15ddde74b1f2e6d0f78102c48271259c3c178 Cleanup in this test case --- diff --git a/teshsuite/java/sleep_host_off/CMakeLists.txt b/teshsuite/java/sleep_host_off/CMakeLists.txt index 18c2174534..90ba170b7e 100644 --- a/teshsuite/java/sleep_host_off/CMakeLists.txt +++ b/teshsuite/java/sleep_host_off/CMakeLists.txt @@ -1,6 +1,5 @@ set(example java_sleep_host_off) set(sources - ${CMAKE_CURRENT_SOURCE_DIR}/Main.java ${CMAKE_CURRENT_SOURCE_DIR}/SleepHostOff.java ) diff --git a/teshsuite/java/sleep_host_off/Main.java b/teshsuite/java/sleep_host_off/Main.java deleted file mode 100644 index 3cc4cea056..0000000000 --- a/teshsuite/java/sleep_host_off/Main.java +++ /dev/null @@ -1,30 +0,0 @@ -package sleep_host_off; - -import org.simgrid.msg.Host; -import org.simgrid.msg.HostNotFoundException; -import org.simgrid.msg.Msg; -import org.simgrid.msg.NativeException; - -public class Main { - - public static void main(String[] args) throws NativeException { - /* Init. internal values */ - Msg.init(args); - - if (args.length < 2) { - Msg.info("Usage : Main platform_file.xml dployment_file.xml"); - System.exit(1); - } - - /* construct the platform and deploy the application */ - Msg.createEnvironment(args[0]); - Msg.deployApplication(args[1]); - - try { - Msg.run(); - } catch (Exception e){ - System.out.println("Bye bye the program crashes !"); - } - - } -} diff --git a/teshsuite/java/sleep_host_off/SleepHostOff.java b/teshsuite/java/sleep_host_off/SleepHostOff.java index 1d60cad739..cebf7afe77 100644 --- a/teshsuite/java/sleep_host_off/SleepHostOff.java +++ b/teshsuite/java/sleep_host_off/SleepHostOff.java @@ -14,42 +14,63 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; -public class SleepHostOff extends Process{ - public static Host jupiter = null; - - public SleepHostOff(Host host, String name, String[]args) { - super(host,name,args); - } - - public void main(String[] strings) throws MsgException { - - try { - jupiter = Host.getByName("Jupiter"); - } catch (HostNotFoundException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } - - Msg.info("**** **** **** ***** ***** Test Sleep ***** ***** **** **** ****"); - Msg.info("Test sleep: Create a process on Jupiter, the process simply make periodic sleep, turn off Jupiter"); - new Process(jupiter, "sleep", null) { - public void main(String[] args) { - while (true) { - Msg.info("I'm not dead"); - try { - Process.sleep(10); - } catch (HostFailureException e) { - Msg.info("catch HostException: "+e.getLocalizedMessage()); - break; //Break is needed to finalize the endless loop - } - } - } - }.start(); - - Process.sleep(20); - Msg.info("Stop Jupiter"); - jupiter.off(); - Msg.info("Jupiter has been stopped"); - Process.sleep(300); - Msg.info("Test sleep seems ok, cool !(number of Process : " + Process.getCount() + ", it should be 1 (i.e. the Test one))\n"); - } +class Sleeper extends Process { + public Sleeper(Host host, String name, String[] args) { + super(host,name,args); + } + public void main(String[] args) { + while (true) { + Msg.info("I'm not dead"); + try { + Process.sleep(10); + } catch (HostFailureException e) { + Msg.info("catch HostException: "+e.getLocalizedMessage()); + break; //Break is needed to finalize the endless loop + } + } + } +} + +class TestRunner extends Process { + + public TestRunner(Host host, String name, String[] args) { + super(host,name,args); + } + + public void main(String[] strings) throws MsgException { + Host host = Host.all()[1]; + + + Msg.info("**** **** **** ***** ***** Test Sleep ***** ***** **** **** ****"); + Msg.info("Test sleep: Create a process on "+host.getName()+" that simply make periodic sleep, turn off "+host.getName()); + new Sleeper(host, "Sleeper", null).start(); + + waitFor(0.02); + Msg.info("Stop "+host.getName()); + host.off(); + Msg.info(host.getName()+" has been stopped"); + waitFor(0.3); + Msg.info("Test sleep seems ok, cool! (number of Process : " + Process.getCount() + ", it should be 1 (i.e. the Test one))"); + } +} + +public class SleepHostOff { + + public static void main(String[] args) throws Exception { + /* Init. internal values */ + Msg.init(args); + + if (args.length < 1) { + Msg.info("Usage: java -cp simgrid.jar:. sleep_host_off.SleepHostOff "); + System.exit(1); + } + + /* construct the platform and deploy the application */ + Msg.createEnvironment(args[0]); + + Host[] hosts = Host.all(); + new TestRunner(hosts[0], "TestRunner", null).start(); + + Msg.run(); + } } diff --git a/teshsuite/java/sleep_host_off/sleep_host_off.tesh b/teshsuite/java/sleep_host_off/sleep_host_off.tesh index 5e77e1749f..c371d7fb40 100644 --- a/teshsuite/java/sleep_host_off/sleep_host_off.tesh +++ b/teshsuite/java/sleep_host_off/sleep_host_off.tesh @@ -1,13 +1,12 @@ -$ java -classpath ${classpath:=.} sleep_host_off.Main ${srcdir:=.}/../../examples/platforms/small_platform.xml ${srcdir:=.}/sleep_host_off/sleep_host_off_d.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" +$ java -classpath ${classpath:=.} sleep_host_off.SleepHostOff ${srcdir:=.}/../../examples/platforms/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (0:maestro@) Using regular java threads. -> [ 0.000000] (1:sleep_host_off.SleepHostOff@Tremblay) **** **** **** ***** ***** Test Sleep ***** ***** **** **** **** -> [ 0.000000] (1:sleep_host_off.SleepHostOff@Tremblay) Test sleep: Create a process on Jupiter, the process simply make periodic sleep, turn off Jupiter -> [ 0.000000] (2:sleep@Jupiter) I'm not dead -> [ 0.010000] (2:sleep@Jupiter) I'm not dead -> [ 0.020000] (1:sleep_host_off.SleepHostOff@Tremblay) Stop Jupiter -> [ 0.020000] (2:sleep@Jupiter) I'm not dead -> [ 0.020000] (2:sleep@Jupiter) catch HostException: Host Failure (null) -> [ 0.020000] (1:sleep_host_off.SleepHostOff@Tremblay) Jupiter has been stopped -> [ 0.320000] (1:sleep_host_off.SleepHostOff@Tremblay) Test sleep seems ok, cool !(number of Process : 1, it should be 1 (i.e. the Test one)) -> +> [ 0.000000] (1:TestRunner@Fafard) **** **** **** ***** ***** Test Sleep ***** ***** **** **** **** +> [ 0.000000] (1:TestRunner@Fafard) Test sleep: Create a process on Tremblay that simply make periodic sleep, turn off Tremblay +> [ 0.000000] (2:Sleeper@Tremblay) I'm not dead +> [ 0.010000] (2:Sleeper@Tremblay) I'm not dead +> [ 0.020000] (1:TestRunner@Fafard) Stop Tremblay +> [ 0.020000] (2:Sleeper@Tremblay) I'm not dead +> [ 0.020000] (2:Sleeper@Tremblay) catch HostException: Host Failure (null) +> [ 0.020000] (1:TestRunner@Fafard) Tremblay has been stopped +> [ 0.320000] (1:TestRunner@Fafard) Test sleep seems ok, cool! (number of Process : 1, it should be 1 (i.e. the Test one)) > [ 0.320000] (0:maestro@) MSG_main finished; Cleaning up the simulation...