Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add a failing (since a few days) example with an explicit exit in MPI program
[simgrid.git] / teshsuite / smpi / pt2pt-dsend / pt2pt-dsend.c
index 7244ec4..c4b081e 100644 (file)
@@ -1,28 +1,61 @@
-/* Copyright (c) 2011-2014. The SimGrid Team.
+/* Copyright (c) 2011-2021. 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. */
 
 /* This program simply does a very small exchange to test whether using SIMIX dsend to model the eager mode works */
-
+#include <stdint.h>
 #include <stdio.h>
 #include <mpi.h>
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(dsend,"the dsend test");
 
-int main(int argc, char *argv[]) {
+static void test_opts(int argc, char* const argv[])
+{
+  int found = 0;
+  int option_index = 0;
+  static struct option long_options[] = {
+  {(char*)"long",     no_argument, 0,  0 },
+  {0,         0,                 0,  0 }
+  };
+  while (1) {
+    int ret = getopt_long(argc, argv, "s", long_options, &option_index);
+    if(ret==-1)
+      break;
+
+    switch (ret) {
+      case 0:
+      case 's':
+        found ++;
+      break;
+      default:
+        printf("option %s", long_options[option_index].name);
+      break;
+    }
+  }
+  if (found!=2){
+    printf("(smpi_)getopt_long failed ! \n");
+  }
+}
+
+int main(int argc, char *argv[])
+{
   int rank;
-  int data=11;
+  int32_t data=11;
+
+  MPI_Init(NULL, NULL);
+
+  /* test getopt_long function */
+  test_opts(argc, argv);
 
-  MPI_Init(&argc, &argv);
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   MPI_Request r;
   if (rank==1) {
     data=22;
-    MPI_Send(&data,1,MPI_BYTE,(rank+1)%2,666,MPI_COMM_WORLD);
+    MPI_Send(&data,1,MPI_INT32_T,(rank+1)%2,666,MPI_COMM_WORLD);
   } else {
-    MPI_Recv(&data,1,MPI_BYTE,MPI_ANY_SOURCE,666,MPI_COMM_WORLD,NULL);
+    MPI_Recv(&data,1,MPI_INT32_T,MPI_ANY_SOURCE,666,MPI_COMM_WORLD,NULL);
     if (data !=22) {
       printf("rank %d: Damn, data does not match (got %d)\n",rank, data);
     }
@@ -30,18 +63,17 @@ int main(int argc, char *argv[]) {
 
   if (rank==1) {
     data=22;
-    MPI_Isend(&data,1,MPI_BYTE,(rank+1)%2,666,MPI_COMM_WORLD, &r);
+    MPI_Isend(&data,1,MPI_INT32_T,(rank+1)%2,666,MPI_COMM_WORLD, &r);
     MPI_Wait(&r, MPI_STATUS_IGNORE);
   } else {
-    MPI_Irecv(&data,1,MPI_BYTE,MPI_ANY_SOURCE,666,MPI_COMM_WORLD,&r);
+    MPI_Irecv(&data,1,MPI_INT32_T,MPI_ANY_SOURCE,666,MPI_COMM_WORLD,&r);
     MPI_Wait(&r, MPI_STATUS_IGNORE);
     if (data !=22) {
       printf("rank %d: Damn, data does not match (got %d)\n",rank, data);
     }
   }
 
-
   XBT_INFO("rank %d: data exchanged", rank);
   MPI_Finalize();
-  return 0;
+  exit(0);
 }