Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add mpich3 test suite, to replace older one.
[simgrid.git] / teshsuite / smpi / mpich-test / env / getproc.c
1 /*
2  * Test get processor name
3  *
4  */
5 #include "mpi.h"
6 #include <string.h>
7 #include <stdio.h>
8 #include <ctype.h>
9
10 int main( int argc, char *argv[] )
11 {
12     char name[MPI_MAX_PROCESSOR_NAME+10];
13     int  resultlen;
14     int  err = 0;
15
16     MPI_Init( &argc, &argv );
17
18     memset( name, 0xFF, MPI_MAX_PROCESSOR_NAME+10 );
19     resultlen = 0;
20
21     MPI_Get_processor_name( name, &resultlen );
22     /* Test that name has only printing characters */
23     if (resultlen > MPI_MAX_PROCESSOR_NAME || resultlen <= 0) {
24         fprintf( stderr, "resultlen (%d) invalid\n", resultlen );
25         err++;
26     }
27     if (!err) {
28         int i;
29         for (i=0; i<resultlen; i++) {
30             if (!isprint(name[i])) {
31                 fprintf( stderr, "Character number %d is not printable\n", i );
32                 err++;
33             }
34         }
35         if (name[resultlen]) {
36             fprintf( stderr, "No null at end of name\n" );
37             err++;
38         }
39         for (i=resultlen+1; i<MPI_MAX_PROCESSOR_NAME+10; i++) {
40             unsigned char *usname = (unsigned char*)name;
41             if ((int)(usname[i]) != 0xFF) {
42                 fprintf( stderr, "Characters changed at end of name\n" );
43                 err++;
44             }
45         }
46     }
47
48     if (err) {
49         printf( " Found %d errors\n", err );
50     }
51     else {
52         printf( " No Errors\n" );
53     }
54         
55     MPI_Finalize();
56     return 0;
57 }