Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
coverage madness in examples
[simgrid.git] / examples / msg / chord / chord.c
index a64b03a..21c6a8c 100644 (file)
@@ -1,15 +1,16 @@
-/* Copyright (c) 2010-2014. The SimGrid Team.
+/* Copyright (c) 2010-2015. 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. */
 
 #include <stdio.h>
-#include "msg/msg.h"
+#include "simgrid/msg.h"
 #include "xbt/log.h"
 #include "xbt/asserts.h"
 #include "simgrid/modelchecker.h"
 #include <xbt/RngStream.h>
+#include "src/mc/mc_replay.h" // FIXME: this is an internal header
 
 /** @addtogroup MSG_examples
  *
@@ -297,7 +298,7 @@ int node(int argc, char *argv[])
 {
 
   /* Reduce the run size for the MC */
-  if(MC_is_active()){
+  if(MC_is_active() || MC_record_replay_is_active()){
     periodic_stabilize_delay = 8;
     periodic_fix_fingers_delay = 8;
     periodic_check_predecessor_delay = 8;
@@ -371,8 +372,8 @@ int node(int argc, char *argv[])
 
         // no task was received: make some periodic calls
 
-        if(MC_is_active()){
-          if(!MC_visited_reduction() && no_op){
+        if(MC_is_active() || MC_record_replay_is_active()){
+          if(MC_is_active() && !MC_visited_reduction() && no_op){
               MC_cut();
           }
           if(listen == 0 && (sub_protocol = MC_random(0, 4)) > 0){
@@ -1025,11 +1026,10 @@ static void random_lookup(node_t node)
 int main(int argc, char *argv[])
 {
   MSG_init(&argc, argv);
-  if (argc < 3) {
-    printf("Usage: %s [-nb_bits=n] [-timeout=t] platform_file deployment_file\n", argv[0]);
-    printf("example: %s ../msg_platform.xml chord.xml\n", argv[0]);
-    exit(1);
-  }
+  xbt_assert(argc > 2, 
+            "Usage: %s [-nb_bits=n] [-timeout=t] platform_file deployment_file\n"
+            "\tExample: %s ../msg_platform.xml chord.xml\n", 
+            argv[0], argv[0]);
 
   char **options = &argv[1];
   while (!strncmp(options[0], "-", 1)) {
@@ -1069,8 +1069,5 @@ int main(int argc, char *argv[])
 
   chord_exit();
 
-  if (res == MSG_OK)
-    return 0;
-  else
-    return 1;
+  return res != MSG_OK;
 }