Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
test getopt, getopt_long, getopt_long_only wrappers
authordegomme <adegomme@users.noreply.github.com>
Fri, 5 Apr 2019 13:12:52 +0000 (15:12 +0200)
committerdegomme <adegomme@users.noreply.github.com>
Fri, 5 Apr 2019 13:12:52 +0000 (15:12 +0200)
teshsuite/smpi/privatization/privatization.c
teshsuite/smpi/privatization/privatization.tesh
teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.c
teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh
teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c
teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.tesh

index 07c2b8f..9a9e963 100644 (file)
@@ -5,12 +5,41 @@
 
 
 static int myvalue = 0;
 
 
 static int myvalue = 0;
-
+static void test_opts(int* argc, char **argv[]){
+  int found = 0, ret;
+  static struct option long_options[] = {
+  {"long",     no_argument, 0,  0 },
+  {0,         0,                 0,  0 }
+  };
+  while (1) {
+    ret = getopt_long_only(*argc, *argv, "s",
+                long_options, NULL);
+    if(ret==-1)
+      break;
+
+    switch (ret) {
+      case 0:
+        found++;
+      break;
+      case 's':
+        found ++;
+      break;
+      default:
+        printf("option %s", long_options[0].name);
+      break;
+    }
+  }
+  if (found!=2){
+    printf("(smpi_)getopt_long_only failed ! \n");
+  }
+}
 int main(int argc, char **argv)
 {
     int me;
 
     MPI_Init(&argc, &argv);
 int main(int argc, char **argv)
 {
     int me;
 
     MPI_Init(&argc, &argv);
+    /* test getopt_long function */
+    test_opts(&argc, &argv);
 
     MPI_Comm_rank(MPI_COMM_WORLD, &me);
 
 
     MPI_Comm_rank(MPI_COMM_WORLD, &me);
 
index fa4352a..5f5f479 100644 (file)
@@ -1,4 +1,4 @@
 p Test privatization
 ! timeout 5
 p Test privatization
 ! timeout 5
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 32 ${bindir:=.}/privatization --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/privatization:${privatization:=1} --log=simix_context.thres:error --log=xbt_memory_map.thres:critical
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 32 ${bindir:=.}/privatization -s -long --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/privatization:${privatization:=1} --log=simix_context.thres:error --log=xbt_memory_map.thres:critical
 > You requested to use 32 ranks, but there is only 5 processes in your hostfile...
 > You requested to use 32 ranks, but there is only 5 processes in your hostfile...
index dbbcf91..b2fbc21 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(dsend,"the dsend test");
 
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(dsend,"the dsend test");
 
-int main()
+static void test_opts(int* argc, char **argv[]){
+  int found = 0, ret;
+  int option_index = 0;
+  static struct option long_options[] = {
+  {"long",     no_argument, 0,  0 },
+  {0,         0,                 0,  0 }
+  };
+  while (1) {
+    ret = getopt_long(*argc, *argv, "s",
+                long_options, &option_index);
+    if(ret==-1)
+      break;
+
+    switch (ret) {
+      case 0:
+        found++;
+      break;
+      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;
   int32_t data=11;
 
   MPI_Init(NULL, NULL);
 {
   int rank;
   int32_t data=11;
 
   MPI_Init(NULL, NULL);
+
+  /* test getopt_long function */
+  test_opts(&argc, &argv);
+
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   MPI_Request r;
   if (rank==1) {
   MPI_Comm_rank(MPI_COMM_WORLD, &rank);
   MPI_Request r;
   if (rank==1) {
index edd9479..09a5b98 100644 (file)
@@ -1,6 +1,6 @@
 p Test dsend
 ! output sort
 p Test dsend
 ! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/simulate-computation:no
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -s --long --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning --cfg=smpi/simulate-computation:no
 > [Jupiter:1:(2) 0.000000] [dsend/INFO] rank 1: data exchanged
 > [Tremblay:0:(1) 0.005890] [dsend/INFO] rank 0: data exchanged
 > [rank 0] -> Tremblay
 > [Jupiter:1:(2) 0.000000] [dsend/INFO] rank 1: data exchanged
 > [Tremblay:0:(1) 0.005890] [dsend/INFO] rank 0: data exchanged
 > [rank 0] -> Tremblay
@@ -11,7 +11,7 @@ p message size is 4 bytes
 p process 1 will finish at 0.5+2*4 (send) + 1+0.1*4 (isend) = 9.9s
 p process 2 will finish at 0.5+2*4 (time before first send) + 2*(1+0.5*4) (recv+irecv) + 0.005890 (network time, same as before) = 14.505890s
 ! output sort
 p process 1 will finish at 0.5+2*4 (send) + 1+0.1*4 (isend) = 9.9s
 p process 2 will finish at 0.5+2*4 (time before first send) + 2*(1+0.5*4) (recv+irecv) + 0.005890 (network time, same as before) = 14.505890s
 ! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -q --log=smpi_kernel.thres:warning --cfg=smpi/or:0:1:0.5 --cfg=smpi/os:0:0.5:2 --cfg=smpi/ois:0:1:0.1 --cfg=smpi/simulate-computation:no --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ${bindir:=.}/../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/pt2pt-dsend -s --long --log=smpi_kernel.thres:warning --cfg=smpi/or:0:1:0.5 --cfg=smpi/os:0:0.5:2 --cfg=smpi/ois:0:1:0.1 --cfg=smpi/simulate-computation:no --log=xbt_cfg.thres:warning
 > [Jupiter:1:(2) 9.900000] [dsend/INFO] rank 1: data exchanged
 > [Tremblay:0:(1) 14.505890] [dsend/INFO] rank 0: data exchanged
 > [rank 0] -> Tremblay
 > [Jupiter:1:(2) 9.900000] [dsend/INFO] rank 1: data exchanged
 > [Tremblay:0:(1) 14.505890] [dsend/INFO] rank 0: data exchanged
 > [rank 0] -> Tremblay
index e42b1b8..6ddb623 100644 (file)
@@ -9,6 +9,21 @@
 #include <stdio.h>
 #include <mpi.h>
 
 #include <stdio.h>
 #include <mpi.h>
 
+static void test_opts(int* argc, char **argv[]){
+  int found = 0, ret;
+  while ((ret = getopt(*argc, *argv, "s")) >= 0)
+  {
+    switch (ret) {
+    case 's':
+      found = 1;
+      break;
+    }
+  }
+  if (found!=1){
+    printf("(smpi_)getopt failed ! \n");
+  }
+}
+
 int main(int argc, char *argv[])
 {
   const int tag1 = 42;
 int main(int argc, char *argv[])
 {
   const int tag1 = 42;
@@ -19,6 +34,10 @@ int main(int argc, char *argv[])
   MPI_Status status;
 
   int err = MPI_Init(&argc, &argv); /* Initialize MPI */
   MPI_Status status;
 
   int err = MPI_Init(&argc, &argv); /* Initialize MPI */
+
+  /* test getopt function */
+  test_opts(&argc, &argv);
+
   if (err != MPI_SUCCESS) {
     printf("MPI initialization failed!\n");
     exit(1);
   if (err != MPI_SUCCESS) {
     printf("MPI initialization failed!\n");
     exit(1);
index 6120d55..fb42fb4 100644 (file)
@@ -1,6 +1,6 @@
 p Test pingpong
 ! output sort
 p Test pingpong
 ! output sort
-$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ../../../examples/platforms/small_platform.xml -np 4 ${bindir:=.}/pt2pt-pingpong -s --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
 >     *** Ping-pong test (MPI_Send/MPI_Recv) ***
 >
 >
 >     *** Ping-pong test (MPI_Send/MPI_Recv) ***
 >
 >