Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please sonar in various trivial ways
[simgrid.git] / teshsuite / smpi / privatization / privatization.c
1
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <mpi.h>
5
6
7 static int myvalue = 0;
8 static void test_opts(int* argc, char **argv[]){
9   int found = 0;
10   int ret;
11   static struct option long_options[] = {
12   {"long",     no_argument, 0,  0 },
13   {0,         0,                 0,  0 }
14   };
15   while (1) {
16     ret = getopt_long_only(*argc, *argv, "s",
17                 long_options, NULL);
18     if(ret==-1)
19       break;
20
21     switch (ret) {
22       case 0:
23         found++;
24       break;
25       case 's':
26         found ++;
27       break;
28       default:
29         printf("option %s", long_options[0].name);
30       break;
31     }
32   }
33   if (found!=2){
34     printf("(smpi_)getopt_long_only failed ! \n");
35   }
36 }
37 int main(int argc, char **argv)
38 {
39     int me;
40
41     MPI_Init(&argc, &argv);
42     /* test getopt_long function */
43     test_opts(&argc, &argv);
44
45     MPI_Comm_rank(MPI_COMM_WORLD, &me);
46
47     MPI_Barrier(MPI_COMM_WORLD);
48
49     myvalue = me;
50
51     MPI_Barrier(MPI_COMM_WORLD);
52
53     if(myvalue!=me)
54       printf("Privatization error - %d != %d\n", myvalue, me);
55     MPI_Finalize();
56     return 0;
57 }