From c459a45307959148a042cbf932f2666ab333fba4 Mon Sep 17 00:00:00 2001 From: degomme Date: Fri, 5 Apr 2019 15:12:52 +0200 Subject: [PATCH 1/1] test getopt, getopt_long, getopt_long_only wrappers --- teshsuite/smpi/privatization/privatization.c | 31 +++++++++++++++- .../smpi/privatization/privatization.tesh | 2 +- teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.c | 36 ++++++++++++++++++- teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh | 4 +-- .../smpi/pt2pt-pingpong/pt2pt-pingpong.c | 19 ++++++++++ .../smpi/pt2pt-pingpong/pt2pt-pingpong.tesh | 2 +- 6 files changed, 88 insertions(+), 6 deletions(-) diff --git a/teshsuite/smpi/privatization/privatization.c b/teshsuite/smpi/privatization/privatization.c index 07c2b8fa95..9a9e963627 100644 --- a/teshsuite/smpi/privatization/privatization.c +++ b/teshsuite/smpi/privatization/privatization.c @@ -5,12 +5,41 @@ 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); + /* test getopt_long function */ + test_opts(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &me); diff --git a/teshsuite/smpi/privatization/privatization.tesh b/teshsuite/smpi/privatization/privatization.tesh index fa4352a5bc..5f5f479ff2 100644 --- a/teshsuite/smpi/privatization/privatization.tesh +++ b/teshsuite/smpi/privatization/privatization.tesh @@ -1,4 +1,4 @@ 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... diff --git a/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.c b/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.c index dbbcf91aa0..b2fbc2148d 100644 --- a/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.c +++ b/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.c @@ -11,12 +11,46 @@ 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); + + /* test getopt_long function */ + test_opts(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Request r; if (rank==1) { diff --git a/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh b/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh index edd94799a4..09a5b988c8 100644 --- a/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh +++ b/teshsuite/smpi/pt2pt-dsend/pt2pt-dsend.tesh @@ -1,6 +1,6 @@ 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 @@ -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 -$ ${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 diff --git a/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c b/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c index e42b1b855d..6ddb623680 100644 --- a/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c +++ b/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.c @@ -9,6 +9,21 @@ #include #include +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; @@ -19,6 +34,10 @@ int main(int argc, char *argv[]) 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); diff --git a/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.tesh b/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.tesh index 6120d55019..fb42fb4963 100644 --- a/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.tesh +++ b/teshsuite/smpi/pt2pt-pingpong/pt2pt-pingpong.tesh @@ -1,6 +1,6 @@ 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) *** > > -- 2.20.1