From: Frederic Suter Date: Mon, 29 Feb 2016 22:37:52 +0000 (+0100) Subject: a few more cosmetics X-Git-Tag: v3_13~618 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/59754cd381aabf278305badcfefbe45cd934ef6c a few more cosmetics --- diff --git a/teshsuite/java/semaphore/SemaphoreGC.java b/teshsuite/java/semaphore/SemaphoreGC.java index ec1b6aaf6e..d740251a98 100644 --- a/teshsuite/java/semaphore/SemaphoreGC.java +++ b/teshsuite/java/semaphore/SemaphoreGC.java @@ -10,47 +10,38 @@ package semaphore; 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; class SemCreator extends Process { - Semaphore sem; - - SemCreator(Host h, String n){ - super(h, n); - } - - public void main(String[] args) throws MsgException{ - int j; - Msg.info("Creating 50 new Semaphores, yielding and triggering a GC after each"); - for(j = 1; j <= 50; j++) { - sem = new Semaphore(0); - waitFor(10); - System.gc(); - } - Msg.info("It worked, we survived. The test is passed."); - } + Semaphore sem; + + SemCreator(Host h, String n){ + super(h, n); + } + + public void main(String[] args) throws MsgException{ + int j; + Msg.info("Creating 50 new Semaphores, yielding and triggering a GC after each"); + for(j = 1; j <= 50; j++) { + sem = new Semaphore(0); + waitFor(10); + System.gc(); + } + Msg.info("It worked, we survived. The test is passed."); + } } - public class SemaphoreGC { - public static void main(String[] args) throws Exception { - - Msg.init(args); - if (args.length < 1) { - Msg.info("Usage: java -cp simgrid.jar:. semaphore.SemaphoreGC "); - System.exit(1); - } - Msg.createEnvironment(args[0]); - - Host[] hosts = Host.all(); - new SemCreator(hosts[0], "SemCreator").start(); - - Msg.run(); - } - + public static void main(String[] args) throws Exception { + Msg.init(args); + if (args.length < 1) { + Msg.info("Usage: java -cp simgrid.jar:. semaphore.SemaphoreGC "); + System.exit(1); + } + Msg.createEnvironment(args[0]); + + Host[] hosts = Host.all(); + new SemCreator(hosts[0], "SemCreator").start(); + + Msg.run(); + } } diff --git a/teshsuite/java/sleep_host_off/SleepHostOff.java b/teshsuite/java/sleep_host_off/SleepHostOff.java index cebf7afe77..0b15188846 100644 --- a/teshsuite/java/sleep_host_off/SleepHostOff.java +++ b/teshsuite/java/sleep_host_off/SleepHostOff.java @@ -7,70 +7,61 @@ 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; 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 - } - } - } + 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 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 { + Msg.init(args); - 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); - } + 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]); + Msg.createEnvironment(args[0]); - Host[] hosts = Host.all(); - new TestRunner(hosts[0], "TestRunner", null).start(); + Host[] hosts = Host.all(); + new TestRunner(hosts[0], "TestRunner", null).start(); - Msg.run(); - } + Msg.run(); + } } diff --git a/teshsuite/xbt/heap_bench/heap_bench.c b/teshsuite/xbt/heap_bench/heap_bench.c index 9c9827c560..ce3d7fc0e9 100644 --- a/teshsuite/xbt/heap_bench/heap_bench.c +++ b/teshsuite/xbt/heap_bench/heap_bench.c @@ -6,7 +6,6 @@ /* 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. */ -#include #include #include @@ -15,19 +14,10 @@ #define MAX_TEST 1000000 -int compare_double(const void *a, const void *b); - -void test_heap_validity(int size); -void test_heap_mean_operation(int size); -void test_reset_heap(xbt_heap_t * heap, int size); - - -int compare_double(const void *a, const void *b) +static int compare_double(const void *a, const void *b) { - double pa, pb; - - pa = *((double *) a); - pb = *((double *) b); + double pa = *((double *) a); + double pb = *((double *) b); if (pa > pb) return 1; @@ -36,11 +26,10 @@ int compare_double(const void *a, const void *b) return -1; } -void test_heap_validity(int size) +static void test_heap_validity(int size) { xbt_heap_t heap = xbt_heap_new(size, NULL); double *tab = xbt_new0(double, size); - int i; for (i = 0; i < size; i++) { @@ -63,47 +52,41 @@ void test_heap_validity(int size) printf("Validity test complete!\n"); } -void test_heap_mean_operation(int size) +static void test_heap_mean_operation(int size) { xbt_heap_t heap = xbt_heap_new(size, NULL); - double val; - double date = 0; - int i, j; - date = xbt_os_time() * 1000000; - for (i = 0; i < size; i++) + double date = xbt_os_time() * 1000000; + for (int i = 0; i < size; i++) xbt_heap_push(heap, NULL, (10.0 * rand() / (RAND_MAX + 1.0))); date = xbt_os_time() * 1000000 - date; printf("Creation time %d size heap : %g\n", size, date); date = xbt_os_time() * 1000000; - for (j = 0; j < MAX_TEST; j++) { + for (int j = 0; j < MAX_TEST; j++) { if (!(j % size) && j) test_reset_heap(&heap, size); - val = xbt_heap_maxkey(heap); + double val = xbt_heap_maxkey(heap); xbt_heap_pop(heap); xbt_heap_push(heap, NULL, 3.0 * val); } date = xbt_os_time() * 1000000 - date; - printf("Mean access time for a %d size heap : %g\n", size, - date * 1.0 / (MAX_TEST + 0.0)); + printf("Mean access time for a %d size heap : %g\n", size, date * 1.0 / (MAX_TEST + 0.0)); xbt_heap_free(heap); } -void test_reset_heap(xbt_heap_t * heap, int size) +static void test_reset_heap(xbt_heap_t * heap, int size) { - int i; xbt_heap_free(*heap); *heap = xbt_heap_new(size, NULL); - for (i = 0; i < size; i++) { + for (int i = 0; i < size; i++) { xbt_heap_push(*heap, NULL, (10.0 * rand() / (RAND_MAX + 1.0))); } - } int main(int argc, char **argv) diff --git a/teshsuite/xbt/log_large/log_large_test.c b/teshsuite/xbt/log_large/log_large_test.c index 847a57c123..9eeec686d9 100644 --- a/teshsuite/xbt/log_large/log_large_test.c +++ b/teshsuite/xbt/log_large/log_large_test.c @@ -10,30 +10,19 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logs of this example"); - int main(int argc, char *argv[]) { char *tmp = bprintf("\n%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s", - 1, - ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", - 2, - ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", - 3, - ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", - 4, - ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", - 5, - ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", - 6, - ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", - 7, - ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", - 8, - ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", - 9, - ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", - 0, - ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n"); + 1, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", + 2, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", + 3, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", + 4, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", + 5, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", + 6, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", + 7, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", + 8, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", + 9, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n", + 0, ".........1.........2.........3.........4.........5.........6.........7.........8.........9.........0\n"); xbt_init(&argc, argv); diff --git a/teshsuite/xbt/log_usage/log_usage.c b/teshsuite/xbt/log_usage/log_usage.c index 2523b55b54..dd9c606771 100644 --- a/teshsuite/xbt/log_usage/log_usage.c +++ b/teshsuite/xbt/log_usage/log_usage.c @@ -8,8 +8,7 @@ #include "xbt.h" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(test, top, - "Logging specific to this test"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(test, top, "Logging specific to this test"); XBT_LOG_NEW_CATEGORY(top, "Useless test channel"); static void dolog(const char *settings) @@ -22,7 +21,6 @@ static void dolog(const char *settings) XBT_CRITICAL("false alarm%s%s%s%s%s%s", "", "", "", "", "", "!"); } - int main(int argc, char **argv) { xbt_init(&argc, argv); diff --git a/teshsuite/xbt/mallocator/mallocator_test.c b/teshsuite/xbt/mallocator/mallocator_test.c index 6eda006947..180b254703 100644 --- a/teshsuite/xbt/mallocator/mallocator_test.c +++ b/teshsuite/xbt/mallocator/mallocator_test.c @@ -36,10 +36,8 @@ int main(int argc, char**argv) { xbt_mallocator_initialization_is_done(1); int i = 0; - xbt_mallocator_t mallocator = xbt_mallocator_new(65536, - element_mallocator_new_f, - element_mallocator_free_f, - element_mallocator_reset_f); + xbt_mallocator_t mallocator = + xbt_mallocator_new(65536, element_mallocator_new_f, element_mallocator_free_f, element_mallocator_reset_f); xbt_dynar_t elems = xbt_dynar_new(sizeof(element_t), NULL); element_t elem = NULL; base_mallocator = xbt_mallocator_get(mallocator); diff --git a/teshsuite/xbt/mmalloc/mmalloc_test.c b/teshsuite/xbt/mmalloc/mmalloc_test.c index b9a074c648..638b776592 100644 --- a/teshsuite/xbt/mmalloc/mmalloc_test.c +++ b/teshsuite/xbt/mmalloc/mmalloc_test.c @@ -90,7 +90,6 @@ int main(int argc, char**argv) xbt_die("FAIL: A double-free went undetected (for size:%d)",size_of_block(i)); } - XBT_INFO("Damnit, I cannot break mmalloc this time. That's SO disappointing."); return 0; } diff --git a/teshsuite/xbt/parallel_log/parallel_log_crashtest.c b/teshsuite/xbt/parallel_log/parallel_log_crashtest.c index c5c5c8e122..81f6d457d2 100644 --- a/teshsuite/xbt/parallel_log/parallel_log_crashtest.c +++ b/teshsuite/xbt/parallel_log/parallel_log_crashtest.c @@ -10,7 +10,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(synchro_crashtest, "Logs of this example"); - int test_amount = 99; /* Up to 999 to not break the logs (and thus the testing mecanism) */ int crasher_amount = 99; /* Up to 99 to not break the logs (and thus the testing mecanism) */ int *id; /* to pass a pointer to the threads without race condition */ @@ -21,9 +20,8 @@ int more_info = 0; /* SET IT TO TRUE TO GET MORE INFO */ static void* crasher_thread(void *arg) { int id = *(int *) arg; - int i; - for (i = 0; i < test_amount; i++) { + for (int i = 0; i < test_amount; i++) { if (more_info) XBT_INFO("%03d (%02d|%02d|%02d|%02d|%02d|%02d|%02d|%02d|%02d)", test_amount - i, id, id, id, id, id, id, id, id, id); @@ -51,8 +49,7 @@ int crasher(int argc, char *argv[]) /* spawn threads */ for (i = 0; i < crasher_amount; i++) { char *name = bprintf("thread %d", i); - crashers[i] = - xbt_os_thread_create(name, &crasher_thread, &id[i], NULL ); + crashers[i] = xbt_os_thread_create(name, &crasher_thread, &id[i], NULL ); free(name); } diff --git a/teshsuite/xbt/parmap_bench/parmap_bench.c b/teshsuite/xbt/parmap_bench/parmap_bench.c index ed890debd0..b73e0b1795 100644 --- a/teshsuite/xbt/parmap_bench/parmap_bench.c +++ b/teshsuite/xbt/parmap_bench/parmap_bench.c @@ -114,8 +114,7 @@ static void bench_parmap_full(int nthreads, e_xbt_parmap_mode_t mode) i++; } while (elapsed_time < TIMEOUT); - printf("ran %d times in %g seconds (%g/s)\n", - i, elapsed_time, i / elapsed_time); + printf("ran %d times in %g seconds (%g/s)\n", i, elapsed_time, i / elapsed_time); xbt_dynar_free(&data); xbt_free(a); @@ -125,8 +124,6 @@ static void bench_parmap_apply(int nthreads, e_xbt_parmap_mode_t mode) { unsigned *a; xbt_dynar_t data; - xbt_parmap_t parmap; - int i; double start_time, elapsed_time; printf("** mode = %-15s ", parmap_mode_name(mode)); @@ -137,8 +134,8 @@ static void bench_parmap_apply(int nthreads, e_xbt_parmap_mode_t mode) array_new(&a, &data); - parmap = xbt_parmap_new(nthreads, mode); - i = 0; + xbt_parmap_t parmap = xbt_parmap_new(nthreads, mode); + int i = 0; start_time = xbt_os_time(); do { xbt_parmap_apply(parmap, fun_to_apply, data); @@ -157,12 +154,9 @@ static void bench_parmap_apply(int nthreads, e_xbt_parmap_mode_t mode) static void bench_all_modes(void (*bench_fun)(int, e_xbt_parmap_mode_t), int nthreads, unsigned modes) { - e_xbt_parmap_mode_t all_modes[] = { - XBT_PARMAP_POSIX, XBT_PARMAP_FUTEX, - XBT_PARMAP_BUSY_WAIT, XBT_PARMAP_DEFAULT - }; - unsigned i; - for (i = 0 ; i < sizeof all_modes / sizeof all_modes[0] ; i++) { + e_xbt_parmap_mode_t all_modes[] = {XBT_PARMAP_POSIX, XBT_PARMAP_FUTEX, XBT_PARMAP_BUSY_WAIT, XBT_PARMAP_DEFAULT}; + + for (unsigned i = 0 ; i < sizeof all_modes / sizeof all_modes[0] ; i++) { if (1U << i & modes) bench_fun(nthreads, all_modes[i]); } @@ -176,8 +170,7 @@ int main(int argc, char *argv[]) SIMIX_global_init(&argc, argv); if (argc != 2 && argc != 3) { - fprintf(stderr, - "Usage: %s nthreads [modes]\n" + fprintf(stderr, "Usage: %s nthreads [modes]\n" " nthreads - number of working threads\n" " modes - bitmask of modes to test\n", argv[0]); @@ -191,8 +184,7 @@ int main(int argc, char *argv[]) if (argc == 3) modes = strtol(argv[2], NULL, 0); - printf("Parmap benchmark with %d workers (modes = %#x)...\n\n", - nthreads, modes); + printf("Parmap benchmark with %d workers (modes = %#x)...\n\n", nthreads, modes); fun_to_apply = fun_small_comp; diff --git a/teshsuite/xbt/parmap_test/parmap_test.c b/teshsuite/xbt/parmap_test/parmap_test.c index 8337604cdc..76ac00226e 100644 --- a/teshsuite/xbt/parmap_test/parmap_test.c +++ b/teshsuite/xbt/parmap_test/parmap_test.c @@ -47,8 +47,7 @@ static int test_parmap_basic(e_xbt_parmap_mode_t mode) for (i = 0; i < len; i++) { unsigned expected = (1U << num) * (i + 1) - 1; if (a[i] != expected) { - XBT_CRITICAL("with %u threads, a[%u]: expected %u, got %u", - num_workers, i, expected, a[i]); + XBT_CRITICAL("with %u threads, a[%u]: expected %u, got %u", num_workers, i, expected, a[i]); ret = 1; break; }