From: Paul Bédaride Date: Tue, 29 Jul 2014 13:08:03 +0000 (+0200) Subject: Add java teshsuite for sleep_host_off X-Git-Tag: v3_12~850^2~17 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a89d5cc048eff839141ea5178e9156f1e135a03d Add java teshsuite for sleep_host_off --- diff --git a/buildtools/Cmake/AddTests.cmake b/buildtools/Cmake/AddTests.cmake index c3b7424109..5700844fc7 100644 --- a/buildtools/Cmake/AddTests.cmake +++ b/buildtools/Cmake/AddTests.cmake @@ -84,6 +84,15 @@ IF(NOT enable_memcheck) ADD_TESH(tesh-self-catch-signal --cd "${CMAKE_BINARY_DIR}/bin" ${CMAKE_HOME_DIRECTORY}/tools/tesh/catch-signal.tesh) ENDIF() +IF(enable_java) + IF(WIN32) + SET(TESH_CLASSPATH "${CMAKE_BINARY_DIR}/teshsuite/java/\;${SIMGRID_FULL_JAR}") + STRING(REPLACE "\;" "§" TESH_CLASSPATH "${TESH_CLASSPATH}") + ELSE() + SET(TESH_CLASSPATH "${CMAKE_BINARY_DIR}/teshsuite/java/:${SIMGRID_FULL_JAR}") + ENDIF() + ADD_TESH(tesh-java-sleep-host-off --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java ${CMAKE_HOME_DIRECTORY}/teshsuite/java/sleep_host_off/sleep_host_off.tesh) +ENDIF() ### GENERIC ### # BEGIN TESH TESTS diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index c4ebec6b33..9a51f2c865 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -1039,6 +1039,8 @@ set(EXAMPLES_CMAKEFILES_TXT set(TESHSUITE_CMAKEFILES_TXT teshsuite/bug-17132/CMakeLists.txt + teshsuite/java/CMakeLists.txt + teshsuite/java/sleep_host_off/CMakeLists.txt teshsuite/mc/CMakeLists.txt teshsuite/mc/dwarf/CMakeLists.txt teshsuite/mc/dwarf_expression/CMakeLists.txt diff --git a/buildtools/Cmake/MakeExe.cmake b/buildtools/Cmake/MakeExe.cmake index 27061c8ba9..7c2097f115 100644 --- a/buildtools/Cmake/MakeExe.cmake +++ b/buildtools/Cmake/MakeExe.cmake @@ -81,6 +81,9 @@ add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/smpi/energy/f90) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/xbt) +add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/java) +add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/java/sleep_host_off) + add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/mc) add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/mc/dwarf) add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/mc/dwarf_expression) diff --git a/teshsuite/java/CMakeLists.txt b/teshsuite/java/CMakeLists.txt new file mode 100644 index 0000000000..50284bc907 --- /dev/null +++ b/teshsuite/java/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 2.6) + +set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}") + +set(xml_files + ${xml_files} + PARENT_SCOPE + ) +set(txt_files + ${txt_files} + PARENT_SCOPE + ) diff --git a/teshsuite/java/sleep_host_off/CMakeLists.txt b/teshsuite/java/sleep_host_off/CMakeLists.txt new file mode 100644 index 0000000000..dceda482bd --- /dev/null +++ b/teshsuite/java/sleep_host_off/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 2.6) + +set(example java_sleep_host_off) +set(sources + ${CMAKE_CURRENT_SOURCE_DIR}/Main.java + ${CMAKE_CURRENT_SOURCE_DIR}/SleepHostOff.java + ) + +if(enable_java) + add_custom_command( + COMMENT "Building ${example}..." + OUTPUT ${example}_compiled + DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR} + COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR} + -d ${CMAKE_CURRENT_BINARY_DIR}/.. ${sources} + COMMAND ${CMAKE_COMMAND} -E remove ${example}_compiled + COMMAND ${CMAKE_COMMAND} -E touch ${example}_compiled + ) + add_custom_target(${example} ALL DEPENDS ${example}_compiled) +endif() + +set(tesh_files + ${tesh_files} + ${CMAKE_CURRENT_SOURCE_DIR}/sleep_host_off.tesh + PARENT_SCOPE + ) +set(xml_files + ${xml_files} + ${CMAKE_CURRENT_SOURCE_DIR}/sleep_host_off_d.xml + PARENT_SCOPE + ) +set(examples_src + ${examples_src} + ${sources} + PARENT_SCOPE + ) +set(bin_files + ${bin_files} + PARENT_SCOPE + ) +set(txt_files + ${txt_files} + ${CMAKE_CURRENT_SOURCE_DIR}/README + PARENT_SCOPE + ) diff --git a/teshsuite/java/sleep_host_off/Main.java b/teshsuite/java/sleep_host_off/Main.java new file mode 100644 index 0000000000..3cc4cea056 --- /dev/null +++ b/teshsuite/java/sleep_host_off/Main.java @@ -0,0 +1,30 @@ +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 new file mode 100644 index 0000000000..a18c9b27d5 --- /dev/null +++ b/teshsuite/java/sleep_host_off/SleepHostOff.java @@ -0,0 +1,55 @@ +/* Copyright (c) 2014. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +package sleep_host_off; + +import org.simgrid.msg.*; +import org.simgrid.msg.Process; +import org.simgrid.trace.Trace; + +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.printStackTrace(); + } + } + } + }.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"); + } +} diff --git a/teshsuite/java/sleep_host_off/sleep_host_off.tesh b/teshsuite/java/sleep_host_off/sleep_host_off.tesh new file mode 100644 index 0000000000..a1d464e552 --- /dev/null +++ b/teshsuite/java/sleep_host_off/sleep_host_off.tesh @@ -0,0 +1,2 @@ +$ 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" +> diff --git a/teshsuite/java/sleep_host_off/sleep_host_off_d.xml b/teshsuite/java/sleep_host_off/sleep_host_off_d.xml new file mode 100644 index 0000000000..96fcb1c9c6 --- /dev/null +++ b/teshsuite/java/sleep_host_off/sleep_host_off_d.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/teshsuite/msg/host_on_off_processes/host_on_off_processes.c b/teshsuite/msg/host_on_off_processes/host_on_off_processes.c index 12975d2b3a..a9c9b78a7e 100644 --- a/teshsuite/msg/host_on_off_processes/host_on_off_processes.c +++ b/teshsuite/msg/host_on_off_processes/host_on_off_processes.c @@ -120,7 +120,34 @@ int test_launcher(int argc, char *argv[]) test =6; if (xbt_dynar_member(tests, &test)){ + /*XBT_INFO("Test 5: Turn on Jupiter, assign a VM on Jupiter, launch a process inside the VM, and turn off the node"); + // Create VM0 + int dpRate = 70; + msg_vm_t vm0; +MSG_vm_create (msg_host_t ind_pm, const char *name, int ncpus, int ramsize, int net_cap, char *disk_path, int disksize, int mig_netspeed, int dp_intensity) + vm0 = MSG_vm_create_core(jupiter, "vm0"); + params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes + MSG_host_set_params(vm0, ¶ms); + MSG_vm_start(vm0); + XVM vm0 = null; + vm0 = new XVM( + host1, + "vm0", + 1, // Nb of vcpu + 2048, // Ramsize, + 125, // Net Bandwidth + null, //VM disk image + -1, //size of disk image, + 125, // Net bandwidth, + dpRate // Memory intensity + ); + vm0.start(); + vm0.setLoad(90); + + host1.off(); + Msg.info("Test 5 is also weird: when the node host1 is turned off once again, the VM and its daemon are not killed." + + " However, the issue regarding the shutdown of hosted VMs can be seen a feature not a bug ;)\n");*/ } test = 7; @@ -141,7 +168,7 @@ int test_launcher(int argc, char *argv[]) return 0; } -// adsein: Is this really a daemon ? it ran only one task ? I just added a stupid loop +// adsein: Is this really a daemon ? it ran only one task ? I just added a stupid loop int process_daemon(int argc, char *argv[]) { msg_task_t task = NULL;